基于SpringBoot+Bootstrap【爱码个人博客系统】附源码

简介: 基于SpringBoot+Bootstrap【爱码个人博客系统】附源码

前言介绍:


随着Internet的广泛应用,动态网页技术也应运而生。本文介绍了应用ASP动态网页技术开发博客系统的设计与实现,

博客系统主要为用户提供发表文章、浏览文章等功能,用户通过Internet 可以发表一些自己撰写的文章以和其他网友进行交流。博客系统主要实现了文章管理的数字化、信息化、智能化,是打破传统报刊、杂志发表文章方式的新尝试。本系统的开发设计实现采用JAVA技术,


系统后台使用SQL数据库,并通过使用JDBC技术访问。本文对博客系统进行整体分析,明确了系统的可行性和用户需求;根据模块化原理,规划设计了系统功能模块;在数据库设计部分,详细说明了系统数据库的结构和数据库的完整性、安全性措施;程序设计则采用面向对象的程序设计思想,提出系统的程序设计思路,对前台与后台功能的程序实现进行了详细论述;系统测试部分,具体分析测试过程中出现的主要问题,并提出了解决方案,实现系统功能。最后,对系统作以客观、全面的评价,并对进一步改进提出了建议。


With the wide application of Internet, dynamic web technology also arises at the historic moment. This paper introduces the design and implementation of the application of ASP dynamic web technology to develop the blog system. The blog system mainly provides users with the functions of publishing articles, browsing articles and so on. Users can publish some of their own articles through the Internet to communicate with other netizens. Blog system mainly realizes the digitalization, information and intelligence of article management, which is a new attempt to break the traditional way of publishing articles in newspapers and magazines. The development and design of this system adopts ASP technology, SQL Server 2008 database is used in the background of the system, and access by using ODBC technology. This article carries on the whole analysis to the blog system, has made clear the feasibility of the system and the user demand; According to the modularization principle, the functional modules of the system are planned and designed. In the database design part, detailed description of the system database structure and database integrity, security measures; The program design adopts object-oriented program design idea, puts forward the system program design idea, and discusses the program realization of the foreground and background function in detail. The system test part, the specific analysis of the test process of the main problems, and put forward solutions to achieve system functions. Finally, an objective and comprehensive evaluation of the system is made, and some suggestions for further improvement are put forward.


一、行业发展原因分析

个人博客能让个人在互联网上表达自己的心声。这是一个收集和共享任何感兴趣的事物的地方一可以是政治评论、个人日记或是指向您想记住的网站的链接。


它是一种简单有效的提供网络用户之间进行 在线交流的网络平台,通过个人博客可以结交更多的朋友, 表达更多的想法,它随时可以发布日志,方便快捷。个人博客作为一种新的表达方式,它传播的不仅是情绪,还包括大量的智慧、意见和思想。


从某种意义上说,它也是一种新的文化现象,个人博客的出现和繁荣,真正凸现了网络的知识价值,标志着互联网发展开始步入更高的阶段这样不仅促进了学习,更重要的是反映了一个人的在思想上的成长过程。访客可以直接在个人博客上留言,如提出问题或意见。通过研究开发本系统,使我们了解当今个人博客发展的最新动态,人博客对 以及个整个社会的影响力。同时,可以使我们掌握个人网站开发的基本方法和技术,为以后的实际开发莫定基础。

系统设计:

该项目是基于SpringBoot+Bootstrap【爱码个人博客系统】,下面做了功能和相关技术的描述,适合出入职场和即将进入职场的各位,如有问题欢迎留言。

系统总共分为几个大的模块。

博客系统分为两大模块:

1.博客前台页面,游客可以查看博主发表的文章,也可以注册后登录对博主文章进行评论

2.博客系统后台管理,管理员登录后可以发表,删除,修改文章,也可以对游客信息进行查看,修改等操作

运行环境

JDK8、Tomcat8、MySQL5.7、IntelliJ IDEA、Maven

  • 核心技术:

Spring Boot2、MyBatis、Bootstrap、jQuery


账号:

如果使用原配置及数据库文件,可以使用一下方式登录

首页:<http://127.0.0.1:8080/>

账号:zhangsan zhangsan


后台:http://127.0.0.1:8080/admin/login

账号:admin admin

功能截图:

代码实现:

package com.lee.common;

import java.util.ArrayList;
import java.util.List;

