项目介绍
随着国内市场经济这几十年来的蓬勃发展,突然遇到了从国外传入国内的互联网技术,互联网产业从开始的群众不信任,到现在的离不开,中间经历了很多挫折。本次开发的个人博客系统,有管理员,用户,博主三个角色。管理员功能有个人中心,用户管理,博主管理,文章分类管理,博主文章管理,系统公告管理,轮播图管理。博主可以注册登录,修改个人信息,对自己发布的博主文章进行管理操作。用户可以注册登录,查看管理员发布的公告信息和博主发布的文章信息,还可以对博主文章进行收藏评论以及评论操作。开发本程序后台用到了Spring Boot开发技术,页面设计采用VUE框架和layui样式。数据库采用关系数据库市场占有率最高的MySQL作为本程序使用的数据库,完全符合程序使用并且有丰富的拓展余地。程序从需求到设计,从开发到测试,都在功能上和性能上都不断的进行了调试,让开发的程序在使用上用户体验更美好。
开发环境
编程语言:Java
数据库 :Mysql
系统架构:B/S
后端框架:SpringBoot
编译工具:idea或者eclipse,jdk1.8,maven
支持定做:java/php/python/android/小程序vue/爬虫/c#/asp.net
系统实现
5.1 管理员功能实现
5.1.1 用户管理
管理员可以对用户信息进行添加,修改,删除,查询操作。
图5.1 用户管理页面
5.1.2 文章分类管理
管理员可以对文章分类信息进行添加,修改,删除,查询操作。
图5.2 文章分类管理页面
5.1.3 公告信息管理
管理员可以对公告信息进行添加,修改,删除,查询操作。
图5.3 公告信息管理页面
5.1.4 博主信息管理
管理员可以对博主信息信息进行添加,修改,删除,查询操作。
图5.4 博主信息管理页面
5.2 博主功能实现
5.2.1 博主文章管理
博主可以对自己发布过的博主文章信息进行添加,修改,删除,查询操作,还可以查看评论。
图5.5首页页面
5.3 用户功能实现
5.3.1 博主文章信息
用户可以在博主文章里面查看到博主发布的文章信息,可以对博主文章信息进行查看,收藏,赞踩,评论操作。
图5.6 博主文章信息页面
5.3.2 我的收藏
我的收藏里面可以看到自己收藏过的博主文章信息,可以去点击收藏的信息去取消收藏。
图5.7 我的收藏页面
核心代码
package com.controller;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;
import com.entity.BozhuEntity;
import com.entity.view.BozhuView;
import com.service.BozhuService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;
import java.io.IOException;
/**
* 博主
* 后端接口
* @author
* @email
* @date
*/
@RestController
@RequestMapping("/bozhu")
public class BozhuController {
@Autowired
private BozhuService bozhuService;
@Autowired
private TokenService tokenService;
/**
* 登录
*/
@IgnoreAuth
@RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
BozhuEntity user = bozhuService.selectOne(new EntityWrapper<BozhuEntity>().eq("bozhuhao", username));
if(user==null || !user.getMima().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(user.getId(), username,"bozhu", "博主" );
return R.ok().put("token", token);
}
/**
* 注册
*/
@IgnoreAuth
@RequestMapping("/register")
public R register(@RequestBody BozhuEntity bozhu){
//ValidatorUtils.validateEntity(bozhu);
BozhuEntity user = bozhuService.selectOne(new EntityWrapper<BozhuEntity>().eq("bozhuhao", bozhu.getBozhuhao()));
if(user!=null) {
return R.error("注册用户已存在");
}
Long uId = new Date().getTime();
bozhu.setId(uId);
bozhuService.insert(bozhu);
return R.ok();
}
/**
* 退出
*/
@RequestMapping("/logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("退出成功");
}
/**
* 获取用户的session用户信息
*/
@RequestMapping("/session")
public R getCurrUser(HttpServletRequest request){
Long id = (Long)request.getSession().getAttribute("userId");
BozhuEntity user = bozhuService.selectById(id);
return R.ok().put("data", user);
}
/**
* 密码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
BozhuEntity user = bozhuService.selectOne(new EntityWrapper<BozhuEntity>().eq("bozhuhao", username));
if(user==null) {
return R.error("账号不存在");
}
user.setMima("123456");
bozhuService.updateById(user);
return R.ok("密码已重置为:123456");
}
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,BozhuEntity bozhu,
HttpServletRequest request){
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("bozhu")) {
bozhu.setBozhuhao((String)request.getSession().getAttribute("username"));
}
EntityWrapper<BozhuEntity> ew = new EntityWrapper<BozhuEntity>();
PageUtils page = bozhuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, bozhu), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,BozhuEntity bozhu,
HttpServletRequest request){
EntityWrapper<BozhuEntity> ew = new EntityWrapper<BozhuEntity>();
PageUtils page = bozhuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, bozhu), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( BozhuEntity bozhu){
EntityWrapper<BozhuEntity> ew = new EntityWrapper<BozhuEntity>();
ew.allEq(MPUtil.allEQMapPre( bozhu, "bozhu"));
return R.ok().put("data", bozhuService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(BozhuEntity bozhu){
EntityWrapper< BozhuEntity> ew = new EntityWrapper< BozhuEntity>();
ew.allEq(MPUtil.allEQMapPre( bozhu, "bozhu"));
BozhuView bozhuView = bozhuService.selectView(ew);
return R.ok("查询博主成功").put("data", bozhuView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
BozhuEntity bozhu = bozhuService.selectById(id);
return R.ok().put("data", bozhu);
}
/**
* 前端详情
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
BozhuEntity bozhu = bozhuService.selectById(id);
return R.ok().put("data", bozhu);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody BozhuEntity bozhu, HttpServletRequest request){
bozhu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(bozhu);
BozhuEntity user = bozhuService.selectOne(new EntityWrapper<BozhuEntity>().eq("bozhuhao", bozhu.getBozhuhao()));
if(user!=null) {
return R.error("用户已存在");
}
bozhu.setId(new Date().getTime());
bozhuService.insert(bozhu);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody BozhuEntity bozhu, HttpServletRequest request){
bozhu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(bozhu);
BozhuEntity user = bozhuService.selectOne(new EntityWrapper<BozhuEntity>().eq("bozhuhao", bozhu.getBozhuhao()));
if(user!=null) {
return R.error("用户已存在");
}
bozhu.setId(new Date().getTime());
bozhuService.insert(bozhu);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody BozhuEntity bozhu, HttpServletRequest request){
//ValidatorUtils.validateEntity(bozhu);
bozhuService.updateById(bozhu);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
bozhuService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 提醒接口
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<BozhuEntity> wrapper = new EntityWrapper<BozhuEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("bozhu")) {
wrapper.eq("bozhuhao", (String)request.getSession().getAttribute("username"));
}
int count = bozhuService.selectCount(wrapper);
return R.ok().put("count", count);
}
}
论文参考
目 录
目 录 III
1 绪论 1
1.1 研究背景 1
1.2 研究意义 1
1.3 研究内容 1
2 开发技术 3
2.1 VUE框架 3
2.2 Mysql数据库 3
2.3 Spring Boot框架 3
2.4 layui介绍 4
3 系统分析 5
3.1可行性研究 5
3.2系统性能分析 6
3.3 系统流程分析 6
3.3.1 系统开发流程 6
3.3.2 系统注册流程 7
3.3.3 系统登录流程 8
4 系统设计 10
4.1 系统结构设计 10
4.2系统功能模块设计 11
4.3数据库设计 11
4.3.1数据库E-R图 11
4.3.2 数据库表结构 13
5 系统实现 16
5.1 管理员功能实现 16
5.1.1 用户管理 16
5.1.2 文章分类管理 16
5.1.3 公告信息管理 17
5.1.4 博主信息管理 17
5.2 博主功能实现 18
5.2.1 博主文章管理 18
5.3 用户功能实现 19
5.3.1 博主文章信息 19
5.3.2 我的收藏 19
6系统测试 21
6.1 测试的基本概念 21
6.2 测试的任务和目的 21
6.2.1测试的任务 21
6.2.2测试的目的 22
6.3 测试结果分析 22
结 论 23
参考文献 24
致 谢 25