From aa2929a3cdc1ddb109085be8493f729b2c963e75 Mon Sep 17 00:00:00 2001 From: xiongxiaoyang <1179705413@qq.com> Date: Tue, 18 Apr 2023 10:58:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=90=8E=E5=8F=B0=E5=B0=8F=E8=AF=B4?= =?UTF-8?q?=E6=8E=A8=E8=8D=90=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/sql/20230418.sql | 44 ++++ doc/sql/novel_plus.sql | 48 ++++- .../controller/BookSettingController.java | 134 ++++++++++++ .../com/java2nb/novel/dao/BookSettingDao.java | 32 +++ .../java2nb/novel/domain/BookSettingDO.java | 175 ++++++++++++++++ .../novel/service/BookSettingService.java | 30 +++ .../service/impl/BookSettingServiceImpl.java | 68 +++++++ .../mybatis/novel/BookSettingMapper.xml | 131 ++++++++++++ .../static/js/appjs/novel/book/book.js | 8 +- .../static/js/appjs/novel/bookSetting/add.js | 119 +++++++++++ .../js/appjs/novel/bookSetting/bookSetting.js | 191 ++++++++++++++++++ .../static/js/appjs/novel/bookSetting/edit.js | 121 +++++++++++ .../static/js/appjs/novel/pay/pay.js | 3 - .../static/js/appjs/novel/user/user.js | 3 - .../static/sql/novel/bookSetting/menu.js | 18 ++ .../templates/novel/bookSetting/add.html | 58 ++++++ .../novel/bookSetting/bookSetting.html | 58 ++++++ .../templates/novel/bookSetting/detail.html | 90 +++++++++ .../templates/novel/bookSetting/edit.html | 60 ++++++ 19 files changed, 1381 insertions(+), 10 deletions(-) create mode 100644 doc/sql/20230418.sql create mode 100644 novel-admin/src/main/java/com/java2nb/novel/controller/BookSettingController.java create mode 100644 novel-admin/src/main/java/com/java2nb/novel/dao/BookSettingDao.java create mode 100644 novel-admin/src/main/java/com/java2nb/novel/domain/BookSettingDO.java create mode 100644 novel-admin/src/main/java/com/java2nb/novel/service/BookSettingService.java create mode 100644 novel-admin/src/main/java/com/java2nb/novel/service/impl/BookSettingServiceImpl.java create mode 100644 novel-admin/src/main/resources/mybatis/novel/BookSettingMapper.xml create mode 100644 novel-admin/src/main/resources/static/js/appjs/novel/bookSetting/add.js create mode 100644 novel-admin/src/main/resources/static/js/appjs/novel/bookSetting/bookSetting.js create mode 100644 novel-admin/src/main/resources/static/js/appjs/novel/bookSetting/edit.js create mode 100644 novel-admin/src/main/resources/static/sql/novel/bookSetting/menu.js create mode 100644 novel-admin/src/main/resources/templates/novel/bookSetting/add.html create mode 100644 novel-admin/src/main/resources/templates/novel/bookSetting/bookSetting.html create mode 100644 novel-admin/src/main/resources/templates/novel/bookSetting/detail.html create mode 100644 novel-admin/src/main/resources/templates/novel/bookSetting/edit.html diff --git a/doc/sql/20230418.sql b/doc/sql/20230418.sql new file mode 100644 index 0000000..7b3457c --- /dev/null +++ b/doc/sql/20230418.sql @@ -0,0 +1,44 @@ +INSERT INTO sys_dict (name, value, type, description, sort, parent_id, create_by, create_date, update_by, + update_date, remarks, del_flag) +VALUES ('轮播图', '0', 'book_rec_type', '小说推荐类型', 0, null, null, null, null, null, '', null); +INSERT INTO sys_dict (name, value, type, description, sort, parent_id, create_by, create_date, update_by, + update_date, remarks, del_flag) +VALUES ('顶部小说栏', '1', 'book_rec_type', '小说推荐类型', 1, null, null, null, null, null, '', null); +INSERT INTO sys_dict (name, value, type, description, sort, parent_id, create_by, create_date, update_by, + update_date, remarks, del_flag) +VALUES ('本周强推', '2', 'book_rec_type', '小说推荐类型', 2, null, null, null, null, null, '', null); +INSERT INTO sys_dict (name, value, type, description, sort, parent_id, create_by, create_date, update_by, + update_date, remarks, del_flag) +VALUES ('热门推荐', '3', 'book_rec_type', '小说推荐类型', 3, null, null, null, null, null, '', null); +INSERT INTO sys_dict (name, value, type, description, sort, parent_id, create_by, create_date, update_by, + update_date, remarks, del_flag) +VALUES ('精品推荐', '4', 'book_rec_type', '小说推荐类型', 4, null, null, null, null, null, '', null); + + + +INSERT INTO `sys_menu` (`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) +VALUES (320, '300', '小说推荐', 'novel/bookSetting', 'novel:bookSetting:bookSetting', '1', 'fa', '6'); + +INSERT INTO `sys_menu` (`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) +VALUES (321, '320', '查看', null, 'novel:bookSetting:detail', '2', null, '6'); +INSERT INTO `sys_menu` (`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) +VALUES (322, '320', '新增', null, 'novel:bookSetting:add', '2', null, '6'); +INSERT INTO `sys_menu` (`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) +VALUES (323, '320', '修改', null, 'novel:bookSetting:edit', '2', null, '6'); +INSERT INTO `sys_menu` (`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) +VALUES (324, '320', '删除', null, 'novel:bookSetting:remove', '2', null, '6'); +INSERT INTO `sys_menu` (`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) +VALUES (325, '320', '批量删除', null, 'novel:bookSetting:batchRemove', '2', null, '6'); + +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 320); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 321); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 322); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 323); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 324); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 325); \ No newline at end of file diff --git a/doc/sql/novel_plus.sql b/doc/sql/novel_plus.sql index 70ced45..dd89f47 100644 --- a/doc/sql/novel_plus.sql +++ b/doc/sql/novel_plus.sql @@ -2947,4 +2947,50 @@ VALUES (1, 603); INSERT INTO `sys_menu` (menu_id, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES (604, 603, '删除', null, 'novel:bookComment:remove', '2', null, '6'); INSERT INTO sys_role_menu (role_id, menu_id) -VALUES (1, 604); \ No newline at end of file +VALUES (1, 604); + + +INSERT INTO sys_dict (name, value, type, description, sort, parent_id, create_by, create_date, update_by, + update_date, remarks, del_flag) +VALUES ('轮播图', '0', 'book_rec_type', '小说推荐类型', 0, null, null, null, null, null, '', null); +INSERT INTO sys_dict (name, value, type, description, sort, parent_id, create_by, create_date, update_by, + update_date, remarks, del_flag) +VALUES ('顶部小说栏', '1', 'book_rec_type', '小说推荐类型', 1, null, null, null, null, null, '', null); +INSERT INTO sys_dict (name, value, type, description, sort, parent_id, create_by, create_date, update_by, + update_date, remarks, del_flag) +VALUES ('本周强推', '2', 'book_rec_type', '小说推荐类型', 2, null, null, null, null, null, '', null); +INSERT INTO sys_dict (name, value, type, description, sort, parent_id, create_by, create_date, update_by, + update_date, remarks, del_flag) +VALUES ('热门推荐', '3', 'book_rec_type', '小说推荐类型', 3, null, null, null, null, null, '', null); +INSERT INTO sys_dict (name, value, type, description, sort, parent_id, create_by, create_date, update_by, + update_date, remarks, del_flag) +VALUES ('精品推荐', '4', 'book_rec_type', '小说推荐类型', 4, null, null, null, null, null, '', null); + + + +INSERT INTO `sys_menu` (`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) +VALUES (320, '300', '小说推荐', 'novel/bookSetting', 'novel:bookSetting:bookSetting', '1', 'fa', '6'); + +INSERT INTO `sys_menu` (`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) +VALUES (321, '320', '查看', null, 'novel:bookSetting:detail', '2', null, '6'); +INSERT INTO `sys_menu` (`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) +VALUES (322, '320', '新增', null, 'novel:bookSetting:add', '2', null, '6'); +INSERT INTO `sys_menu` (`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) +VALUES (323, '320', '修改', null, 'novel:bookSetting:edit', '2', null, '6'); +INSERT INTO `sys_menu` (`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) +VALUES (324, '320', '删除', null, 'novel:bookSetting:remove', '2', null, '6'); +INSERT INTO `sys_menu` (`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) +VALUES (325, '320', '批量删除', null, 'novel:bookSetting:batchRemove', '2', null, '6'); + +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 320); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 321); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 322); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 323); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 324); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 325); \ No newline at end of file diff --git a/novel-admin/src/main/java/com/java2nb/novel/controller/BookSettingController.java b/novel-admin/src/main/java/com/java2nb/novel/controller/BookSettingController.java new file mode 100644 index 0000000..762cb20 --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/novel/controller/BookSettingController.java @@ -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 params) { + //查询列表数据 + Query query = new Query(params); + List 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(); + } + +} diff --git a/novel-admin/src/main/java/com/java2nb/novel/dao/BookSettingDao.java b/novel-admin/src/main/java/com/java2nb/novel/dao/BookSettingDao.java new file mode 100644 index 0000000..532a349 --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/novel/dao/BookSettingDao.java @@ -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 list(Map map); + + int count(Map map); + + int save(BookSettingDO bookSetting); + + int update(BookSettingDO bookSetting); + + int remove(Long id); + + int batchRemove(Long[] ids); +} diff --git a/novel-admin/src/main/java/com/java2nb/novel/domain/BookSettingDO.java b/novel-admin/src/main/java/com/java2nb/novel/domain/BookSettingDO.java new file mode 100644 index 0000000..6125150 --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/novel/domain/BookSettingDO.java @@ -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; + } +} diff --git a/novel-admin/src/main/java/com/java2nb/novel/service/BookSettingService.java b/novel-admin/src/main/java/com/java2nb/novel/service/BookSettingService.java new file mode 100644 index 0000000..99fef87 --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/novel/service/BookSettingService.java @@ -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 list(Map map); + + int count(Map map); + + int save(BookSettingDO bookSetting); + + int update(BookSettingDO bookSetting); + + int remove(Long id); + + int batchRemove(Long[] ids); +} diff --git a/novel-admin/src/main/java/com/java2nb/novel/service/impl/BookSettingServiceImpl.java b/novel-admin/src/main/java/com/java2nb/novel/service/impl/BookSettingServiceImpl.java new file mode 100644 index 0000000..2b53256 --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/novel/service/impl/BookSettingServiceImpl.java @@ -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 list(Map map) { + List list = bookSettingDao.list(map); + if (!CollectionUtils.isEmpty(list)) { + List bookIds = list.stream().map(BookSettingDO::getBookId).collect(Collectors.toList()); + Map 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 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); + } + +} diff --git a/novel-admin/src/main/resources/mybatis/novel/BookSettingMapper.xml b/novel-admin/src/main/resources/mybatis/novel/BookSettingMapper.xml new file mode 100644 index 0000000..75fcd33 --- /dev/null +++ b/novel-admin/src/main/resources/mybatis/novel/BookSettingMapper.xml @@ -0,0 +1,131 @@ + + + + + + + + + + + + + insert into book_setting + (`id`, + `book_id`, + `sort`, + `type`, + `create_time`, + `create_user_id`, + `update_time`, + `update_user_id`) + values (#{id}, + #{bookId}, + #{sort}, + #{type}, + #{createTime}, + #{createUserId}, + #{updateTime}, + #{updateUserId}) + + + + insert into book_setting + ( + `id`, + `book_id`, + `sort`, + `type`, + `create_time`, + `create_user_id`, + `update_time`, + `update_user_id` + ) + values + ( + #{id}, + #{bookId}, + #{sort}, + #{type}, + #{createTime}, + #{createUserId}, + #{updateTime}, + #{updateUserId} + ) + + + + update book_setting + + `book_id` = #{bookId}, + `sort` = #{sort}, + `type` = #{type}, + `create_time` = #{createTime}, + `create_user_id` = #{createUserId}, + `update_time` = #{updateTime}, + `update_user_id` = #{updateUserId} + + where id = #{id} + + + + delete + from book_setting + where id = #{value} + + + + delete from book_setting where id in + + #{id} + + + + \ No newline at end of file diff --git a/novel-admin/src/main/resources/static/js/appjs/novel/book/book.js b/novel-admin/src/main/resources/static/js/appjs/novel/book/book.js index 96d01b2..d605080 100644 --- a/novel-admin/src/main/resources/static/js/appjs/novel/book/book.js +++ b/novel-admin/src/main/resources/static/js/appjs/novel/book/book.js @@ -50,9 +50,6 @@ function load() { } }, columns: [ - { - checkbox: true - }, { title: '序号', formatter: function () { @@ -60,6 +57,11 @@ function load() { } }, + { + field: 'id', + title: '小说ID' + }, + { field: 'workDirection', title: '作品方向', diff --git a/novel-admin/src/main/resources/static/js/appjs/novel/bookSetting/add.js b/novel-admin/src/main/resources/static/js/appjs/novel/bookSetting/add.js new file mode 100644 index 0000000..b3c5e1a --- /dev/null +++ b/novel-admin/src/main/resources/static/js/appjs/novel/bookSetting/add.js @@ -0,0 +1,119 @@ +var E = window.wangEditor; +$("[id^='contentEditor']").each(function (index, ele) { + var relName = $(ele).attr("id").substring(13); + var editor = new E('#contentEditor' + relName); +// 自定义菜单配置 + editor.customConfig.menus = [ + 'head', // 标题 + 'bold', // 粗体 + 'fontSize', // 字号 + 'fontName', // 字体 + 'italic', // 斜体 + 'underline', // 下划线 + 'strikeThrough', // 删除线 + 'foreColor', // 文字颜色 + //'backColor', // 背景颜色 + //'link', // 插入链接 + 'list', // 列表 + 'justify', // 对齐方式 + 'quote', // 引用 + 'emoticon', // 表情 + 'image', // 插入图片 + //'table', // 表格 + //'video', // 插入视频 + //'code', // 插入代码 + 'undo', // 撤销 + 'redo' // 重复 + ]; + editor.customConfig.onchange = function (html) { + // html 即变化之后的内容 + $("#" + relName).val(html); + } + editor.customConfig.uploadImgShowBase64 = true; + editor.create(); + +}) + +$("[id^='picImage']").each(function (index, ele) { + var relName = $(ele).attr("id").substring(8); + layui.use('upload', function () { + var upload = layui.upload; + //执行实例 + var uploadInst = upload.render({ + elem: '#picImage' + relName, //绑定元素 + url: '/common/sysFile/upload', //上传接口 + size: 1000, + accept: 'file', + done: function (r) { + $("#picImage" + relName).attr("src", r.fileName); + $("#" + relName).val(r.fileName); + }, + error: function (r) { + layer.msg(r.msg); + } + }); + }); + +}); + + + + + + +$().ready(function () { + validateRule(); +}); + +$.validator.setDefaults({ + submitHandler: function () { + save(); + } +}); +function save() { + $.ajax({ + cache: true, + type: "POST", + url: "/novel/bookSetting/save", + data: $('#signupForm').serialize(),// 你的formid + async: false, + error: function (request) { + parent.layer.alert("Connection error"); + }, + success: function (data) { + if (data.code == 0) { + parent.layer.msg("操作成功"); + parent.reLoad(); + var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引 + parent.layer.close(index); + + } else { + parent.layer.alert(data.msg) + } + + } + }); + +} +function validateRule() { + var icon = " "; + $("#signupForm").validate({ + ignore: "", + rules: { + bookId: { + required: true + }, sort: { + required: true + }, type: { + required: true + }, }, + messages: { + bookId: { + required: icon + "请选择小说ID" + }, sort: { + required: icon + "请选择排序号" + }, type: { + required: icon + "请选择推荐类型" + }, } +}) +} \ No newline at end of file diff --git a/novel-admin/src/main/resources/static/js/appjs/novel/bookSetting/bookSetting.js b/novel-admin/src/main/resources/static/js/appjs/novel/bookSetting/bookSetting.js new file mode 100644 index 0000000..5968e25 --- /dev/null +++ b/novel-admin/src/main/resources/static/js/appjs/novel/bookSetting/bookSetting.js @@ -0,0 +1,191 @@ +var prefix = "/novel/bookSetting" +$(function () { + load(); +}); + +function load() { + $('#exampleTable') + .bootstrapTable( + { + method: 'get', // 服务器数据的请求方式 get or post + url: prefix + "/list", // 服务器数据的加载地址 + // showRefresh : true, + // showToggle : true, + // showColumns : true, + iconSize: 'outline', + toolbar: '#exampleToolbar', + striped: true, // 设置为true会有隔行变色效果 + dataType: "json", // 服务器返回的数据类型 + pagination: true, // 设置为true会在底部显示分页条 + // queryParamsType : "limit", + // //设置为limit则会发送符合RESTFull格式的参数 + singleSelect: false, // 设置为true将禁止多选 + // contentType : "application/x-www-form-urlencoded", + // //发送到服务器的数据编码类型 + pageSize: 10, // 如果设置了分页,每页数据条数 + pageNumber: 1, // 如果设置了分布,首页页码 + //search : true, // 是否显示搜索框 + showColumns: false, // 是否显示内容下拉框(选择显示的列) + sidePagination: "server", // 设置在哪里进行分页,可选值为"client" 或者 "server" + queryParams: function (params) { + //说明:传入后台的参数包括offset开始索引,limit步长,sort排序列,order:desc或者,以及所有列的键值对 + var queryParams = getFormJson("searchForm"); + queryParams.limit = params.limit; + queryParams.offset = params.offset; + return queryParams; + }, + // //请求服务器数据时,你可以通过重写参数的方式添加一些额外的参数,例如 toolbar 中的参数 如果 + // queryParamsType = 'limit' ,返回参数必须包含 + // limit, offset, search, sort, order 否则, 需要包含: + // pageSize, pageNumber, searchText, sortName, + // sortOrder. + // 返回false将会终止请求 + responseHandler: function (rs) { + + if (rs.code == 0) { + return rs.data; + } else { + parent.layer.alert(rs.msg) + return {total: 0, rows: []}; + } + }, + columns: [ + { + title: '序号', + formatter: function () { + return arguments[2] + 1; + } + }, + { + field: 'bookId', + title: '小说ID' + }, + { + field: 'bookName', + title: '小说名' + }, + { + field: 'type', + title: '推荐类型', + formatter: function (value, row, index) { + return formatDict("book_rec_type", value); + } + }, + { + field: 'sort', + title: '排序号' + }, + + { + title: '操作', + field: 'id', + align: 'center', + formatter: function (value, row, index) { + var d = ' '; + var e = ' '; + return d + e; + } + }] + }); +} + +function reLoad() { + $('#exampleTable').bootstrapTable('refresh'); +} + +function add() { + layer.open({ + type: 2, + title: '增加', + maxmin: true, + shadeClose: false, // 点击遮罩关闭层 + area: ['800px', '520px'], + content: prefix + '/add' // iframe的url + }); +} + +function detail(id) { + layer.open({ + type: 2, + title: '详情', + maxmin: true, + shadeClose: false, // 点击遮罩关闭层 + area: ['800px', '520px'], + content: prefix + '/detail/' + id // iframe的url + }); +} + +function edit(id) { + layer.open({ + type: 2, + title: '编辑', + maxmin: true, + shadeClose: false, // 点击遮罩关闭层 + area: ['800px', '520px'], + content: prefix + '/edit/' + id // iframe的url + }); +} + +function remove(id) { + layer.confirm('确定要删除选中的记录?', { + btn: ['确定', '取消'] + }, function () { + $.ajax({ + url: prefix + "/remove", + type: "post", + data: { + 'id': id + }, + success: function (r) { + if (r.code == 0) { + layer.msg(r.msg); + reLoad(); + } else { + layer.msg(r.msg); + } + } + }); + }) +} + +function resetPwd(id) { +} + +function batchRemove() { + var rows = $('#exampleTable').bootstrapTable('getSelections'); // 返回所有选择的行,当没有选择的记录时,返回一个空数组 + if (rows.length == 0) { + layer.msg("请选择要删除的数据"); + return; + } + layer.confirm("确认要删除选中的'" + rows.length + "'条数据吗?", { + btn: ['确定', '取消'] + // 按钮 + }, function () { + var ids = new Array(); + // 遍历所有选择的行数据,取每条数据对应的ID + $.each(rows, function (i, row) { + ids[i] = row['id']; + }); + $.ajax({ + type: 'POST', + data: { + "ids": ids + }, + url: prefix + '/batchRemove', + success: function (r) { + if (r.code == 0) { + layer.msg(r.msg); + reLoad(); + } else { + layer.msg(r.msg); + } + } + }); + }, function () { + + }); +} \ No newline at end of file diff --git a/novel-admin/src/main/resources/static/js/appjs/novel/bookSetting/edit.js b/novel-admin/src/main/resources/static/js/appjs/novel/bookSetting/edit.js new file mode 100644 index 0000000..c049ef4 --- /dev/null +++ b/novel-admin/src/main/resources/static/js/appjs/novel/bookSetting/edit.js @@ -0,0 +1,121 @@ +var E = window.wangEditor; +$("[id^='contentEditor']").each(function (index, ele) { + var relName = $(ele).attr("id").substring(13); + var editor = new E('#contentEditor' + relName); +// 自定义菜单配置 + editor.customConfig.menus = [ + 'head', // 标题 + 'bold', // 粗体 + 'fontSize', // 字号 + 'fontName', // 字体 + 'italic', // 斜体 + 'underline', // 下划线 + 'strikeThrough', // 删除线 + 'foreColor', // 文字颜色 + //'backColor', // 背景颜色 + //'link', // 插入链接 + 'list', // 列表 + 'justify', // 对齐方式 + 'quote', // 引用 + 'emoticon', // 表情 + 'image', // 插入图片 + //'table', // 表格 + //'video', // 插入视频 + //'code', // 插入代码 + 'undo', // 撤销 + 'redo' // 重复 + ]; + editor.customConfig.onchange = function (html) { + // html 即变化之后的内容 + $("#" + relName).val(html); + } + editor.customConfig.uploadImgShowBase64 = true; + editor.create(); + editor.txt.html($("#" + relName).val()); + +}) + +$("[id^='picImage']").each(function (index, ele) { + var relName = $(ele).attr("id").substring(8); + layui.use('upload', function () { + var upload = layui.upload; + //执行实例 + var uploadInst = upload.render({ + elem: '#picImage' + relName, //绑定元素 + url: '/common/sysFile/upload', //上传接口 + size: 1000, + accept: 'file', + done: function (r) { + $("#picImage" + relName).attr("src", r.fileName); + $("#" + relName).val(r.fileName); + }, + error: function (r) { + layer.msg(r.msg); + } + }); + }); + +}); + +$().ready(function () { + validateRule(); +}); + +$.validator.setDefaults({ + submitHandler: function () { + update(); + } +}); +function update() { + $.ajax({ + cache: true, + type: "POST", + url: "/novel/bookSetting/update", + data: $('#signupForm').serialize(),// 你的formid + async: false, + error: function (request) { + parent.layer.alert("Connection error"); + }, + success: function (data) { + if (data.code == 0) { + parent.layer.msg("操作成功"); + parent.reLoad(); + var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引 + parent.layer.close(index); + + } else { + parent.layer.alert(data.msg) + } + + } + }); + +} +function validateRule() { + var icon = " "; + $("#signupForm").validate({ + ignore: "", + rules: { + bookId: + { + required: true + }, sort: + { + required: true + }, type: + { + required: true + }, }, + messages: { + bookId: + { + required: icon + "请选择小说ID" + }, sort: + { + required: icon + "请选择排序号" + }, type: + { + required: icon + "请选择推荐类型" + }, } +}) +} \ No newline at end of file diff --git a/novel-admin/src/main/resources/static/js/appjs/novel/pay/pay.js b/novel-admin/src/main/resources/static/js/appjs/novel/pay/pay.js index 0777934..eb70610 100644 --- a/novel-admin/src/main/resources/static/js/appjs/novel/pay/pay.js +++ b/novel-admin/src/main/resources/static/js/appjs/novel/pay/pay.js @@ -50,9 +50,6 @@ function load() { } }, columns: [ - { - checkbox: true - }, { title: '序号', formatter: function () { diff --git a/novel-admin/src/main/resources/static/js/appjs/novel/user/user.js b/novel-admin/src/main/resources/static/js/appjs/novel/user/user.js index afdfa7a..f62e3ac 100644 --- a/novel-admin/src/main/resources/static/js/appjs/novel/user/user.js +++ b/novel-admin/src/main/resources/static/js/appjs/novel/user/user.js @@ -50,9 +50,6 @@ function load() { } }, columns: [ - { - checkbox: true - }, { title: '序号', formatter: function () { diff --git a/novel-admin/src/main/resources/static/sql/novel/bookSetting/menu.js b/novel-admin/src/main/resources/static/sql/novel/bookSetting/menu.js new file mode 100644 index 0000000..82f5610 --- /dev/null +++ b/novel-admin/src/main/resources/static/sql/novel/bookSetting/menu.js @@ -0,0 +1,18 @@ +-- 菜单SQL +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + VALUES ('1', '首页小说设置表', 'novel/bookSetting', 'novel:bookSetting:bookSetting', '1', 'fa', '6'); + +-- 按钮父菜单ID +set @parentId = @@identity; + +-- 菜单对应按钮SQL +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + SELECT @parentId, '查看', null, 'novel:bookSetting:detail', '2', null, '6'; +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + SELECT @parentId, '新增', null, 'novel:bookSetting:add', '2', null, '6'; +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + SELECT @parentId, '修改', null, 'novel:bookSetting:edit', '2', null, '6'; +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + SELECT @parentId, '删除', null, 'novel:bookSetting:remove', '2', null, '6'; +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + SELECT @parentId, '批量删除', null, 'novel:bookSetting:batchRemove', '2', null, '6'; diff --git a/novel-admin/src/main/resources/templates/novel/bookSetting/add.html b/novel-admin/src/main/resources/templates/novel/bookSetting/add.html new file mode 100644 index 0000000..91dd093 --- /dev/null +++ b/novel-admin/src/main/resources/templates/novel/bookSetting/add.html @@ -0,0 +1,58 @@ + + + + + +
+
+
+
+
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + + +
+
+
+
+ +
+
+
+
+
+
+
+
+
+ + + + diff --git a/novel-admin/src/main/resources/templates/novel/bookSetting/bookSetting.html b/novel-admin/src/main/resources/templates/novel/bookSetting/bookSetting.html new file mode 100644 index 0000000..bc6ea87 --- /dev/null +++ b/novel-admin/src/main/resources/templates/novel/bookSetting/bookSetting.html @@ -0,0 +1,58 @@ + + + + + +
+
+
+
+
+
+ +
+ +
+
+ +
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+ + + \ No newline at end of file diff --git a/novel-admin/src/main/resources/templates/novel/bookSetting/detail.html b/novel-admin/src/main/resources/templates/novel/bookSetting/detail.html new file mode 100644 index 0000000..bc1f281 --- /dev/null +++ b/novel-admin/src/main/resources/templates/novel/bookSetting/detail.html @@ -0,0 +1,90 @@ + + + + + +
+
+
+
+
+
+ +
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + +
+
+
+
+
+
+
+
+ + diff --git a/novel-admin/src/main/resources/templates/novel/bookSetting/edit.html b/novel-admin/src/main/resources/templates/novel/bookSetting/edit.html new file mode 100644 index 0000000..eaece7b --- /dev/null +++ b/novel-admin/src/main/resources/templates/novel/bookSetting/edit.html @@ -0,0 +1,60 @@ + + + + + +
+
+
+
+
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + +
+
+
+
+ +
+
+
+
+
+
+
+
+
+ + + +