From 7f4d315f25f55321b6b8f83cac4b1daac983cc20 Mon Sep 17 00:00:00 2001 From: xiongxiaoyang <773861846@qq.com> Date: Tue, 1 Dec 2020 12:14:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E6=96=B0=E9=97=BB=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E5=BC=80=E5=8F=91=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../XssAndSqlHttpServletRequestWrapper.java | 2 +- .../novel/controller/CategoryController.java | 135 ++++++++++++ .../novel/controller/NewsController.java | 135 ++++++++++++ .../com/java2nb/novel/dao/CategoryDao.java | 32 +++ .../java/com/java2nb/novel/dao/NewsDao.java | 32 +++ .../com/java2nb/novel/domain/CategoryDO.java | 135 ++++++++++++ .../java/com/java2nb/novel/domain/NewsDO.java | 180 +++++++++++++++ .../novel/service/CategoryService.java | 30 +++ .../java2nb/novel/service/NewsService.java | 30 +++ .../service/impl/CategoryServiceImpl.java | 58 +++++ .../novel/service/impl/NewsServiceImpl.java | 58 +++++ .../mybatis/novel/CategoryMapper.xml | 117 ++++++++++ .../resources/mybatis/novel/NewsMapper.xml | 138 ++++++++++++ .../static/js/appjs/novel/category/add.js | 111 ++++++++++ .../js/appjs/novel/category/category.js | 193 ++++++++++++++++ .../static/js/appjs/novel/category/edit.js | 109 +++++++++ .../static/js/appjs/novel/news/add.js | 123 +++++++++++ .../static/js/appjs/novel/news/edit.js | 127 +++++++++++ .../static/js/appjs/novel/news/news.js | 206 ++++++++++++++++++ .../static/sql/novel/category/menu.js | 18 ++ .../resources/static/sql/novel/news/menu.js | 18 ++ .../templates/novel/category/add.html | 46 ++++ .../templates/novel/category/category.html | 57 +++++ .../templates/novel/category/detail.html | 80 +++++++ .../templates/novel/category/edit.html | 48 ++++ .../resources/templates/novel/news/add.html | 105 +++++++++ .../templates/novel/news/detail.html | 108 +++++++++ .../resources/templates/novel/news/edit.html | 109 +++++++++ .../resources/templates/novel/news/news.html | 66 ++++++ sql/20201201.sql | 32 +++ sql/novel_plus.sql | 37 +++- 31 files changed, 2673 insertions(+), 2 deletions(-) create mode 100644 novel-admin/src/main/java/com/java2nb/novel/controller/CategoryController.java create mode 100644 novel-admin/src/main/java/com/java2nb/novel/controller/NewsController.java create mode 100644 novel-admin/src/main/java/com/java2nb/novel/dao/CategoryDao.java create mode 100644 novel-admin/src/main/java/com/java2nb/novel/dao/NewsDao.java create mode 100644 novel-admin/src/main/java/com/java2nb/novel/domain/CategoryDO.java create mode 100644 novel-admin/src/main/java/com/java2nb/novel/domain/NewsDO.java create mode 100644 novel-admin/src/main/java/com/java2nb/novel/service/CategoryService.java create mode 100644 novel-admin/src/main/java/com/java2nb/novel/service/NewsService.java create mode 100644 novel-admin/src/main/java/com/java2nb/novel/service/impl/CategoryServiceImpl.java create mode 100644 novel-admin/src/main/java/com/java2nb/novel/service/impl/NewsServiceImpl.java create mode 100644 novel-admin/src/main/resources/mybatis/novel/CategoryMapper.xml create mode 100644 novel-admin/src/main/resources/mybatis/novel/NewsMapper.xml create mode 100644 novel-admin/src/main/resources/static/js/appjs/novel/category/add.js create mode 100644 novel-admin/src/main/resources/static/js/appjs/novel/category/category.js create mode 100644 novel-admin/src/main/resources/static/js/appjs/novel/category/edit.js create mode 100644 novel-admin/src/main/resources/static/js/appjs/novel/news/add.js create mode 100644 novel-admin/src/main/resources/static/js/appjs/novel/news/edit.js create mode 100644 novel-admin/src/main/resources/static/js/appjs/novel/news/news.js create mode 100644 novel-admin/src/main/resources/static/sql/novel/category/menu.js create mode 100644 novel-admin/src/main/resources/static/sql/novel/news/menu.js create mode 100644 novel-admin/src/main/resources/templates/novel/category/add.html create mode 100644 novel-admin/src/main/resources/templates/novel/category/category.html create mode 100644 novel-admin/src/main/resources/templates/novel/category/detail.html create mode 100644 novel-admin/src/main/resources/templates/novel/category/edit.html create mode 100644 novel-admin/src/main/resources/templates/novel/news/add.html create mode 100644 novel-admin/src/main/resources/templates/novel/news/detail.html create mode 100644 novel-admin/src/main/resources/templates/novel/news/edit.html create mode 100644 novel-admin/src/main/resources/templates/novel/news/news.html create mode 100644 sql/20201201.sql diff --git a/novel-admin/src/main/java/com/java2nb/common/xss/XssAndSqlHttpServletRequestWrapper.java b/novel-admin/src/main/java/com/java2nb/common/xss/XssAndSqlHttpServletRequestWrapper.java index 7044070..2414170 100644 --- a/novel-admin/src/main/java/com/java2nb/common/xss/XssAndSqlHttpServletRequestWrapper.java +++ b/novel-admin/src/main/java/com/java2nb/common/xss/XssAndSqlHttpServletRequestWrapper.java @@ -14,7 +14,7 @@ public class XssAndSqlHttpServletRequestWrapper extends HttpServletRequestWrappe /** * 假如有有html 代码是自己传来的 需要设定对应的name 不过滤 */ - private static final List noFilterNames = Arrays.asList("attach","push_ip"); + private static final List noFilterNames = Arrays.asList("attach","push_ip","content"); public XssAndSqlHttpServletRequestWrapper(HttpServletRequest request) { super(request); diff --git a/novel-admin/src/main/java/com/java2nb/novel/controller/CategoryController.java b/novel-admin/src/main/java/com/java2nb/novel/controller/CategoryController.java new file mode 100644 index 0000000..9b6e4c3 --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/novel/controller/CategoryController.java @@ -0,0 +1,135 @@ +package com.java2nb.novel.controller; + +import java.util.List; +import java.util.Map; + +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import io.swagger.annotations.ApiOperation; + + +import com.java2nb.novel.domain.CategoryDO; +import com.java2nb.novel.service.CategoryService; +import com.java2nb.common.utils.PageBean; +import com.java2nb.common.utils.Query; +import com.java2nb.common.utils.R; + +/** + * 新闻类别表 + * + * @author xiongxy + * @email 1179705413@qq.com + * @date 2020-12-01 10:03:41 + */ + +@Controller +@RequestMapping("/novel/category") +public class CategoryController { + @Autowired + private CategoryService categoryService; + + @GetMapping() + @RequiresPermissions("novel:category:category") + String Category() { + return "novel/category/category"; + } + + @ApiOperation(value = "获取新闻类别表列表", notes = "获取新闻类别表列表") + @ResponseBody + @GetMapping("/list") + @RequiresPermissions("novel:category:category") + public R list(@RequestParam Map params) { + //查询列表数据 + Query query = new Query(params); + List categoryList = categoryService.list(query); + int total = categoryService.count(query); + PageBean pageBean = new PageBean(categoryList, total); + return R.ok().put("data", pageBean); + } + + @ApiOperation(value = "新增新闻类别表页面", notes = "新增新闻类别表页面") + @GetMapping("/add") + @RequiresPermissions("novel:category:add") + String add() { + return "novel/category/add"; + } + + @ApiOperation(value = "修改新闻类别表页面", notes = "修改新闻类别表页面") + @GetMapping("/edit/{id}") + @RequiresPermissions("novel:category:edit") + String edit(@PathVariable("id") Integer id, Model model) { + CategoryDO category = categoryService.get(id); + model.addAttribute("category", category); + return "novel/category/edit"; + } + + @ApiOperation(value = "查看新闻类别表页面", notes = "查看新闻类别表页面") + @GetMapping("/detail/{id}") + @RequiresPermissions("novel:category:detail") + String detail(@PathVariable("id") Integer id, Model model) { + CategoryDO category = categoryService.get(id); + model.addAttribute("category", category); + return "novel/category/detail"; + } + + /** + * 保存 + */ + @ApiOperation(value = "新增新闻类别表", notes = "新增新闻类别表") + @ResponseBody + @PostMapping("/save") + @RequiresPermissions("novel:category:add") + public R save( CategoryDO category) { + if (categoryService.save(category) > 0) { + return R.ok(); + } + return R.error(); + } + + /** + * 修改 + */ + @ApiOperation(value = "修改新闻类别表", notes = "修改新闻类别表") + @ResponseBody + @RequestMapping("/update") + @RequiresPermissions("novel:category:edit") + public R update( CategoryDO category) { + categoryService.update(category); + return R.ok(); + } + + /** + * 删除 + */ + @ApiOperation(value = "删除新闻类别表", notes = "删除新闻类别表") + @PostMapping("/remove") + @ResponseBody + @RequiresPermissions("novel:category:remove") + public R remove( Integer id) { + if (categoryService.remove(id) > 0) { + return R.ok(); + } + return R.error(); + } + + /** + * 删除 + */ + @ApiOperation(value = "批量删除新闻类别表", notes = "批量删除新闻类别表") + @PostMapping("/batchRemove") + @ResponseBody + @RequiresPermissions("novel:category:batchRemove") + public R remove(@RequestParam("ids[]") Integer[] ids) { + categoryService.batchRemove(ids); + return R.ok(); + } + +} diff --git a/novel-admin/src/main/java/com/java2nb/novel/controller/NewsController.java b/novel-admin/src/main/java/com/java2nb/novel/controller/NewsController.java new file mode 100644 index 0000000..4fab9fc --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/novel/controller/NewsController.java @@ -0,0 +1,135 @@ +package com.java2nb.novel.controller; + +import java.util.List; +import java.util.Map; + +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import io.swagger.annotations.ApiOperation; + + +import com.java2nb.novel.domain.NewsDO; +import com.java2nb.novel.service.NewsService; +import com.java2nb.common.utils.PageBean; +import com.java2nb.common.utils.Query; +import com.java2nb.common.utils.R; + +/** + * 新闻表 + * + * @author xiongxy + * @email 1179705413@qq.com + * @date 2020-12-01 10:05:51 + */ + +@Controller +@RequestMapping("/novel/news") +public class NewsController { + @Autowired + private NewsService newsService; + + @GetMapping() + @RequiresPermissions("novel:news:news") + String News() { + return "novel/news/news"; + } + + @ApiOperation(value = "获取新闻表列表", notes = "获取新闻表列表") + @ResponseBody + @GetMapping("/list") + @RequiresPermissions("novel:news:news") + public R list(@RequestParam Map params) { + //查询列表数据 + Query query = new Query(params); + List newsList = newsService.list(query); + int total = newsService.count(query); + PageBean pageBean = new PageBean(newsList, total); + return R.ok().put("data", pageBean); + } + + @ApiOperation(value = "新增新闻表页面", notes = "新增新闻表页面") + @GetMapping("/add") + @RequiresPermissions("novel:news:add") + String add() { + return "novel/news/add"; + } + + @ApiOperation(value = "修改新闻表页面", notes = "修改新闻表页面") + @GetMapping("/edit/{id}") + @RequiresPermissions("novel:news:edit") + String edit(@PathVariable("id") Long id, Model model) { + NewsDO news = newsService.get(id); + model.addAttribute("news", news); + return "novel/news/edit"; + } + + @ApiOperation(value = "查看新闻表页面", notes = "查看新闻表页面") + @GetMapping("/detail/{id}") + @RequiresPermissions("novel:news:detail") + String detail(@PathVariable("id") Long id, Model model) { + NewsDO news = newsService.get(id); + model.addAttribute("news", news); + return "novel/news/detail"; + } + + /** + * 保存 + */ + @ApiOperation(value = "新增新闻表", notes = "新增新闻表") + @ResponseBody + @PostMapping("/save") + @RequiresPermissions("novel:news:add") + public R save( NewsDO news) { + if (newsService.save(news) > 0) { + return R.ok(); + } + return R.error(); + } + + /** + * 修改 + */ + @ApiOperation(value = "修改新闻表", notes = "修改新闻表") + @ResponseBody + @RequestMapping("/update") + @RequiresPermissions("novel:news:edit") + public R update( NewsDO news) { + newsService.update(news); + return R.ok(); + } + + /** + * 删除 + */ + @ApiOperation(value = "删除新闻表", notes = "删除新闻表") + @PostMapping("/remove") + @ResponseBody + @RequiresPermissions("novel:news:remove") + public R remove( Long id) { + if (newsService.remove(id) > 0) { + return R.ok(); + } + return R.error(); + } + + /** + * 删除 + */ + @ApiOperation(value = "批量删除新闻表", notes = "批量删除新闻表") + @PostMapping("/batchRemove") + @ResponseBody + @RequiresPermissions("novel:news:batchRemove") + public R remove(@RequestParam("ids[]") Long[] ids) { + newsService.batchRemove(ids); + return R.ok(); + } + +} diff --git a/novel-admin/src/main/java/com/java2nb/novel/dao/CategoryDao.java b/novel-admin/src/main/java/com/java2nb/novel/dao/CategoryDao.java new file mode 100644 index 0000000..55139d3 --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/novel/dao/CategoryDao.java @@ -0,0 +1,32 @@ +package com.java2nb.novel.dao; + +import com.java2nb.novel.domain.CategoryDO; + +import java.util.List; +import java.util.Map; + +import org.apache.ibatis.annotations.Mapper; + +/** + * 新闻类别表 + * @author xiongxy + * @email 1179705413@qq.com + * @date 2020-12-01 10:03:41 + */ +@Mapper +public interface CategoryDao { + + CategoryDO get(Integer id); + + List list(Map map); + + int count(Map map); + + int save(CategoryDO category); + + int update(CategoryDO category); + + int remove(Integer id); + + int batchRemove(Integer[] ids); +} diff --git a/novel-admin/src/main/java/com/java2nb/novel/dao/NewsDao.java b/novel-admin/src/main/java/com/java2nb/novel/dao/NewsDao.java new file mode 100644 index 0000000..3366eef --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/novel/dao/NewsDao.java @@ -0,0 +1,32 @@ +package com.java2nb.novel.dao; + +import com.java2nb.novel.domain.NewsDO; + +import java.util.List; +import java.util.Map; + +import org.apache.ibatis.annotations.Mapper; + +/** + * 新闻表 + * @author xiongxy + * @email 1179705413@qq.com + * @date 2020-12-01 10:05:51 + */ +@Mapper +public interface NewsDao { + + NewsDO get(Long id); + + List list(Map map); + + int count(Map map); + + int save(NewsDO news); + + int update(NewsDO news); + + int remove(Long id); + + int batchRemove(Long[] ids); +} diff --git a/novel-admin/src/main/java/com/java2nb/novel/domain/CategoryDO.java b/novel-admin/src/main/java/com/java2nb/novel/domain/CategoryDO.java new file mode 100644 index 0000000..3ff0928 --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/novel/domain/CategoryDO.java @@ -0,0 +1,135 @@ +package com.java2nb.novel.domain; + +import java.io.Serializable; + + +import java.math.BigDecimal; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.java2nb.common.jsonserializer.LongToStringSerializer; + + +import org.springframework.format.annotation.DateTimeFormat; +import java.util.Date; + + + +/** + * 新闻类别表 + * + * @author xiongxy + * @email 1179705413@qq.com + * @date 2020-12-01 10:03:41 + */ +public class CategoryDO implements Serializable { + private static final long serialVersionUID = 1L; + + + //主键 + private Integer id; + //分类名 + private String name; + //排序 + private Integer sort; + // + //java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值) + //所以通过序列化成字符串来解决 + @JsonSerialize(using = LongToStringSerializer.class) + private Long createUserId; + // + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + // + //java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值) + //所以通过序列化成字符串来解决 + @JsonSerialize(using = LongToStringSerializer.class) + private Long updateUserId; + // + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; + + /** + * 设置:主键 + */ + public void setId(Integer id) { + this.id = id; + } + /** + * 获取:主键 + */ + public Integer getId() { + return id; + } + /** + * 设置:分类名 + */ + public void setName(String name) { + this.name = name; + } + /** + * 获取:分类名 + */ + public String getName() { + return name; + } + /** + * 设置:排序 + */ + public void setSort(Integer sort) { + this.sort = sort; + } + /** + * 获取:排序 + */ + public Integer getSort() { + return sort; + } + /** + * 设置: + */ + public void setCreateUserId(Long createUserId) { + this.createUserId = createUserId; + } + /** + * 获取: + */ + public Long getCreateUserId() { + return createUserId; + } + /** + * 设置: + */ + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + /** + * 获取: + */ + public Date getCreateTime() { + return createTime; + } + /** + * 设置: + */ + public void setUpdateUserId(Long updateUserId) { + this.updateUserId = updateUserId; + } + /** + * 获取: + */ + public Long getUpdateUserId() { + return updateUserId; + } + /** + * 设置: + */ + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + /** + * 获取: + */ + public Date getUpdateTime() { + return updateTime; + } +} diff --git a/novel-admin/src/main/java/com/java2nb/novel/domain/NewsDO.java b/novel-admin/src/main/java/com/java2nb/novel/domain/NewsDO.java new file mode 100644 index 0000000..0d2e1a3 --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/novel/domain/NewsDO.java @@ -0,0 +1,180 @@ +package com.java2nb.novel.domain; + +import java.io.Serializable; + + +import java.math.BigDecimal; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.java2nb.common.jsonserializer.LongToStringSerializer; + + +import org.springframework.format.annotation.DateTimeFormat; +import java.util.Date; + + + +/** + * 新闻表 + * + * @author xiongxy + * @email 1179705413@qq.com + * @date 2020-12-01 10:05:51 + */ +public class NewsDO implements Serializable { + private static final long serialVersionUID = 1L; + + + //主键 + //java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值) + //所以通过序列化成字符串来解决 + @JsonSerialize(using = LongToStringSerializer.class) + private Long id; + //类别ID + private Integer catId; + //分类名 + private String catName; + //来源 + private String sourceName; + //标题 + private String title; + //内容 + private String content; + //发布时间 + @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; + + /** + * 设置:主键 + */ + public void setId(Long id) { + this.id = id; + } + /** + * 获取:主键 + */ + public Long getId() { + return id; + } + /** + * 设置:类别ID + */ + public void setCatId(Integer catId) { + this.catId = catId; + } + /** + * 获取:类别ID + */ + public Integer getCatId() { + return catId; + } + /** + * 设置:分类名 + */ + public void setCatName(String catName) { + this.catName = catName; + } + /** + * 获取:分类名 + */ + public String getCatName() { + return catName; + } + /** + * 设置:来源 + */ + public void setSourceName(String sourceName) { + this.sourceName = sourceName; + } + /** + * 获取:来源 + */ + public String getSourceName() { + return sourceName; + } + /** + * 设置:标题 + */ + public void setTitle(String title) { + this.title = title; + } + /** + * 获取:标题 + */ + public String getTitle() { + return title; + } + /** + * 设置:内容 + */ + public void setContent(String content) { + this.content = content; + } + /** + * 获取:内容 + */ + public String getContent() { + return content; + } + /** + * 设置:发布时间 + */ + 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/CategoryService.java b/novel-admin/src/main/java/com/java2nb/novel/service/CategoryService.java new file mode 100644 index 0000000..3806544 --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/novel/service/CategoryService.java @@ -0,0 +1,30 @@ +package com.java2nb.novel.service; + +import com.java2nb.novel.domain.CategoryDO; + +import java.util.List; +import java.util.Map; + +/** + * 新闻类别表 + * + * @author xiongxy + * @email 1179705413@qq.com + * @date 2020-12-01 10:03:41 + */ +public interface CategoryService { + + CategoryDO get(Integer id); + + List list(Map map); + + int count(Map map); + + int save(CategoryDO category); + + int update(CategoryDO category); + + int remove(Integer id); + + int batchRemove(Integer[] ids); +} diff --git a/novel-admin/src/main/java/com/java2nb/novel/service/NewsService.java b/novel-admin/src/main/java/com/java2nb/novel/service/NewsService.java new file mode 100644 index 0000000..7351819 --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/novel/service/NewsService.java @@ -0,0 +1,30 @@ +package com.java2nb.novel.service; + +import com.java2nb.novel.domain.NewsDO; + +import java.util.List; +import java.util.Map; + +/** + * 新闻表 + * + * @author xiongxy + * @email 1179705413@qq.com + * @date 2020-12-01 10:05:51 + */ +public interface NewsService { + + NewsDO get(Long id); + + List list(Map map); + + int count(Map map); + + int save(NewsDO news); + + int update(NewsDO news); + + int remove(Long id); + + int batchRemove(Long[] ids); +} diff --git a/novel-admin/src/main/java/com/java2nb/novel/service/impl/CategoryServiceImpl.java b/novel-admin/src/main/java/com/java2nb/novel/service/impl/CategoryServiceImpl.java new file mode 100644 index 0000000..15030f1 --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/novel/service/impl/CategoryServiceImpl.java @@ -0,0 +1,58 @@ +package com.java2nb.novel.service.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +import com.java2nb.novel.dao.CategoryDao; +import com.java2nb.novel.domain.CategoryDO; +import com.java2nb.novel.service.CategoryService; + + + +@Service +public class CategoryServiceImpl implements CategoryService { + @Autowired + private CategoryDao categoryDao; + + @Override + public CategoryDO get(Integer id){ + return categoryDao.get(id); + } + + @Override + public List list(Map map){ + return categoryDao.list(map); + } + + @Override + public int count(Map map){ + return categoryDao.count(map); + } + + @Override + public int save(CategoryDO category){ + category.setCreateTime(new Date()); + return categoryDao.save(category); + } + + @Override + public int update(CategoryDO category){ + category.setUpdateTime(new Date()); + return categoryDao.update(category); + } + + @Override + public int remove(Integer id){ + return categoryDao.remove(id); + } + + @Override + public int batchRemove(Integer[] ids){ + return categoryDao.batchRemove(ids); + } + +} diff --git a/novel-admin/src/main/java/com/java2nb/novel/service/impl/NewsServiceImpl.java b/novel-admin/src/main/java/com/java2nb/novel/service/impl/NewsServiceImpl.java new file mode 100644 index 0000000..9f42089 --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/novel/service/impl/NewsServiceImpl.java @@ -0,0 +1,58 @@ +package com.java2nb.novel.service.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +import com.java2nb.novel.dao.NewsDao; +import com.java2nb.novel.domain.NewsDO; +import com.java2nb.novel.service.NewsService; + + + +@Service +public class NewsServiceImpl implements NewsService { + @Autowired + private NewsDao newsDao; + + @Override + public NewsDO get(Long id){ + return newsDao.get(id); + } + + @Override + public List list(Map map){ + return newsDao.list(map); + } + + @Override + public int count(Map map){ + return newsDao.count(map); + } + + @Override + public int save(NewsDO news){ + news.setCreateTime(new Date()); + return newsDao.save(news); + } + + @Override + public int update(NewsDO news){ + news.setUpdateTime(new Date()); + return newsDao.update(news); + } + + @Override + public int remove(Long id){ + return newsDao.remove(id); + } + + @Override + public int batchRemove(Long[] ids){ + return newsDao.batchRemove(ids); + } + +} diff --git a/novel-admin/src/main/resources/mybatis/novel/CategoryMapper.xml b/novel-admin/src/main/resources/mybatis/novel/CategoryMapper.xml new file mode 100644 index 0000000..018da4a --- /dev/null +++ b/novel-admin/src/main/resources/mybatis/novel/CategoryMapper.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + insert into news_category + ( + `id`, + `name`, + `sort`, + `create_user_id`, + `create_time`, + `update_user_id`, + `update_time` + ) + values + ( + #{id}, + #{name}, + #{sort}, + #{createUserId}, + #{createTime}, + #{updateUserId}, + #{updateTime} + ) + + + + insert into news_category + ( + `id`, + `name`, + `sort`, + `create_user_id`, + `create_time`, + `update_user_id`, + `update_time` + ) + values + ( + #{id}, + #{name}, + #{sort}, + #{createUserId}, + #{createTime}, + #{updateUserId}, + #{updateTime} + ) + + + + update news_category + + `name` = #{name}, + `sort` = #{sort}, + `create_user_id` = #{createUserId}, + `create_time` = #{createTime}, + `update_user_id` = #{updateUserId}, + `update_time` = #{updateTime} + + where id = #{id} + + + + delete from news_category where id = #{value} + + + + delete from news_category where id in + + #{id} + + + + \ No newline at end of file diff --git a/novel-admin/src/main/resources/mybatis/novel/NewsMapper.xml b/novel-admin/src/main/resources/mybatis/novel/NewsMapper.xml new file mode 100644 index 0000000..434b954 --- /dev/null +++ b/novel-admin/src/main/resources/mybatis/novel/NewsMapper.xml @@ -0,0 +1,138 @@ + + + + + + + + + + + + + insert into news + ( + `id`, + `cat_id`, + `cat_name`, + `source_name`, + `title`, + `content`, + `create_time`, + `create_user_id`, + `update_time`, + `update_user_id` + ) + values + ( + #{id}, + #{catId}, + #{catName}, + #{sourceName}, + #{title}, + #{content}, + #{createTime}, + #{createUserId}, + #{updateTime}, + #{updateUserId} + ) + + + + insert into news + ( + `id`, + `cat_id`, + `cat_name`, + `source_name`, + `title`, + `content`, + `create_time`, + `create_user_id`, + `update_time`, + `update_user_id` + ) + values + ( + #{id}, + #{catId}, + #{catName}, + #{sourceName}, + #{title}, + #{content}, + #{createTime}, + #{createUserId}, + #{updateTime}, + #{updateUserId} + ) + + + + update news + + `cat_id` = #{catId}, + `cat_name` = #{catName}, + `source_name` = #{sourceName}, + `title` = #{title}, + `content` = #{content}, + `create_time` = #{createTime}, + `create_user_id` = #{createUserId}, + `update_time` = #{updateTime}, + `update_user_id` = #{updateUserId} + + where id = #{id} + + + + delete from news where id = #{value} + + + + delete from news where id in + + #{id} + + + + \ No newline at end of file diff --git a/novel-admin/src/main/resources/static/js/appjs/novel/category/add.js b/novel-admin/src/main/resources/static/js/appjs/novel/category/add.js new file mode 100644 index 0000000..ebfde97 --- /dev/null +++ b/novel-admin/src/main/resources/static/js/appjs/novel/category/add.js @@ -0,0 +1,111 @@ +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/category/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: { + name: { + required: true + }, }, + messages: { + name: { + required: icon + "请选择分类名" + }, } +}) +} \ No newline at end of file diff --git a/novel-admin/src/main/resources/static/js/appjs/novel/category/category.js b/novel-admin/src/main/resources/static/js/appjs/novel/category/category.js new file mode 100644 index 0000000..492b5f7 --- /dev/null +++ b/novel-admin/src/main/resources/static/js/appjs/novel/category/category.js @@ -0,0 +1,193 @@ +var prefix = "/novel/category" +$(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: [ + { + checkbox: true + }, + { + title: '序号', + formatter: function () { + return arguments[2] + 1; + } + }, + + + { + field: 'name', + title: '分类名' + }, + + + { + field: 'sort', + title: '排序' + }, + + + + + { + title: '操作', + field: 'id', + align: 'center', + formatter: function (value, row, index) { + var d = ' '; + var e = ' '; + var r = ' '; + return e + r; + } + }] + }); +} + +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/category/edit.js b/novel-admin/src/main/resources/static/js/appjs/novel/category/edit.js new file mode 100644 index 0000000..b8b4d16 --- /dev/null +++ b/novel-admin/src/main/resources/static/js/appjs/novel/category/edit.js @@ -0,0 +1,109 @@ +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/category/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: { + name: + { + required: true + }, }, + messages: { + name: + { + required: icon + "请选择分类名" + }, } +}) +} \ No newline at end of file diff --git a/novel-admin/src/main/resources/static/js/appjs/novel/news/add.js b/novel-admin/src/main/resources/static/js/appjs/novel/news/add.js new file mode 100644 index 0000000..a608c14 --- /dev/null +++ b/novel-admin/src/main/resources/static/js/appjs/novel/news/add.js @@ -0,0 +1,123 @@ +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/news/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: { + catId: { + required: true + }, catName: { + required: true + }, title: { + required: true + }, content: { + required: true + }, }, + messages: { + catId: { + required: icon + "请选择类别ID" + }, catName: { + required: icon + "请选择分类名" + }, title: { + required: icon + "请选择标题" + }, content: { + required: icon + "请选择内容" + }, } +}) +} \ No newline at end of file diff --git a/novel-admin/src/main/resources/static/js/appjs/novel/news/edit.js b/novel-admin/src/main/resources/static/js/appjs/novel/news/edit.js new file mode 100644 index 0000000..67aec10 --- /dev/null +++ b/novel-admin/src/main/resources/static/js/appjs/novel/news/edit.js @@ -0,0 +1,127 @@ +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/news/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: { + catId: + { + required: true + }, catName: + { + required: true + }, title: + { + required: true + }, content: + { + required: true + }, }, + messages: { + catId: + { + required: icon + "请选择类别ID" + }, catName: + { + required: icon + "请选择分类名" + }, title: + { + required: icon + "请选择标题" + }, content: + { + required: icon + "请选择内容" + }, } +}) +} \ No newline at end of file diff --git a/novel-admin/src/main/resources/static/js/appjs/novel/news/news.js b/novel-admin/src/main/resources/static/js/appjs/novel/news/news.js new file mode 100644 index 0000000..c88ecc7 --- /dev/null +++ b/novel-admin/src/main/resources/static/js/appjs/novel/news/news.js @@ -0,0 +1,206 @@ +var prefix = "/novel/news" +$(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: [ + { + checkbox: true + }, + { + title: '序号', + formatter: function () { + return arguments[2] + 1; + } + }, + + { + field: 'catName', + title: '分类名' + }, + + + { + field: 'sourceName', + title: '来源' + }, + + + { + field: 'title', + title: '标题' + }, + + + + + { + field: 'createTime', + title: '发布时间' + }, + + + + + { + title: '操作', + field: 'id', + align: 'center', + formatter: function (value, row, index) { + var d = ' '; + var e = ' '; + var r = ' '; + return e + r; + } + }] + }); +} + +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/sql/novel/category/menu.js b/novel-admin/src/main/resources/static/sql/novel/category/menu.js new file mode 100644 index 0000000..de0b6a7 --- /dev/null +++ b/novel-admin/src/main/resources/static/sql/novel/category/menu.js @@ -0,0 +1,18 @@ +-- 菜单SQL +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + VALUES ('1', '新闻类别表', 'novel/category', 'novel:category:category', '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:category:detail', '2', null, '6'; +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + SELECT @parentId, '新增', null, 'novel:category:add', '2', null, '6'; +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + SELECT @parentId, '修改', null, 'novel:category:edit', '2', null, '6'; +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + SELECT @parentId, '删除', null, 'novel:category:remove', '2', null, '6'; +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + SELECT @parentId, '批量删除', null, 'novel:category:batchRemove', '2', null, '6'; diff --git a/novel-admin/src/main/resources/static/sql/novel/news/menu.js b/novel-admin/src/main/resources/static/sql/novel/news/menu.js new file mode 100644 index 0000000..24acd26 --- /dev/null +++ b/novel-admin/src/main/resources/static/sql/novel/news/menu.js @@ -0,0 +1,18 @@ +-- 菜单SQL +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + VALUES ('1', '新闻表', 'novel/news', 'novel:news:news', '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:news:detail', '2', null, '6'; +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + SELECT @parentId, '新增', null, 'novel:news:add', '2', null, '6'; +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + SELECT @parentId, '修改', null, 'novel:news:edit', '2', null, '6'; +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + SELECT @parentId, '删除', null, 'novel:news:remove', '2', null, '6'; +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + SELECT @parentId, '批量删除', null, 'novel:news:batchRemove', '2', null, '6'; diff --git a/novel-admin/src/main/resources/templates/novel/category/add.html b/novel-admin/src/main/resources/templates/novel/category/add.html new file mode 100644 index 0000000..86a7eae --- /dev/null +++ b/novel-admin/src/main/resources/templates/novel/category/add.html @@ -0,0 +1,46 @@ + + + + + +
+
+
+
+
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+ +
+
+
+
+
+
+
+
+
+ + + + diff --git a/novel-admin/src/main/resources/templates/novel/category/category.html b/novel-admin/src/main/resources/templates/novel/category/category.html new file mode 100644 index 0000000..56c9cb2 --- /dev/null +++ b/novel-admin/src/main/resources/templates/novel/category/category.html @@ -0,0 +1,57 @@ + + + + + +
+
+
+
+
+
+ + +
+ + +
+ +
+
+
+
+
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+ + + \ No newline at end of file diff --git a/novel-admin/src/main/resources/templates/novel/category/detail.html b/novel-admin/src/main/resources/templates/novel/category/detail.html new file mode 100644 index 0000000..910a556 --- /dev/null +++ b/novel-admin/src/main/resources/templates/novel/category/detail.html @@ -0,0 +1,80 @@ + + + + + +
+
+
+
+
+
+ +
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + +
+
+
+
+
+
+
+
+ + diff --git a/novel-admin/src/main/resources/templates/novel/category/edit.html b/novel-admin/src/main/resources/templates/novel/category/edit.html new file mode 100644 index 0000000..9344031 --- /dev/null +++ b/novel-admin/src/main/resources/templates/novel/category/edit.html @@ -0,0 +1,48 @@ + + + + + +
+
+
+
+
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+
+ + + + diff --git a/novel-admin/src/main/resources/templates/novel/news/add.html b/novel-admin/src/main/resources/templates/novel/news/add.html new file mode 100644 index 0000000..3f91c53 --- /dev/null +++ b/novel-admin/src/main/resources/templates/novel/news/add.html @@ -0,0 +1,105 @@ + + + + + +
+
+
+
+
+
+
+ +
+ + + +
+
+
+
+ + + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ +
+ +
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+
+ + + + + diff --git a/novel-admin/src/main/resources/templates/novel/news/detail.html b/novel-admin/src/main/resources/templates/novel/news/detail.html new file mode 100644 index 0000000..a9a4498 --- /dev/null +++ b/novel-admin/src/main/resources/templates/novel/news/detail.html @@ -0,0 +1,108 @@ + + + + + +
+
+
+
+
+
+ +
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + +
+
+
+
+
+
+
+
+ + diff --git a/novel-admin/src/main/resources/templates/novel/news/edit.html b/novel-admin/src/main/resources/templates/novel/news/edit.html new file mode 100644 index 0000000..d51025c --- /dev/null +++ b/novel-admin/src/main/resources/templates/novel/news/edit.html @@ -0,0 +1,109 @@ + + + + + +
+
+
+
+
+
+ +
+ +
+ + +
+
+
+
+ + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+ +
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+ + + + + diff --git a/novel-admin/src/main/resources/templates/novel/news/news.html b/novel-admin/src/main/resources/templates/novel/news/news.html new file mode 100644 index 0000000..4c341e6 --- /dev/null +++ b/novel-admin/src/main/resources/templates/novel/news/news.html @@ -0,0 +1,66 @@ + + + + + +
+
+
+
+
+
+ + +
+
+ +
+ +
+
+ +
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+ + + \ No newline at end of file diff --git a/sql/20201201.sql b/sql/20201201.sql new file mode 100644 index 0000000..140d9a9 --- /dev/null +++ b/sql/20201201.sql @@ -0,0 +1,32 @@ +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (246, 241, '批量删除', NULL, 'novel:news:batchRemove', 2, NULL, 6, NULL, NULL); +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (245, 241, '删除', NULL, 'novel:news:remove', 2, NULL, 6, NULL, NULL); +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (244, 241, '修改', NULL, 'novel:news:edit', 2, NULL, 6, NULL, NULL); +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (243, 241, '新增', NULL, 'novel:news:add', 2, NULL, 6, NULL, NULL); +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (242, 241, '查看', NULL, 'novel:news:detail', 2, NULL, 6, NULL, NULL); +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (241, 234, '新闻列表', 'novel/news', 'novel:news:news', 1, 'fa', 8, NULL, NULL); +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (240, 235, '批量删除', NULL, 'novel:category:batchRemove', 2, NULL, 6, NULL, NULL); +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (239, 235, '删除', NULL, 'novel:category:remove', 2, NULL, 6, NULL, NULL); +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (238, 235, '修改', NULL, 'novel:category:edit', 2, NULL, 6, NULL, NULL); +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (237, 235, '新增', NULL, 'novel:category:add', 2, NULL, 6, NULL, NULL); +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (236, 235, '查看', NULL, 'novel:category:detail', 2, NULL, 6, NULL, NULL); +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (235, 234, '类别管理', 'novel/category', 'novel:category:category', 1, 'fa', 6, NULL, NULL); +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (234, 0, '新闻管理', '', '', 0, 'fa fa-newspaper-o', 8, NULL, NULL); + + + +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4889, 1, 246); +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4890, 1, 245); +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4891, 1, 244); +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4892, 1, 243); +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4893, 1, 242); +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4899, 1, 241); +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4894, 1, 240); +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4895, 1, 239); +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4896, 1, 238); +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4897, 1, 237); +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4898, 1, 236); +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4900, 1, 235); +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4888, 1, 234); + + +delete from sys_menu where menu_id = 202; \ No newline at end of file diff --git a/sql/novel_plus.sql b/sql/novel_plus.sql index a544e18..2c4c9ad 100644 --- a/sql/novel_plus.sql +++ b/sql/novel_plus.sql @@ -1869,4 +1869,39 @@ CREATE TABLE `author_income` ( alter table book add column `yesterday_buy` int(11) DEFAULT '0' COMMENT '昨日订阅数' after comment_count; -alter table book_index add column `book_price` int(3) DEFAULT 0 COMMENT '章节费用(屋币)' after `is_vip`; \ No newline at end of file +alter table book_index add column `book_price` int(3) DEFAULT 0 COMMENT '章节费用(屋币)' after `is_vip`; + + + +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (246, 241, '批量删除', NULL, 'novel:news:batchRemove', 2, NULL, 6, NULL, NULL); +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (245, 241, '删除', NULL, 'novel:news:remove', 2, NULL, 6, NULL, NULL); +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (244, 241, '修改', NULL, 'novel:news:edit', 2, NULL, 6, NULL, NULL); +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (243, 241, '新增', NULL, 'novel:news:add', 2, NULL, 6, NULL, NULL); +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (242, 241, '查看', NULL, 'novel:news:detail', 2, NULL, 6, NULL, NULL); +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (241, 234, '新闻列表', 'novel/news', 'novel:news:news', 1, 'fa', 8, NULL, NULL); +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (240, 235, '批量删除', NULL, 'novel:category:batchRemove', 2, NULL, 6, NULL, NULL); +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (239, 235, '删除', NULL, 'novel:category:remove', 2, NULL, 6, NULL, NULL); +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (238, 235, '修改', NULL, 'novel:category:edit', 2, NULL, 6, NULL, NULL); +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (237, 235, '新增', NULL, 'novel:category:add', 2, NULL, 6, NULL, NULL); +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (236, 235, '查看', NULL, 'novel:category:detail', 2, NULL, 6, NULL, NULL); +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (235, 234, '类别管理', 'novel/category', 'novel:category:category', 1, 'fa', 6, NULL, NULL); +INSERT INTO `sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `gmt_create`, `gmt_modified`) VALUES (234, 0, '新闻管理', '', '', 0, 'fa fa-newspaper-o', 8, NULL, NULL); + + + +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4889, 1, 246); +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4890, 1, 245); +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4891, 1, 244); +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4892, 1, 243); +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4893, 1, 242); +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4899, 1, 241); +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4894, 1, 240); +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4895, 1, 239); +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4896, 1, 238); +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4897, 1, 237); +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4898, 1, 236); +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4900, 1, 235); +INSERT INTO `sys_role_menu`(`id`, `role_id`, `menu_id`) VALUES (4888, 1, 234); + + +delete from sys_menu where menu_id = 202; \ No newline at end of file