——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7、Node.js≥14
开发工具
后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可
❗没学过node.js的不要搞前后端分离项目
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明




基于javaweb的SpringBoot在线小说阅读系统(前后端分离+java+vue+springboot+ssm+mysql+maven)
一、项目简述
本系统功能包括: 普通用户端登录注册,小说的分类,日榜,月榜,年榜, 小说的阅读,分章节,小说的评论,收藏,推荐等等,以 及后台小说的维护,上架,编辑等等。
二、项目运行
环境配置: Jdk1.8 + Mysql + HBuilderX (Webstorm也 行)+ Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts都支 持)。
项目技术: Springboot + Maven + Mybatis + Vue , B/S 模式+ Maven等等
——————————CodeStart——————————
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
|
@RestController @RequestMapping("/api/follow") @Api(tags = "共同前缀:/api/follow", description = "FollowController") @Slf4j public class FollowController { @Autowired UserService userService; @Autowired FollowService followService;
@PostMapping @ApiOperation("新增Follow") @PreAuthorize("isAuthenticated()") public ResponseObject post(@RequestBody Follow follow) { log.info("新增Follow"); System.out.println(follow); if (follow.getId() != null) { throw new ControllerException("id必须为null"); } else if (follow.getFollower_id() != null) { throw new ControllerException("follower_id必须为null"); } else if (follow.getFollowing_id() == null) { throw new ControllerException("following_id不可为null"); } else { follow.setFollower_id(userService .selectByUsername((String) SecurityContextHolder.getContext().getAuthentication().getPrincipal()) .getId()); if (follow.getFollower_id() == follow.getFollowing_id()) { throw new ControllerException("不可自己关注自己"); } else if (followService.selectByFollower_idFollowing_id(follow.getFollower_id(), follow.getFollowing_id()) != null) {
|
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
| public ResponseObject patchById(@PathVariable Integer id,@RequestBody Volume volume) { log.info("修改Volume"); if (id == null) { throw new ControllerException("id不可为null"); } else { Volume volume2 = volumeService.selectById(id); if (volume2 == null) { throw new ControllerException("不存在为该id的volume"); } else if (volume.getName() != null && !volume.getName().equals("")) { volume2.setName(volume.getName()); if (volumeService.selectByNovel_idName(volume2.getNovel_id(), volume2.getName()) != null) { throw new ControllerException("name不可重复"); } } else if (volume.getSummary() != null && !volume.getSummary().equals("")) { volume2.setSummary(volume.getSummary()); } else { throw new ControllerException("请传入需要修改的数据,如name,summary"); } User user = userService .selectByUsername((String) SecurityContextHolder.getContext().getAuthentication().getPrincipal()); if (user.getId() == novelService.selectById(volume2.getNovel_id()).getUser_id() || user.getRole().equals("ADMIN")) { return new ResponseObject("200", "操作成功", volumeService.update(volume2)); } else { throw new ControllerException("该用户无权限修改该volume"); } } }
} package com.homework.web.controller;
|
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 47 48
| } else if (novel.getCategory_id() == null) { throw new ControllerException("category_id不可为null"); } else if (novel.getName() == null || novel.getName().equals("")) { throw new ControllerException("name不可为null,也不可为空字符串"); } else if (novel.getSummary() == null || novel.getSummary().equals("")) { throw new ControllerException("summary不可为null,也不可为空字符串"); } else if (novel.getImage() == null || novel.getImage().equals("")) { throw new ControllerException("image不可为null,也不可为空字符串"); } else if (novel.getIs_complete() == null) { throw new ControllerException("is_complete不可为null"); } else { novel.setMultiplier(10000); novel.setAddend(0); return new ResponseObject("200", "操作成功", novelService.insert(novel)); } }
@GetMapping @ApiOperation("查询Novel") public ResponseObject get(Integer category_id, Integer user_id, String searchName) { log.info("查询Novel"); if (category_id != null) { return new ResponseObject("200", "操作成功", novelService.selectByCategory_id(category_id)); } else if (user_id != null) { return new ResponseObject("200", "操作成功", novelService.selectByUser_id(user_id)); } else if (searchName != null && !searchName.equals("")) { return new ResponseObject("200", "操作成功", novelService.selectByLikeName(searchName)); } else { throw new ControllerException("category_id或user_id或searchName不可为null"); } }
@GetMapping("/{id:[0-9]+}") @ApiOperation("查询Novel") public ResponseObject getById(@PathVariable Integer id) { log.info("查询Novel"); if (id != null) { return new ResponseObject("200", "操作成功", novelService.selectById(id)); } else { throw new ControllerException("id不可为null"); } }
@PatchMapping("/{id:[0-9]+}") @ApiOperation("修改Novel") @PreAuthorize("isAuthenticated()") public ResponseObject patchById(@PathVariable Integer id, @RequestBody Novel novel) { log.info("修改Novel");
|
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
| } else { throw new ControllerException("follower_id与following_id不可同时为null"); } }
@DeleteMapping @ApiOperation("删除Follow") @PreAuthorize("isAuthenticated()") public ResponseObject delete(Integer following_id) { log.info("删除Follow"); if (following_id == null) { throw new ControllerException("following_id不可为null"); } else { Integer follower_id = userService .selectByUsername((String) SecurityContextHolder.getContext().getAuthentication().getPrincipal()) .getId(); Follow follow = followService.selectByFollower_idFollowing_id(follower_id, following_id); if (follow == null) { throw new ControllerException("该用户未关注,无法取消关注"); } else { followService.deleteById(follow.getId()); return new ResponseObject("200", "操作成功", null); } } } } package com.homework.web.controller;
|
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 47 48 49 50 51 52 53 54
| .getId()); if (recommendService.selectByUser_idNovel_id(recommend.getUser_id(), recommend.getNovel_id()) != null) { throw new ControllerException("该用户已经推荐过该小说了,不可重复推荐"); } else { return new ResponseObject("200", "操作成功", recommendService.insert(recommend)); } } }
@GetMapping @ApiOperation("查询Recommend") public ResponseObject get(Integer novel_id, Integer user_id) { log.info("查询Recommend"); if (novel_id == null) { throw new ControllerException("novel_id不可为null"); } else if (user_id == null) { throw new ControllerException("user_id不可为null"); } else { return new ResponseObject("200", "操作成功", recommendService.selectByUser_idNovel_id(user_id, novel_id)); } }
@DeleteMapping @ApiOperation("删除Recommend") @PreAuthorize("isAuthenticated()") public ResponseObject delete(Integer novel_id, Integer user_id) { log.info("删除Recommend"); if (novel_id == null) { throw new ControllerException("novel_id不可为null"); } else if (user_id == null) { throw new ControllerException("user_id不可为null"); } else { Recommend recommend = recommendService.selectByUser_idNovel_id(user_id, novel_id); if (recommend == null) { throw new ControllerException("该用户还未推荐该小说,无法取消推荐"); } else { User user = userService.selectByUsername( (String) SecurityContextHolder.getContext().getAuthentication().getPrincipal()); if (user.getId() == recommend.getUser_id() || user.getRole().equals("ADMIN")) { recommendService.deleteById(recommend.getId()); return new ResponseObject("200", "操作成功", null); } else { throw new ControllerException("该用户无权限取消推荐"); } } } }
@GetMapping("/count") @ApiOperation("查询Recommend") public ResponseObject getCount(Integer novel_id) { log.info("查询Recommend"); if (novel_id == null) { throw new ControllerException("novel_id不可为null");
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=571222052008200vy
https://javayms.pages.dev?id=571222052008200vy