开发工具:IDEA
服务器:Tomcat9.0, jdk1.8
项目构建:maven
数据库:mysql5.7
系统分前后台,项目采用前后端分离
前端技术:vue+elementUI
服务端技术:springboot+mybatis-plus
本项目分为管理员与普通用户两种角色
一、用户功能:
1.登录、注册、退出登录
2.首页、搜索、阅读小说,添加书签、添加收藏、取消收藏
3.我的书架:新建文件夹、下载全部、我要上传、搜素小说
4.我的上传:查看、编辑、删除、下载、发布小说
5.我的书签:查询、编辑、删除
6.阅读历史:查询、删除
7.个人信息:修改个人信息
8.个人动态:显示所有个人发布的动态信息
9.安全管理:修改邮箱和修改密码
二、管理员功能:
1.用户管理:查询、删除、详情、禁用
2.动态管理:查询、删除
3.小说管理:上传小说、查看详情、下载小说、编辑、删除
4.小说审核:通过、驳回、禁用
5.书签管理:查询、按进度查看,编辑、删除
6.收藏管理:查询、删除
7.管理员设置:修改密码,添加管理员
8.公告管理:发布公告、编辑、查询、删除
文档截图:
N-133基于springboot,vue小说网站
用户截图:
管理员截图:
package com.wpy.controller;
import com.wpy.annotation.SysLogs;
import com.wpy.dto.DownloadDto;
import com.wpy.dto.NovelDto;
import com.wpy.dto.NovelUploadDto;
import com.wpy.entity.Novel;
import com.wpy.entity.SysUser;
import com.wpy.enums.CodeMsgEnums;
import com.wpy.exception.RequestException;
import com.wpy.service.NovelService;
import com.wpy.utils.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.List;
/**
* <p>
* 小说数据表 前端控制器
* </p>
*/
@RestController
@RequestMapping("/novel")
@Slf4j
public class NovelController {
@Autowired
private NovelService novelService;
@PostMapping("/upload")
@SysLogs("小说上传")
public ResponseResult uploadNovel(HttpServletRequest request,NovelUploadDto novelUploadDto){
try{
if(novelUploadDto.getNovelFiles().length==0){
throw RequestException.fail("文件不能为空");
}
SysUser sysUser = ShiroUtils.getSysUser(request);
novelService.uploadNovel(sysUser,novelUploadDto);
return ResponseResult.success();
}catch (Exception e){
log.error(e.getMessage(),e);
return ResponseResult.error();
}
}
@PostMapping("/updateNovel")
@SysLogs("小说修改")
public ResponseResult updateNovel(HttpServletRequest request,NovelUploadDto novelUploadDto){
if(StringUtils.isEmpty(novelUploadDto.getId())){
throw RequestException.fail(CodeMsgEnums.ID_IS_EMPTY.getMsg());
}
try{
SysUser sysUser = ShiroUtils.getSysUser(request);
novelService.updateNovel(sysUser,novelUploadDto);
return ResponseResult.success();
}catch (Exception e){
log.error(e.getMessage(),e);
return ResponseResult.error();
}
}
@GetMapping("/list")
@SysLogs("小说列表")
public ResponseResult getNovelList(HttpServletRequest request,NovelDto novelDto){
SysUser sysUser = RequestUtils.getSysUser(request);
return ResponseResult.success(novelService.getNovelList(sysUser,novelDto));
}
@GetMapping("/novelInfo")
@SysLogs("获取小说信息")
public ResponseResult getNovelInfo(HttpServletRequest request,@RequestParam("id")String id,@RequestParam("isClick")Boolean isClick){
if(StringUtils.isEmpty(id)){
throw RequestException.fail(CodeMsgEnums.ID_IS_EMPTY.getMsg());
}
SysUser sysUser = RequestUtils.getSysUser(request);
return ResponseResult.success(novelService.getNovelInfo(sysUser,id,isClick));
}
@DeleteMapping("/deleteNovel")
@SysLogs("删除小说")
public ResponseResult deleteNovel(@RequestParam("ids")List<String> ids){
if(CollectionUtils.isEmpty(ids)){
throw RequestException.fail(CodeMsgEnums.ID_IS_EMPTY.getMsg());
}
novelService.deleteNovel(ids);
return ResponseResult.success();
}
@GetMapping("/download")
@SysLogs("下载小说")
public void downloadNovel(HttpServletRequest request, HttpServletResponse response, @RequestParam("params") String params){
try {
SysUser sysUser = ShiroUtils.getSysUser(request);
String param = URLDecoder.decode(params, "UTF-8");
DownloadDto downloadDto = JsonUtils.jsonStrToObject(param, DownloadDto.class);
this.novelService.downloadNovel(request,response,downloadDto,sysUser);
} catch (UnsupportedEncodingException e) {
throw RequestException.fail("参数错误");
}
}
@PostMapping("/public")
@SysLogs("发布小说")
public ResponseResult publicNovel(HttpServletRequest request,@RequestBody NovelDto novelDto){
if(StringUtils.isEmpty(novelDto.getId())&&CollectionUtils.isEmpty(novelDto.getIds())){
throw RequestException.fail(CodeMsgEnums.ID_IS_EMPTY.getMsg());
}
SysUser sysUser = ShiroUtils.getSysUser(request);
this.novelService.publicNovel(sysUser,novelDto);
return ResponseResult.success();
}
@PostMapping("/cancelPublic")
@SysLogs("取消发布")
public ResponseResult cancelPublic(HttpServletRequest request,@RequestBody NovelDto novelDto){
if(StringUtils.isEmpty(novelDto.getId())&&CollectionUtils.isEmpty(novelDto.getIds())){
throw RequestException.fail(CodeMsgEnums.ID_IS_EMPTY.getMsg());
}
SysUser sysUser = ShiroUtils.getSysUser(request);
this.novelService.cancelPublic(sysUser,novelDto);
return ResponseResult.success();
}
@PostMapping("/audit")
@SysLogs("审核小说")
public ResponseResult auditNovel(HttpServletRequest request,@RequestBody NovelDto novelDto){
if(StringUtils.isEmpty(novelDto.getId())&&CollectionUtils.isEmpty(novelDto.getIds())){
throw RequestException.fail(CodeMsgEnums.ID_IS_EMPTY.getMsg());
}
SysUser sysUser = ShiroUtils.getSysUser(request);
this.novelService.auditNovel(sysUser,novelDto);
return ResponseResult.success();
}
}