文末获取源码
开发语言:Java
框架:springboot
JDK版本:JDK1.8
服务器:tomcat7
数据库:mysql 5.7/8.0
数据库工具:Navicat11
开发软件:eclipse/myeclipse/idea
Maven包:Maven3.3.9
浏览器:谷歌浏览器
系统采用了Java技术springboot框架,前端使用 element-ui 组件库,选择MySQL作为系统的数据库,开发工具选择 idea来进行系统的设计。基本实现了在线小说阅读平台应有的主要功能模块,本系统有以下功能:
(1)前台:首页、小说信息、交流论坛、公告资讯、个人中心、后台管理。
(2)管理员:首页、个人中心、会员管理、小说分类管理、小说信息管理、小说评分管理、交流论坛、系统管理。
(3)会员:首页、个人中心。
# Tomcat
server:
tomcat:
uri-encoding: UTF-8
port: 8080
servlet:
context-path: /springbootm3h7l
spring:
datasource:
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/springbootm3h7l?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8
username: root
password:
# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=springbootm3h7l
# username: sa
# password: 123456
servlet:
multipart:
max-file-size: 300MB
max-request-size: 300MB
resources:
static-locations: classpath:static/,file:static/
#mybatis
mybatis-plus:
mapper-locations: classpath*:mapper/*.xml
#实体扫描,多个package用逗号或者分号分隔
typeAliasesPackage: com.entity
global-config:
#主键类型 0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
id-type: 1
#字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
field-strategy: 1
#驼峰下划线转换
db-column-underline: true
#刷新mapper 调试神器
refresh-mapper: true
#逻辑删除配置
logic-delete-value: -1
logic-not-delete-value: 0
#自定义SQL注入器
sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
call-setters-on-nulls: true
#springboot 项目mybatis plus 设置 jdbcTypeForNull (oracle数据库需配置JdbcType.NULL, 默认是Other)
jdbc-type-for-null: 'null'
/**
* 小说信息
* 后端接口
* @author
* @email
* @date 2022-05-08 15:02:29
*/
@RestController
@RequestMapping("/xiaoshuoxinxi")
public class XiaoshuoxinxiController {
@Autowired
private XiaoshuoxinxiService xiaoshuoxinxiService;
@Autowired
private StoreupService storeupService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map params,XiaoshuoxinxiEntity xiaoshuoxinxi,
HttpServletRequest request){
EntityWrapper ew = new EntityWrapper();
PageUtils page = xiaoshuoxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, xiaoshuoxinxi), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map params,XiaoshuoxinxiEntity xiaoshuoxinxi,
HttpServletRequest request){
EntityWrapper ew = new EntityWrapper();
PageUtils page = xiaoshuoxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, xiaoshuoxinxi), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( XiaoshuoxinxiEntity xiaoshuoxinxi){
EntityWrapper ew = new EntityWrapper();
ew.allEq(MPUtil.allEQMapPre( xiaoshuoxinxi, "xiaoshuoxinxi"));
return R.ok().put("data", xiaoshuoxinxiService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(XiaoshuoxinxiEntity xiaoshuoxinxi){
EntityWrapper< XiaoshuoxinxiEntity> ew = new EntityWrapper< XiaoshuoxinxiEntity>();
ew.allEq(MPUtil.allEQMapPre( xiaoshuoxinxi, "xiaoshuoxinxi"));
XiaoshuoxinxiView xiaoshuoxinxiView = xiaoshuoxinxiService.selectView(ew);
return R.ok("查询小说信息成功").put("data", xiaoshuoxinxiView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
XiaoshuoxinxiEntity xiaoshuoxinxi = xiaoshuoxinxiService.selectById(id);
xiaoshuoxinxi.setClicknum(xiaoshuoxinxi.getClicknum()+1);
xiaoshuoxinxi.setClicktime(new Date());
xiaoshuoxinxiService.updateById(xiaoshuoxinxi);
return R.ok().put("data", xiaoshuoxinxi);
}
/**
* 前端详情
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
XiaoshuoxinxiEntity xiaoshuoxinxi = xiaoshuoxinxiService.selectById(id);
xiaoshuoxinxi.setClicknum(xiaoshuoxinxi.getClicknum()+1);
xiaoshuoxinxi.setClicktime(new Date());
xiaoshuoxinxiService.updateById(xiaoshuoxinxi);
return R.ok().put("data", xiaoshuoxinxi);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody XiaoshuoxinxiEntity xiaoshuoxinxi, HttpServletRequest request){
xiaoshuoxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(xiaoshuoxinxi);
xiaoshuoxinxiService.insert(xiaoshuoxinxi);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody XiaoshuoxinxiEntity xiaoshuoxinxi, HttpServletRequest request){
xiaoshuoxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(xiaoshuoxinxi);
xiaoshuoxinxiService.insert(xiaoshuoxinxi);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody XiaoshuoxinxiEntity xiaoshuoxinxi, HttpServletRequest request){
//ValidatorUtils.validateEntity(xiaoshuoxinxi);
xiaoshuoxinxiService.updateById(xiaoshuoxinxi);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
xiaoshuoxinxiService.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 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 wrapper = new EntityWrapper();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
int count = xiaoshuoxinxiService.selectCount(wrapper);
return R.ok().put("count", count);
}
/**
* 前端智能排序
*/
@IgnoreAuth
@RequestMapping("/autoSort")
public R autoSort(@RequestParam Map params,XiaoshuoxinxiEntity xiaoshuoxinxi, HttpServletRequest request,String pre){
EntityWrapper ew = new EntityWrapper();
Map newMap = new HashMap();
Map param = new HashMap();
Iterator> it = param.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = it.next();
String key = entry.getKey();
String newKey = entry.getKey();
if (pre.endsWith(".")) {
newMap.put(pre + newKey, entry.getValue());
} else if (StringUtils.isEmpty(pre)) {
newMap.put(newKey, entry.getValue());
} else {
newMap.put(pre + "." + newKey, entry.getValue());
}
}
params.put("sort", "clicknum");
params.put("order", "desc");
PageUtils page = xiaoshuoxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, xiaoshuoxinxi), params), params));
return R.ok().put("data", page);
}
}