mirror of
https://github.com/201206030/novel-plus.git
synced 2025-07-05 00:36:39 +00:00
feat: 后台小说推荐管理
This commit is contained in:
@ -0,0 +1,134 @@
|
||||
package com.java2nb.novel.controller;
|
||||
|
||||
import com.java2nb.common.config.CacheKey;
|
||||
import com.java2nb.common.utils.PageBean;
|
||||
import com.java2nb.common.utils.Query;
|
||||
import com.java2nb.common.utils.R;
|
||||
import com.java2nb.novel.domain.BookSettingDO;
|
||||
import com.java2nb.novel.service.BookSettingService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 首页小说推荐
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2023-04-18 10:01:13
|
||||
*/
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/novel/bookSetting")
|
||||
public class BookSettingController {
|
||||
|
||||
@Autowired
|
||||
private BookSettingService bookSettingService;
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
@GetMapping()
|
||||
@RequiresPermissions("novel:bookSetting:bookSetting")
|
||||
String BookSetting() {
|
||||
return "novel/bookSetting/bookSetting";
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取首页小说设置表列表", notes = "获取首页小说设置表列表")
|
||||
@ResponseBody
|
||||
@GetMapping("/list")
|
||||
@RequiresPermissions("novel:bookSetting:bookSetting")
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
//查询列表数据
|
||||
Query query = new Query(params);
|
||||
List<BookSettingDO> bookSettingList = bookSettingService.list(query);
|
||||
int total = bookSettingService.count(query);
|
||||
PageBean pageBean = new PageBean(bookSettingList, total);
|
||||
return R.ok().put("data", pageBean);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增首页小说设置表页面", notes = "新增首页小说设置表页面")
|
||||
@GetMapping("/add")
|
||||
@RequiresPermissions("novel:bookSetting:add")
|
||||
String add() {
|
||||
return "novel/bookSetting/add";
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改首页小说设置表页面", notes = "修改首页小说设置表页面")
|
||||
@GetMapping("/edit/{id}")
|
||||
@RequiresPermissions("novel:bookSetting:edit")
|
||||
String edit(@PathVariable("id") Long id, Model model) {
|
||||
BookSettingDO bookSetting = bookSettingService.get(id);
|
||||
model.addAttribute("bookSetting", bookSetting);
|
||||
return "novel/bookSetting/edit";
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查看首页小说设置表页面", notes = "查看首页小说设置表页面")
|
||||
@GetMapping("/detail/{id}")
|
||||
@RequiresPermissions("novel:bookSetting:detail")
|
||||
String detail(@PathVariable("id") Long id, Model model) {
|
||||
BookSettingDO bookSetting = bookSettingService.get(id);
|
||||
model.addAttribute("bookSetting", bookSetting);
|
||||
return "novel/bookSetting/detail";
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@ApiOperation(value = "新增首页小说设置表", notes = "新增首页小说设置表")
|
||||
@ResponseBody
|
||||
@PostMapping("/save")
|
||||
@RequiresPermissions("novel:bookSetting:add")
|
||||
public R save(BookSettingDO bookSetting) {
|
||||
if (bookSettingService.save(bookSetting) > 0) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@ApiOperation(value = "修改首页小说设置表", notes = "修改首页小说设置表")
|
||||
@ResponseBody
|
||||
@RequestMapping("/update")
|
||||
@RequiresPermissions("novel:bookSetting:edit")
|
||||
public R update(BookSettingDO bookSetting) {
|
||||
bookSettingService.update(bookSetting);
|
||||
redisTemplate.delete(CacheKey.INDEX_BOOK_SETTINGS_KEY);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@ApiOperation(value = "删除首页小说设置表", notes = "删除首页小说设置表")
|
||||
@PostMapping("/remove")
|
||||
@ResponseBody
|
||||
@RequiresPermissions("novel:bookSetting:remove")
|
||||
public R remove(Long id) {
|
||||
if (bookSettingService.remove(id) > 0) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@ApiOperation(value = "批量删除首页小说设置表", notes = "批量删除首页小说设置表")
|
||||
@PostMapping("/batchRemove")
|
||||
@ResponseBody
|
||||
@RequiresPermissions("novel:bookSetting:batchRemove")
|
||||
public R remove(@RequestParam("ids[]") Long[] ids) {
|
||||
bookSettingService.batchRemove(ids);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.java2nb.novel.dao;
|
||||
|
||||
import com.java2nb.novel.domain.BookSettingDO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 首页小说设置表
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2023-04-18 10:01:13
|
||||
*/
|
||||
@Mapper
|
||||
public interface BookSettingDao {
|
||||
|
||||
BookSettingDO get(Long id);
|
||||
|
||||
List<BookSettingDO> list(Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
int save(BookSettingDO bookSetting);
|
||||
|
||||
int update(BookSettingDO bookSetting);
|
||||
|
||||
int remove(Long id);
|
||||
|
||||
int batchRemove(Long[] ids);
|
||||
}
|
@ -0,0 +1,175 @@
|
||||
package com.java2nb.novel.domain;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.java2nb.common.jsonserializer.LongToStringSerializer;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 首页小说设置表
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2023-04-18 10:01:13
|
||||
*/
|
||||
public class BookSettingDO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
//
|
||||
//java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值)
|
||||
//所以通过序列化成字符串来解决
|
||||
@JsonSerialize(using = LongToStringSerializer.class)
|
||||
private Long id;
|
||||
//小说ID
|
||||
//java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值)
|
||||
//所以通过序列化成字符串来解决
|
||||
@JsonSerialize(using = LongToStringSerializer.class)
|
||||
private Long bookId;
|
||||
//排序号
|
||||
private Integer sort;
|
||||
//类型,0:轮播图,1:顶部小说栏设置,2:本周强推,3:热门推荐,4:精品推荐
|
||||
private Integer type;
|
||||
//创建时间
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
//创建人ID
|
||||
//java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值)
|
||||
//所以通过序列化成字符串来解决
|
||||
@JsonSerialize(using = LongToStringSerializer.class)
|
||||
private Long createUserId;
|
||||
//更新时间
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
//更新人ID
|
||||
//java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值)
|
||||
//所以通过序列化成字符串来解决
|
||||
@JsonSerialize(using = LongToStringSerializer.class)
|
||||
private Long updateUserId;
|
||||
|
||||
private String bookName;
|
||||
|
||||
public String getBookName() {
|
||||
return bookName;
|
||||
}
|
||||
|
||||
public void setBookName(String bookName) {
|
||||
this.bookName = bookName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置:
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取:
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置:小说ID
|
||||
*/
|
||||
public void setBookId(Long bookId) {
|
||||
this.bookId = bookId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取:小说ID
|
||||
*/
|
||||
public Long getBookId() {
|
||||
return bookId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置:排序号
|
||||
*/
|
||||
public void setSort(Integer sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取:排序号
|
||||
*/
|
||||
public Integer getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置:类型,0:轮播图,1:顶部小说栏设置,2:本周强推,3:热门推荐,4:精品推荐
|
||||
*/
|
||||
public void setType(Integer type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取:类型,0:轮播图,1:顶部小说栏设置,2:本周强推,3:热门推荐,4:精品推荐
|
||||
*/
|
||||
public Integer getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置:创建时间
|
||||
*/
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取:创建时间
|
||||
*/
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置:创建人ID
|
||||
*/
|
||||
public void setCreateUserId(Long createUserId) {
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取:创建人ID
|
||||
*/
|
||||
public Long getCreateUserId() {
|
||||
return createUserId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置:更新时间
|
||||
*/
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取:更新时间
|
||||
*/
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置:更新人ID
|
||||
*/
|
||||
public void setUpdateUserId(Long updateUserId) {
|
||||
this.updateUserId = updateUserId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取:更新人ID
|
||||
*/
|
||||
public Long getUpdateUserId() {
|
||||
return updateUserId;
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.java2nb.novel.service;
|
||||
|
||||
import com.java2nb.novel.domain.BookSettingDO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 首页小说设置表
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2023-04-18 10:01:13
|
||||
*/
|
||||
public interface BookSettingService {
|
||||
|
||||
BookSettingDO get(Long id);
|
||||
|
||||
List<BookSettingDO> list(Map<String, Object> map);
|
||||
|
||||
int count(Map<String, Object> map);
|
||||
|
||||
int save(BookSettingDO bookSetting);
|
||||
|
||||
int update(BookSettingDO bookSetting);
|
||||
|
||||
int remove(Long id);
|
||||
|
||||
int batchRemove(Long[] ids);
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package com.java2nb.novel.service.impl;
|
||||
|
||||
import com.java2nb.novel.dao.BookDao;
|
||||
import com.java2nb.novel.dao.BookSettingDao;
|
||||
import com.java2nb.novel.domain.BookDO;
|
||||
import com.java2nb.novel.domain.BookSettingDO;
|
||||
import com.java2nb.novel.service.BookSettingService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Service
|
||||
public class BookSettingServiceImpl implements BookSettingService {
|
||||
|
||||
@Autowired
|
||||
private BookSettingDao bookSettingDao;
|
||||
@Autowired
|
||||
private BookDao bookDao;
|
||||
|
||||
@Override
|
||||
public BookSettingDO get(Long id) {
|
||||
return bookSettingDao.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BookSettingDO> list(Map<String, Object> map) {
|
||||
List<BookSettingDO> list = bookSettingDao.list(map);
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
List<Long> bookIds = list.stream().map(BookSettingDO::getBookId).collect(Collectors.toList());
|
||||
Map<Long, String> bookNameMap = bookDao.batchGet(bookIds).stream()
|
||||
.collect(Collectors.toMap(BookDO::getId, BookDO::getBookName));
|
||||
list = list.stream().filter(v -> bookNameMap.containsKey(v.getBookId())).collect(Collectors.toList());
|
||||
list.forEach(v -> v.setBookName(bookNameMap.get(v.getBookId())));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(Map<String, Object> map) {
|
||||
return bookSettingDao.count(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int save(BookSettingDO bookSetting) {
|
||||
return bookSettingDao.save(bookSetting);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(BookSettingDO bookSetting) {
|
||||
return bookSettingDao.update(bookSetting);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int remove(Long id) {
|
||||
return bookSettingDao.remove(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchRemove(Long[] ids) {
|
||||
return bookSettingDao.batchRemove(ids);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user