diff --git a/novel-admin/src/main/java/com/java2nb/novel/controller/BookController.java b/novel-admin/src/main/java/com/java2nb/novel/controller/BookController.java new file mode 100644 index 0000000..216991e --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/novel/controller/BookController.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.BookDO; +import com.java2nb.novel.service.BookService; +import com.java2nb.common.utils.PageBean; +import com.java2nb.common.utils.Query; +import com.java2nb.common.utils.R; + +/** + * 小说表 + * + * @author phacks + * @email 1179705413@qq.com + * @date 2020-05-16 15:08:34 + */ + +@Controller +@RequestMapping("/novel/book") +public class BookController { + @Autowired + private BookService bookService; + + @GetMapping() + @RequiresPermissions("novel:book:book") + String Book() { + return "novel/book/book"; + } + + @ApiOperation(value = "获取小说表列表", notes = "获取小说表列表") + @ResponseBody + @GetMapping("/list") + @RequiresPermissions("novel:book:book") + public R list(@RequestParam Map params) { + //查询列表数据 + Query query = new Query(params); + List bookList = bookService.list(query); + int total = bookService.count(query); + PageBean pageBean = new PageBean(bookList, total); + return R.ok().put("data", pageBean); + } + + @ApiOperation(value = "新增小说表页面", notes = "新增小说表页面") + @GetMapping("/add") + @RequiresPermissions("novel:book:add") + String add() { + return "novel/book/add"; + } + + @ApiOperation(value = "修改小说表页面", notes = "修改小说表页面") + @GetMapping("/edit/{id}") + @RequiresPermissions("novel:book:edit") + String edit(@PathVariable("id") Long id, Model model) { + BookDO book = bookService.get(id); + model.addAttribute("book", book); + return "novel/book/edit"; + } + + @ApiOperation(value = "查看小说表页面", notes = "查看小说表页面") + @GetMapping("/detail/{id}") + @RequiresPermissions("novel:book:detail") + String detail(@PathVariable("id") Long id, Model model) { + BookDO book = bookService.get(id); + model.addAttribute("book", book); + return "novel/book/detail"; + } + + /** + * 保存 + */ + @ApiOperation(value = "新增小说表", notes = "新增小说表") + @ResponseBody + @PostMapping("/save") + @RequiresPermissions("novel:book:add") + public R save( BookDO book) { + if (bookService.save(book) > 0) { + return R.ok(); + } + return R.error(); + } + + /** + * 修改 + */ + @ApiOperation(value = "修改小说表", notes = "修改小说表") + @ResponseBody + @RequestMapping("/update") + @RequiresPermissions("novel:book:edit") + public R update( BookDO book) { + bookService.update(book); + return R.ok(); + } + + /** + * 删除 + */ + @ApiOperation(value = "删除小说表", notes = "删除小说表") + @PostMapping("/remove") + @ResponseBody + @RequiresPermissions("novel:book:remove") + public R remove( Long id) { + if (bookService.remove(id) > 0) { + return R.ok(); + } + return R.error(); + } + + /** + * 删除 + */ + @ApiOperation(value = "批量删除小说表", notes = "批量删除小说表") + @PostMapping("/batchRemove") + @ResponseBody + @RequiresPermissions("novel:book:batchRemove") + public R remove(@RequestParam("ids[]") Long[] ids) { + bookService.batchRemove(ids); + return R.ok(); + } + +} diff --git a/novel-admin/src/main/java/com/java2nb/novel/dao/BookDao.java b/novel-admin/src/main/java/com/java2nb/novel/dao/BookDao.java new file mode 100644 index 0000000..01d591d --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/novel/dao/BookDao.java @@ -0,0 +1,32 @@ +package com.java2nb.novel.dao; + +import com.java2nb.novel.domain.BookDO; + +import java.util.List; +import java.util.Map; + +import org.apache.ibatis.annotations.Mapper; + +/** + * 小说表 + * @author phacks + * @email 1179705413@qq.com + * @date 2020-05-16 15:08:34 + */ +@Mapper +public interface BookDao { + + BookDO get(Long id); + + List list(Map map); + + int count(Map map); + + int save(BookDO book); + + int update(BookDO book); + + int remove(Long id); + + int batchRemove(Long[] ids); +} diff --git a/novel-admin/src/main/java/com/java2nb/novel/domain/BookDO.java b/novel-admin/src/main/java/com/java2nb/novel/domain/BookDO.java new file mode 100644 index 0000000..a43ad9e --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/novel/domain/BookDO.java @@ -0,0 +1,395 @@ +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 phacks + * @email 1179705413@qq.com + * @date 2020-05-16 15:08:34 + */ +public class BookDO implements Serializable { + private static final long serialVersionUID = 1L; + + + //主键 + //java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值) + //所以通过序列化成字符串来解决 + @JsonSerialize(using = LongToStringSerializer.class) + private Long id; + //作品方向,0:男频,1:女频' + private Integer workDirection; + //分类ID + private Integer catId; + //分类名 + private String catName; + //小说封面 + private String picUrl; + //小说名 + private String bookName; + //作者id + //java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值) + //所以通过序列化成字符串来解决 + @JsonSerialize(using = LongToStringSerializer.class) + private Long authorId; + //作者名 + private String authorName; + //书籍描述 + private String bookDesc; + //评分,预留字段 + private Float score; + //书籍状态,0:连载中,1:已完结 + private Integer bookStatus; + //点击量 + //java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值) + //所以通过序列化成字符串来解决 + @JsonSerialize(using = LongToStringSerializer.class) + private Long visitCount; + //总字数 + private Integer wordCount; + //评论数 + private Integer commentCount; + //最新目录ID + //java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值) + //所以通过序列化成字符串来解决 + @JsonSerialize(using = LongToStringSerializer.class) + private Long lastIndexId; + //最新目录名 + private String lastIndexName; + //最新目录更新时间 + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date lastIndexUpdateTime; + //是否收费,1:收费,0:免费 + private Integer isVip; + //状态,0:入库,1:上架 + private Integer status; + //更新时间 + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; + //创建时间 + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + //爬虫源站ID + private Integer crawlSourceId; + //抓取的源站小说ID + private String crawlBookId; + //最后一次的抓取时间 + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date crawlLastTime; + //是否已停止更新,0:未停止,1:已停止 + private Integer crawlIsStop; + + /** + * 设置:主键 + */ + public void setId(Long id) { + this.id = id; + } + /** + * 获取:主键 + */ + public Long getId() { + return id; + } + /** + * 设置:作品方向,0:男频,1:女频' + */ + public void setWorkDirection(Integer workDirection) { + this.workDirection = workDirection; + } + /** + * 获取:作品方向,0:男频,1:女频' + */ + public Integer getWorkDirection() { + return workDirection; + } + /** + * 设置:分类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 setPicUrl(String picUrl) { + this.picUrl = picUrl; + } + /** + * 获取:小说封面 + */ + public String getPicUrl() { + return picUrl; + } + /** + * 设置:小说名 + */ + public void setBookName(String bookName) { + this.bookName = bookName; + } + /** + * 获取:小说名 + */ + public String getBookName() { + return bookName; + } + /** + * 设置:作者id + */ + public void setAuthorId(Long authorId) { + this.authorId = authorId; + } + /** + * 获取:作者id + */ + public Long getAuthorId() { + return authorId; + } + /** + * 设置:作者名 + */ + public void setAuthorName(String authorName) { + this.authorName = authorName; + } + /** + * 获取:作者名 + */ + public String getAuthorName() { + return authorName; + } + /** + * 设置:书籍描述 + */ + public void setBookDesc(String bookDesc) { + this.bookDesc = bookDesc; + } + /** + * 获取:书籍描述 + */ + public String getBookDesc() { + return bookDesc; + } + /** + * 设置:评分,预留字段 + */ + public void setScore(Float score) { + this.score = score; + } + /** + * 获取:评分,预留字段 + */ + public Float getScore() { + return score; + } + /** + * 设置:书籍状态,0:连载中,1:已完结 + */ + public void setBookStatus(Integer bookStatus) { + this.bookStatus = bookStatus; + } + /** + * 获取:书籍状态,0:连载中,1:已完结 + */ + public Integer getBookStatus() { + return bookStatus; + } + /** + * 设置:点击量 + */ + public void setVisitCount(Long visitCount) { + this.visitCount = visitCount; + } + /** + * 获取:点击量 + */ + public Long getVisitCount() { + return visitCount; + } + /** + * 设置:总字数 + */ + public void setWordCount(Integer wordCount) { + this.wordCount = wordCount; + } + /** + * 获取:总字数 + */ + public Integer getWordCount() { + return wordCount; + } + /** + * 设置:评论数 + */ + public void setCommentCount(Integer commentCount) { + this.commentCount = commentCount; + } + /** + * 获取:评论数 + */ + public Integer getCommentCount() { + return commentCount; + } + /** + * 设置:最新目录ID + */ + public void setLastIndexId(Long lastIndexId) { + this.lastIndexId = lastIndexId; + } + /** + * 获取:最新目录ID + */ + public Long getLastIndexId() { + return lastIndexId; + } + /** + * 设置:最新目录名 + */ + public void setLastIndexName(String lastIndexName) { + this.lastIndexName = lastIndexName; + } + /** + * 获取:最新目录名 + */ + public String getLastIndexName() { + return lastIndexName; + } + /** + * 设置:最新目录更新时间 + */ + public void setLastIndexUpdateTime(Date lastIndexUpdateTime) { + this.lastIndexUpdateTime = lastIndexUpdateTime; + } + /** + * 获取:最新目录更新时间 + */ + public Date getLastIndexUpdateTime() { + return lastIndexUpdateTime; + } + /** + * 设置:是否收费,1:收费,0:免费 + */ + public void setIsVip(Integer isVip) { + this.isVip = isVip; + } + /** + * 获取:是否收费,1:收费,0:免费 + */ + public Integer getIsVip() { + return isVip; + } + /** + * 设置:状态,0:入库,1:上架 + */ + public void setStatus(Integer status) { + this.status = status; + } + /** + * 获取:状态,0:入库,1:上架 + */ + public Integer getStatus() { + return status; + } + /** + * 设置:更新时间 + */ + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + /** + * 获取:更新时间 + */ + public Date getUpdateTime() { + return updateTime; + } + /** + * 设置:创建时间 + */ + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + /** + * 获取:创建时间 + */ + public Date getCreateTime() { + return createTime; + } + /** + * 设置:爬虫源站ID + */ + public void setCrawlSourceId(Integer crawlSourceId) { + this.crawlSourceId = crawlSourceId; + } + /** + * 获取:爬虫源站ID + */ + public Integer getCrawlSourceId() { + return crawlSourceId; + } + /** + * 设置:抓取的源站小说ID + */ + public void setCrawlBookId(String crawlBookId) { + this.crawlBookId = crawlBookId; + } + /** + * 获取:抓取的源站小说ID + */ + public String getCrawlBookId() { + return crawlBookId; + } + /** + * 设置:最后一次的抓取时间 + */ + public void setCrawlLastTime(Date crawlLastTime) { + this.crawlLastTime = crawlLastTime; + } + /** + * 获取:最后一次的抓取时间 + */ + public Date getCrawlLastTime() { + return crawlLastTime; + } + /** + * 设置:是否已停止更新,0:未停止,1:已停止 + */ + public void setCrawlIsStop(Integer crawlIsStop) { + this.crawlIsStop = crawlIsStop; + } + /** + * 获取:是否已停止更新,0:未停止,1:已停止 + */ + public Integer getCrawlIsStop() { + return crawlIsStop; + } +} diff --git a/novel-admin/src/main/java/com/java2nb/novel/service/BookService.java b/novel-admin/src/main/java/com/java2nb/novel/service/BookService.java new file mode 100644 index 0000000..f8dda3c --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/novel/service/BookService.java @@ -0,0 +1,30 @@ +package com.java2nb.novel.service; + +import com.java2nb.novel.domain.BookDO; + +import java.util.List; +import java.util.Map; + +/** + * 小说表 + * + * @author phacks + * @email 1179705413@qq.com + * @date 2020-05-16 15:08:34 + */ +public interface BookService { + + BookDO get(Long id); + + List list(Map map); + + int count(Map map); + + int save(BookDO book); + + int update(BookDO book); + + int remove(Long id); + + int batchRemove(Long[] ids); +} diff --git a/novel-admin/src/main/java/com/java2nb/novel/service/impl/BookServiceImpl.java b/novel-admin/src/main/java/com/java2nb/novel/service/impl/BookServiceImpl.java new file mode 100644 index 0000000..2bd27b3 --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/novel/service/impl/BookServiceImpl.java @@ -0,0 +1,55 @@ +package com.java2nb.novel.service.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +import com.java2nb.novel.dao.BookDao; +import com.java2nb.novel.domain.BookDO; +import com.java2nb.novel.service.BookService; + + + +@Service +public class BookServiceImpl implements BookService { + @Autowired + private BookDao bookDao; + + @Override + public BookDO get(Long id){ + return bookDao.get(id); + } + + @Override + public List list(Map map){ + return bookDao.list(map); + } + + @Override + public int count(Map map){ + return bookDao.count(map); + } + + @Override + public int save(BookDO book){ + return bookDao.save(book); + } + + @Override + public int update(BookDO book){ + return bookDao.update(book); + } + + @Override + public int remove(Long id){ + return bookDao.remove(id); + } + + @Override + public int batchRemove(Long[] ids){ + return bookDao.batchRemove(ids); + } + +} diff --git a/novel-admin/src/main/resources/mybatis/novel/BookMapper.xml b/novel-admin/src/main/resources/mybatis/novel/BookMapper.xml new file mode 100644 index 0000000..ac028b5 --- /dev/null +++ b/novel-admin/src/main/resources/mybatis/novel/BookMapper.xml @@ -0,0 +1,241 @@ + + + + + + + + + + + + + insert into book + ( + `work_direction`, + `cat_id`, + `cat_name`, + `pic_url`, + `book_name`, + `author_id`, + `author_name`, + `book_desc`, + `score`, + `book_status`, + `visit_count`, + `word_count`, + `comment_count`, + `last_index_id`, + `last_index_name`, + `last_index_update_time`, + `is_vip`, + `status`, + `update_time`, + `create_time`, + `crawl_source_id`, + `crawl_book_id`, + `crawl_last_time`, + `crawl_is_stop` + ) + values + ( + #{workDirection}, + #{catId}, + #{catName}, + #{picUrl}, + #{bookName}, + #{authorId}, + #{authorName}, + #{bookDesc}, + #{score}, + #{bookStatus}, + #{visitCount}, + #{wordCount}, + #{commentCount}, + #{lastIndexId}, + #{lastIndexName}, + #{lastIndexUpdateTime}, + #{isVip}, + #{status}, + #{updateTime}, + #{createTime}, + #{crawlSourceId}, + #{crawlBookId}, + #{crawlLastTime}, + #{crawlIsStop} + ) + + + + insert into book + ( + `id`, + `work_direction`, + `cat_id`, + `cat_name`, + `pic_url`, + `book_name`, + `author_id`, + `author_name`, + `book_desc`, + `score`, + `book_status`, + `visit_count`, + `word_count`, + `comment_count`, + `last_index_id`, + `last_index_name`, + `last_index_update_time`, + `is_vip`, + `status`, + `update_time`, + `create_time`, + `crawl_source_id`, + `crawl_book_id`, + `crawl_last_time`, + `crawl_is_stop` + ) + values + ( + #{id}, + #{workDirection}, + #{catId}, + #{catName}, + #{picUrl}, + #{bookName}, + #{authorId}, + #{authorName}, + #{bookDesc}, + #{score}, + #{bookStatus}, + #{visitCount}, + #{wordCount}, + #{commentCount}, + #{lastIndexId}, + #{lastIndexName}, + #{lastIndexUpdateTime}, + #{isVip}, + #{status}, + #{updateTime}, + #{createTime}, + #{crawlSourceId}, + #{crawlBookId}, + #{crawlLastTime}, + #{crawlIsStop} + ) + + + + update book + + `work_direction` = #{workDirection}, + `cat_id` = #{catId}, + `cat_name` = #{catName}, + `pic_url` = #{picUrl}, + `book_name` = #{bookName}, + `author_id` = #{authorId}, + `author_name` = #{authorName}, + `book_desc` = #{bookDesc}, + `score` = #{score}, + `book_status` = #{bookStatus}, + `visit_count` = #{visitCount}, + `word_count` = #{wordCount}, + `comment_count` = #{commentCount}, + `last_index_id` = #{lastIndexId}, + `last_index_name` = #{lastIndexName}, + `last_index_update_time` = #{lastIndexUpdateTime}, + `is_vip` = #{isVip}, + `status` = #{status}, + `update_time` = #{updateTime}, + `create_time` = #{createTime}, + `crawl_source_id` = #{crawlSourceId}, + `crawl_book_id` = #{crawlBookId}, + `crawl_last_time` = #{crawlLastTime}, + `crawl_is_stop` = #{crawlIsStop} + + where id = #{id} + + + + delete from book where id = #{value} + + + + delete from book where id in + + #{id} + + + + \ No newline at end of file diff --git a/novel-admin/src/main/resources/static/js/appjs/novel/book/add.js b/novel-admin/src/main/resources/static/js/appjs/novel/book/add.js new file mode 100644 index 0000000..ee612a0 --- /dev/null +++ b/novel-admin/src/main/resources/static/js/appjs/novel/book/add.js @@ -0,0 +1,107 @@ +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/book/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: { + }, + messages: { + } +}) +} \ 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 new file mode 100644 index 0000000..2135f5f --- /dev/null +++ b/novel-admin/src/main/resources/static/js/appjs/novel/book/book.js @@ -0,0 +1,321 @@ +var prefix = "/novel/book" +$(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: 'id', + title: '主键' + }, + + + { + field: 'workDirection', + title: '作品方向,0:男频,1:女频' + }, + + + { + field: 'catId', + title: '分类ID' + }, + + + { + field: 'catName', + title: '分类名' + }, + + + { + field: 'picUrl', + title: '小说封面' + }, + + + { + field: 'bookName', + title: '小说名' + }, + + + { + field: 'authorId', + title: '作者id' + }, + + + { + field: 'authorName', + title: '作者名' + }, + + + { + field: 'bookDesc', + title: '书籍描述' + }, + + + { + field: 'score', + title: '评分,预留字段' + }, + + + { + field: 'bookStatus', + title: '书籍状态,0:连载中,1:已完结' + }, + + + { + field: 'visitCount', + title: '点击量' + }, + + + { + field: 'wordCount', + title: '总字数' + }, + + + { + field: 'commentCount', + title: '评论数' + }, + + + { + field: 'lastIndexId', + title: '最新目录ID' + }, + + + { + field: 'lastIndexName', + title: '最新目录名' + }, + + + { + field: 'lastIndexUpdateTime', + title: '最新目录更新时间' + }, + + + { + field: 'isVip', + title: '是否收费,1:收费,0:免费' + }, + + + { + field: 'status', + title: '状态,0:入库,1:上架' + }, + + + { + field: 'updateTime', + title: '更新时间' + }, + + + { + field: 'createTime', + title: '创建时间' + }, + + + { + field: 'crawlSourceId', + title: '爬虫源站ID' + }, + + + { + field: 'crawlBookId', + title: '抓取的源站小说ID' + }, + + + { + field: 'crawlLastTime', + title: '最后一次的抓取时间' + }, + + + { + field: 'crawlIsStop', + title: '是否已停止更新,0:未停止,1:已停止' + }, + + + { + title: '操作', + field: 'id', + align: 'center', + formatter: function (value, row, index) { + var d = ' '; + var e = ' '; + var r = ' '; + return d + 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/book/edit.js b/novel-admin/src/main/resources/static/js/appjs/novel/book/edit.js new file mode 100644 index 0000000..dfff98f --- /dev/null +++ b/novel-admin/src/main/resources/static/js/appjs/novel/book/edit.js @@ -0,0 +1,103 @@ +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/book/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: { + }, + messages: { + } +}) +} \ No newline at end of file diff --git a/novel-admin/src/main/resources/static/sql/novel/book/menu.js b/novel-admin/src/main/resources/static/sql/novel/book/menu.js new file mode 100644 index 0000000..057e333 --- /dev/null +++ b/novel-admin/src/main/resources/static/sql/novel/book/menu.js @@ -0,0 +1,18 @@ +-- 菜单SQL +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + VALUES ('1', '小说表', 'novel/book', 'novel:book:book', '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:book:detail', '2', null, '6'; +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + SELECT @parentId, '新增', null, 'novel:book:add', '2', null, '6'; +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + SELECT @parentId, '修改', null, 'novel:book:edit', '2', null, '6'; +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + SELECT @parentId, '删除', null, 'novel:book:remove', '2', null, '6'; +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + SELECT @parentId, '批量删除', null, 'novel:book:batchRemove', '2', null, '6'; diff --git a/novel-admin/src/main/resources/templates/novel/book/add.html b/novel-admin/src/main/resources/templates/novel/book/add.html new file mode 100644 index 0000000..0062404 --- /dev/null +++ b/novel-admin/src/main/resources/templates/novel/book/add.html @@ -0,0 +1,252 @@ + + + + + +
+
+
+
+
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+ +
+
+
+
+
+
+
+
+
+ + + + diff --git a/novel-admin/src/main/resources/templates/novel/book/book.html b/novel-admin/src/main/resources/templates/novel/book/book.html new file mode 100644 index 0000000..412294b --- /dev/null +++ b/novel-admin/src/main/resources/templates/novel/book/book.html @@ -0,0 +1,77 @@ + + + + + +
+
+
+
+
+
+ + +
+
+ + +
+
+ +
+ +
+
+ +
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+ + + \ No newline at end of file diff --git a/novel-admin/src/main/resources/templates/novel/book/detail.html b/novel-admin/src/main/resources/templates/novel/book/detail.html new file mode 100644 index 0000000..29a73e1 --- /dev/null +++ b/novel-admin/src/main/resources/templates/novel/book/detail.html @@ -0,0 +1,258 @@ + + + + + +
+
+
+
+
+
+ +
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + +
+
+
+
+
+
+
+
+ + diff --git a/novel-admin/src/main/resources/templates/novel/book/edit.html b/novel-admin/src/main/resources/templates/novel/book/edit.html new file mode 100644 index 0000000..370e557 --- /dev/null +++ b/novel-admin/src/main/resources/templates/novel/book/edit.html @@ -0,0 +1,254 @@ + + + + + +
+
+
+
+
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+
+ + + +