基于javaweb的SpringBoot个人博客系统(前后端分离+java+vue+springboot+ssm+mysql+maven)

运行环境

Java≥8、MySQL≥5.7、Node.js≥14

开发工具

后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可

❗没学过node.js的不要搞前后端分离项目

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

370123032402

380123032402

390123032402

400123032402

基于javaweb的SpringBoot个人博客系统(前后端分离+java+vue+springboot+ssm+mysql+maven)

一、项目简述

本系统功能包括:文章展示、热门文章、文章分类、标签云用户登录评论、匿名评论用户留言、匿名留言评论管理、文章发布、文章管理文章数据统计等等.

二、项目运行

环境配置: Jdkl . 8 + + Mysql + HBuilderX ( Webstorm 也行) + Eclispe ( IntelliJ 10 以,三 clispe , MyEclispe , Sts 都支持)。

项目技术: Springboot + Maven + Mybatis + Vue + Redis 组成, BIS 模式+ M aven 等等,附带支付宝沙箱环境以及支付环节代码。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
    @Autowired
private CommentService commentService;

@ApiOperation("分页展示评论列表")
@GetMapping("/")
public PageInfoVO<CommentItemVO> getComment(
@RequestParam(value = "pageNumber", defaultValue = "1", required = false) Integer pageNumber) {
PageInfoVO<CommentItemVO> pageInfoVO = commentService.findAllComments(pageNumber);
return pageInfoVO;
}

@ApiOperation("根据id删除对应评论")
@DeleteMapping("/{id}")
public ResultVO delById(@PathVariable Long id) {
commentService.deleteById(id);
return ResultVO.ok("操作成功!");
}
}
package com.qianyucc.blog.controller.comm;



/**
* @description 获取blog的信息
*/
@Slf4j
@RestController("commBlogController")
@RequestMapping("/comm/blog")
public class BlogController {
@Autowired
private BlogService blogService;
@Autowired
private Configs configs;

@ApiOperation("获取博客信息")
@GetMapping("/info")
public BlogInfoVO getInfo() {
BlogInfoVO blogInfo = blogService.getBlogInfo();
return blogInfo;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
        DraftDO draftDO = draftMapper.findById(id);
return draftDO;
}

@ApiOperation("新增草稿")
@PostMapping("/")
public Map<String, Object> saveDraft(@RequestBody DraftDTO draftDTO) {
// 生成唯一id
String id = IdUtil.simpleUUID();
DraftDO draftDO = new DraftDO();
draftDO.setTitle(draftDTO.getTitle());
draftDO.setContent(draftDTO.getContent());
draftDO.setGmtUpdate(System.currentTimeMillis());
draftDO.setGmtCreate(draftDO.getGmtUpdate());
draftDO.setId(id);

draftMapper.insDraft(draftDO);
Map<String, Object> map = new HashMap<>();
map.put("msg", "文章已自动保存,上次保存时间:" + Utils.formatDate(draftDO.getGmtUpdate(), DATE_TIME_PATTERN));
map.put("id", id);
return map;
}

@ApiOperation("更新草稿")
@PutMapping("/")
public Map<String, Object> updDraft(@RequestBody DraftDTO draftDTO) {
DraftDO draftDO = new DraftDO();
String id = draftDTO.getId();
draftDO.setId(id);
draftDO.setTitle(draftDTO.getTitle());
draftDO.setContent(draftDTO.getContent());
draftDO.setGmtUpdate(System.currentTimeMillis());
draftMapper.updDraft(draftDO);
Map<String, Object> map = new HashMap<>();
map.put("msg", "文章已自动保存,上次保存时间:" + Utils.formatDate(draftDO.getGmtUpdate(), DATE_TIME_PATTERN));
map.put("id", id);
return map;
}

@ApiOperation("根据id删除指定草稿")
@DeleteMapping("/{id}")
public ResultVO get(@PathVariable String id) {
draftMapper.deleteById(id);
return ResultVO.ok("删除成功");
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    public PageInfoVO<CommentItemVO> getComment(
@RequestParam(value = "pageNumber", defaultValue = "1", required = false) Integer pageNumber) {
PageInfoVO<CommentItemVO> pageInfoVO = commentService.findAllComments(pageNumber);
return pageInfoVO;
}

@ApiOperation("根据id删除对应评论")
@DeleteMapping("/{id}")
public ResultVO delById(@PathVariable Long id) {
commentService.deleteById(id);
return ResultVO.ok("操作成功!");
}
}
package com.qianyucc.blog.controller.comm;



/**
* @description 获取blog的信息
*/
@Slf4j
@RestController("commBlogController")
@RequestMapping("/comm/blog")
public class BlogController {
@Autowired
private BlogService blogService;
@Autowired
private Configs configs;

@ApiOperation("获取博客信息")
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.qianyucc.blog.controller.admin;



/**
* @description 管理博客文章
*/
@RestController("adminArticleController")
@RequestMapping("admin/articles")
@Slf4j
public class ArticleController {
@Autowired
private ArticleService articleService;

@ApiOperation("插入文章")
@PostMapping("/")
public ResultVO insArticle(@RequestBody @Validated ArticleDTO articleDTO) {
articleService.insArticle(articleDTO);
return ResultVO.ok("插入文章成功!");
}

@ApiOperation("修改文章")
@PutMapping("/")
public ResultVO updArticle(@RequestBody @Validated ArticleDTO articleDTO) {
articleService.updArticle(articleDTO);
return ResultVO.ok("更新文章成功!");
}

@ApiOperation("根据对应文章id删除文章")
@DeleteMapping("/{id}")
public ResultVO delArticleById(@PathVariable String id) {
articleService.delete(id);
return ResultVO.ok("ID为" + id + "的文章删除成功!");
}

@ApiOperation("分页获取文章列表")
@GetMapping("/")
public PageInfoVO<SimpleArticleVO> getPageArticles(@RequestParam(value = "pageNumber", defaultValue = "1") Integer pageNumber) {
PageInfoVO<SimpleArticleVO> pageInfoVO = articleService.findByCondition(pageNumber, ADMIN_PAGE_SIZE, null, null);
return pageInfoVO;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
    public ResponseEntity<ResultVO> exception(Exception exception) {
exception.printStackTrace();
log.error("message:{}", exception.getMessage());
//未知异常
ResultVO resultVO = ResultVO.error(exception.getMessage());
return new ResponseEntity<>(resultVO, HttpStatus.INTERNAL_SERVER_ERROR);
}

/**
* 结合BeanValid,格式化异常信息
*
* @param ex
* @return
*/
private String getMessage(MethodArgumentNotValidException ex) {
BindingResult bindingResult = ex.getBindingResult();
StringBuilder sb = new StringBuilder();
for (FieldError error : bindingResult.getFieldErrors()) {
String field = error.getField();
Object value = error.getRejectedValue();
String msg = error.getDefaultMessage();
String message = String.format("错误字段:%s,错误值:%s,原因:%s;", field, value, msg);
sb.append(message);
}
return sb.toString();
}
}
package com.qianyucc.blog.controller.admin;



/**
* @e-mail 1413979079@qq.com
* @description
*/
@Slf4j
@RestController("adminBlogController")


项目链接:
https://javayms.github.io?id=431222052008200vl
https://javayms.pages.dev?id=431222052008200vl