/**
 * 表格数据存储对象
 * 默认作为bootstrap表格对应的数据结构存储对象
 * author:lee
 */
public class DataGrid {
    private Long total = Long.valueOf(0);
    private List rows = new ArrayList();

    public Long getTotal() {
        return total;
    }
    public void setTotal(Long total) {
        this.total = total;
    }
    public List getRows() {
        return rows;
    }
    public void setRows(List rows) {
        this.rows = rows;
    }
}
package com.lee.controller.admin;


import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lee.common.DataGrid;
import com.lee.common.DateTimeUtil;
import com.lee.common.Message;
import com.lee.entity.Admin;
import com.lee.entity.Article;
import com.lee.service.ArticleService;
import com.lee.service.CateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lee
 * @since 2020-02-22
 */
@Controller
@RequestMapping("/admin/article")
public class ArticleController extends BasicController {
    @Autowired
    ArticleService articleService;
    @Autowired
    CateService cateService;
    @GetMapping("list")
    public String list(){
        return "admin/article/list";
    }
    @PostMapping("findList")
    @ResponseBody
    public DataGrid findList(@RequestBody JSONObject jsonObject){
        Map<String, Object> searchParams = (HashMap<String, Object>) jsonObject.get("search");
        int offset = "".equals(jsonObject.getString("offset")) ? 0 : jsonObject.getIntValue("offset");
        int size = "".equals(jsonObject.getString("limit")) ? 10 : jsonObject.getIntValue("limit");

        IPage<Map<String, Object>> page = articleService.getPageInfo(searchParams, offset, size);

        DataGrid result = new DataGrid();
        result.setTotal(page.getTotal());
        result.setRows(page.getRecords());
        return result;
    }
    @GetMapping("add")
    public String add(Model model) {
        model.addAttribute("cateInfos",cateService.getList());
        return "admin/article/add";
    }

    @PostMapping("add")
    @ResponseBody
    public Message doAdd(@Validated Article article, HttpServletRequest request){
        try {
            Admin admin = getCurrentUser(request);
            if(admin != null) {
                if(article.getIsTop() == null) {
                    article.setIsTop(0);
                }
                article.setCreateTime(DateTimeUtil.nowTimeStr());
                article.setMemberId(admin.getId());
                articleService.save(article);
                return Message.success("文章添加成功!");
            } else {
                return Message.fail("登录超时,请重新登录!",null,"/admin/login");
            }
        } catch (Exception e) {
            return Message.fail("文章数据保存异常,保存失败!");
        }

    }
    @PostMapping("top")
    @ResponseBody
    public Message top(@RequestParam(value = "id")Integer id,@RequestParam(value = "istop")Integer istop){
        try{
           Article article =  articleService.getById(id);
           if(article != null) {
               if(istop == 1) {
                   article.setIsTop(0);
               } else if(istop == 0) {
                   article.setIsTop(1);
               }
               articleService.updateById(article);
               return Message.success("操作成功!");
           } else {
               return Message.fail("文章不存在或已被删除,操作失败!");
           }
        } catch (Exception e) {
            return Message.fail("文章推荐操作处理异常!");
        }
    }
    @GetMapping("/update/{id}")
    public String update(@PathVariable Integer id,Model model){
       Article article =  articleService.getById(id);
        model.addAttribute("cateInfos",cateService.getList());
        model.addAttribute("articleInfo",article);
       return "admin/article/update";
    }
    @PostMapping("/update")
    @ResponseBody
    public Message doUpdate(@Validated Article article){
        try{
            Article articleInfo = articleService.getById(article.getId());
            if(articleInfo != null) {
                if(article.getIsTop() == null) {
                    articleInfo.setIsTop(0);
                } else {
                    articleInfo.setIsTop(article.getIsTop());
                }

                articleInfo.setTitle(article.getTitle());
                articleInfo.setAuthorname(article.getAuthorname());
                articleInfo.setTags(article.getTags());
                articleInfo.setArtdesc(article.getArtdesc());
                articleInfo.setContent(article.getContent());
                articleInfo.setCateId(article.getCateId());
                articleInfo.setUpdateTime(DateTimeUtil.nowTimeStr());
                articleService.updateById(articleInfo);
                return Message.success("文章修改成功!");
            } else {
                return Message.fail("文章不存在或已被删除!");
            }
        } catch (Exception e) {
            return Message.fail("文章修改保存异常,操作失败!");
        }
    }
    @PostMapping("delete")
    @ResponseBody
    public Message delete(@RequestParam(value = "ids") List<Integer> ids) {
        try {
            for (int id : ids) {
                articleService.deleteArticleAndCommentById(id);
            }
            return Message.success("文章删除成功");
        } catch (Exception e) {
            return Message.fail("文章删除异常!");
        }
    }

}

