*文末获取源码
开发环境
项目编号:Java+spring ssm285小说阅读网站#毕业设计
开发语言:Java
开发工具:IDEA /Eclipse
数据库:MYSQL5.7
应用服务:Tomcat7/Tomcat8
使用框架:ssm+vue
项目介绍
网络的发展带动了小说这一行业的快速发展,各大网站都能看到小说阅读的身影,读者的增加进一步抑制了市场消费的提升,随着市场竞争的日益激烈,虽然许多作者主动选用信用销售模式,但却缺乏对其充分的重视与质量的良性控制,一些作者没有建立独立的信用实践管理,无法在交易前期准确获取读者资信情况而是轻易的履行授信,令其始终无法得到良性提升。
小说阅读网站,主要的模块包括查看;管理员;首页、个人中心、读者管理、作者管理、小说信息管理、小说分类管理、余额充值管理、购买小说管理、下载小说管理、系统管理,读者;个人中心、余额充值管理、购买小说管理、下载小说管理、我的收藏管理等,作者:个人中心、小说信息管理、小说分类管理、余额充值管理、购买小说管理、下载小说管理、我的收藏管理。首页:小说信息、我的、跳转到后台功能。系统中管理员主要是为了安全有效地存储和管理各类信息,还可以对系统进行管理与更新维护等操作,并且对前后台有相应的操作权限。
系统截图
关键代码
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.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.XiaoshuoxinxiEntity;
import com.entity.view.XiaoshuoxinxiView;
import com.service.XiaoshuoxinxiService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;
/**
* 小说信息
* 后端接口
* @author
* @email
* @date 2021-03-07 10:13:33
*/
@RestController
@RequestMapping("/xiaoshuoxinxi")
public class XiaoshuoxinxiController {
@Autowired
private XiaoshuoxinxiService xiaoshuoxinxiService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,XiaoshuoxinxiEntity xiaoshuoxinxi, HttpServletRequest request){
EntityWrapper<XiaoshuoxinxiEntity> ew = new EntityWrapper<XiaoshuoxinxiEntity>();
PageUtils page = xiaoshuoxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, xiaoshuoxinxi), params), params));
request.setAttribute("data", page);
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,XiaoshuoxinxiEntity xiaoshuoxinxi, HttpServletRequest request){
EntityWrapper<XiaoshuoxinxiEntity> ew = new EntityWrapper<XiaoshuoxinxiEntity>();
PageUtils page = xiaoshuoxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, xiaoshuoxinxi), params), params));
request.setAttribute("data", page);
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( XiaoshuoxinxiEntity xiaoshuoxinxi){
EntityWrapper<XiaoshuoxinxiEntity> ew = new EntityWrapper<XiaoshuoxinxiEntity>();
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("/thumbsup/{id}")
public R vote(@PathVariable("id") String id,String type){
XiaoshuoxinxiEntity xiaoshuoxinxi = xiaoshuoxinxiService.selectById(id);
if(type.equals("1")) {
xiaoshuoxinxi.setThumbsupnum(xiaoshuoxinxi.getThumbsupnum()+1);
} else {
xiaoshuoxinxi.setCrazilynum(xiaoshuoxinxi.getCrazilynum()+1);
}
xiaoshuoxinxiService.updateById(xiaoshuoxinxi);
return R.ok("投票成功");
}
/**
* 后端保存
*/
@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")
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<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<XiaoshuoxinxiEntity> wrapper = new EntityWrapper<XiaoshuoxinxiEntity>();
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<String, Object> params,XiaoshuoxinxiEntity xiaoshuoxinxi, HttpServletRequest request,String pre){
EntityWrapper<XiaoshuoxinxiEntity> ew = new EntityWrapper<XiaoshuoxinxiEntity>();
Map<String, Object> newMap = new HashMap<String, Object>();
Map<String, Object> param = new HashMap<String, Object>();
Iterator<Map.Entry<String, Object>> it = param.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, Object> 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);
}
}