package com.lee.controller.admin;

import com.lee.entity.Article;
import com.lee.entity.Member;
import com.lee.service.ArticleService;
import com.lee.service.CommentService;
import com.lee.service.MemberService;
import com.sun.org.apache.xpath.internal.operations.Mod;
import org.apache.catalina.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.nio.channels.MembershipKey;

@Controller
@RequestMapping("/admin")
public class HomeController {
    @Autowired
    MemberService memberService;
    @Autowired
    ArticleService articleService;
    @Autowired
    CommentService commentService;

    @RequestMapping("home")
    public String home(Model model){
        int memberCount = memberService.count();
        int articleCount = articleService.count();
        int commentCount = commentService.count();
        model.addAttribute("memberCount",memberCount);
        model.addAttribute("articleCount",articleCount);
        model.addAttribute("commentCount",commentCount);
        return "admin/home";
    }

    /**
     * 退出管理
     * @return
     */
    @RequestMapping("logout")
    public String logout(HttpServletRequest request){
        request.getSession().removeAttribute("admin");
        if(request.getSession().getAttribute("admin") != null) {
            //ToDO session清空失败,可以跳转到退出失败页面
        }
//        return "redirect:/admin/login";
        return "admin/login";
    }
}

package com.lee.controller.admin;


import com.lee.common.DateTimeUtil;
import com.lee.common.Message;
import com.lee.entity.Syssetting;
import com.lee.service.SyssettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.Time;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lee
 * @since 2020-02-24
 */
@Controller
@RequestMapping("/admin/syssetting")
public class SyssettingController {
    @Autowired
    SyssettingService syssettingService;

    @GetMapping("add")
    public String add(Model model){
        Syssetting syssetting =  syssettingService.getById(1);
        if(syssetting != null) {
            model.addAttribute("syssetting",syssetting);
        }
        return "admin/syssetting/add";
    }
    @PostMapping("add")
    @ResponseBody
    public Message doAdd(@Validated Syssetting syssetting){
        try{
            Syssetting syssettingInfo = syssettingService.getById(1);
            if (syssettingInfo == null) {
                syssettingInfo = new Syssetting();
                syssettingInfo.setCopyright(syssetting.getCopyright());
                syssettingInfo.setWebname(syssetting.getWebname());
                syssettingInfo .setCreateTime(DateTimeUtil.nowTimeStr());
                syssettingInfo.setSign(syssetting.getSign());
                syssettingService.save(syssettingInfo);
            } else {
                syssettingInfo.setCopyright(syssetting.getCopyright());
                syssettingInfo.setWebname(syssetting.getWebname());
                syssettingInfo .setUpdateTime(DateTimeUtil.nowTimeStr());
                syssettingInfo.setSign(syssetting.getSign());
                syssettingService.updateById(syssettingInfo);
            }
            return Message.success("系统设置保存成功");
        } catch (Exception e) {
            return Message.fail("系统设置保存异常!");
        }
    }
}

论文参考:

目录
相关文章
|
7天前
|
设计模式 Java 关系型数据库
【Java笔记+踩坑汇总】Java基础+JavaWeb+SSM+SpringBoot+SpringCloud+瑞吉外卖/谷粒商城/学成在线+设计模式+面试题汇总+性能调优/架构设计+源码解析
本文是“Java学习路线”专栏的导航文章,目标是为Java初学者和初中高级工程师提供一套完整的Java学习路线。
|
2天前
|
机器学习/深度学习 数据采集 JavaScript
ADR智能监测系统源码,系统采用Java开发,基于SpringBoot框架,前端使用Vue,可自动预警药品不良反应
ADR药品不良反应监测系统是一款智能化工具,用于监测和分析药品不良反应。该系统通过收集和分析病历、处方及实验室数据,快速识别潜在不良反应,提升用药安全性。系统采用Java开发,基于SpringBoot框架,前端使用Vue,具备数据采集、清洗、分析等功能模块,并能生成监测报告辅助医务人员决策。通过集成多种数据源并运用机器学习算法,系统可自动预警药品不良反应,有效减少药害事故,保障公众健康。
ADR智能监测系统源码,系统采用Java开发,基于SpringBoot框架,前端使用Vue,可自动预警药品不良反应
|
1月前
|
JavaScript Java 关系型数据库
美妆商城系统 SpringBoot + Vue 【毕业设计 资料 + 源码】
这篇文章介绍了一个使用SpringBoot + Vue + Mybatis + Mysql技术栈开发的美妆商城系统,包括系统功能划分、部分页面截图和前后端源码示例,并提供了GitHub上的源码链接。
美妆商城系统 SpringBoot + Vue 【毕业设计 资料 + 源码】
|
22天前
|
JavaScript 前端开发 小程序
【项目实战】SpringBoot+vue+iview打造一个极简个人博客系统
这是一个基于 SpringBoot+MybatisPlus+Vue+Iview 技术栈构建的个人极简博客系统,适合初学者实战练习。项目包含文章分类、撰写文章、标签管理和用户管理等功能,代码简洁并配有详细注释,易于上手。此外,该项目也可作为毕业设计的基础进行二次开发。
77 0
【项目实战】SpringBoot+vue+iview打造一个极简个人博客系统
|
30天前
|
安全 Java 关系型数据库
毕设项目&课程设计&毕设项目:基于springboot+jsp实现的健身房管理系统(含教程&源码&数据库数据)
本文介绍了一款基于Spring Boot和JSP技术实现的健身房管理系统。随着健康生活观念的普及,健身房成为日常锻炼的重要场所,高效管理会员信息、课程安排等变得尤为重要。该系统旨在通过简洁的操作界面帮助管理者轻松处理日常运营挑战。技术栈包括:JDK 1.8、Maven 3.6、MySQL 8.0、JSP、Shiro、Spring Boot 2.0等。系统功能覆盖登录、会员管理(如会员列表、充值管理)、教练管理、课程管理、器材管理、物品遗失管理、商品管理及信息统计等多方面。
|
28天前
|
JavaScript Java 关系型数据库
毕设项目&课程设计&毕设项目:基于springboot+vue实现的前后端分离的考试管理系统(含教程&源码&数据库数据)
在数字化时代背景下,本文详细介绍了如何使用Spring Boot框架结合Vue.js技术栈,实现一个前后端分离的考试管理系统。该系统旨在提升考试管理效率,优化用户体验,确保数据安全及可维护性。技术选型包括:Spring Boot 2.0、Vue.js 2.0、Node.js 12.14.0、MySQL 8.0、Element-UI等。系统功能涵盖登录注册、学员考试(包括查看试卷、答题、成绩查询等)、管理员功能(题库管理、试题管理、试卷管理、系统设置等)。
毕设项目&课程设计&毕设项目:基于springboot+vue实现的前后端分离的考试管理系统(含教程&源码&数据库数据)
|
1月前
|
Web App开发 前端开发 关系型数据库
基于SpringBoot+Vue+Redis+Mybatis的商城购物系统 【系统实现+系统源码+答辩PPT】
这篇文章介绍了一个基于SpringBoot+Vue+Redis+Mybatis技术栈开发的商城购物系统,包括系统功能、页面展示、前后端项目结构和核心代码,以及如何获取系统源码和答辩PPT的方法。
|
1月前
|
JavaScript Java Maven
毕设项目&课程设计&毕设项目:springboot+vue实现的在线求职管理平台(含教程&源码&数据库数据)
本文介绍了一款基于Spring Boot和Vue.js实现的在线求职平台。该平台采用了前后端分离的架构,使用Spring Boot作为后端服务
毕设项目&课程设计&毕设项目:springboot+vue实现的在线求职管理平台(含教程&源码&数据库数据)
|
缓存 Java Spring
Spring&SpringBoot源码笔记整理 |Bean的加载流程二
昨天的文章里提到Bean的加载流程和如何获取bean,今天继续源码解读。还是老规矩,看着Bean加载的时序图进入主题。
321 0
Spring&SpringBoot源码笔记整理 |Bean的加载流程二
|
缓存 Java Spring
Spring&SpringBoot源码笔记整理 |Bean的加载流程一
本篇文章主要介绍Bean的加载流程,以及Spring是怎么解决循环依赖的问题。
129 0
Spring&SpringBoot源码笔记整理 |Bean的加载流程一