重构文档管理模块

This commit is contained in:
gxwebsoft
2024-03-24 00:00:43 +08:00
parent 634c1babab
commit c63ea71315
20 changed files with 844 additions and 18 deletions
@@ -0,0 +1,105 @@
package com.gxwebsoft.cms.controller;
import com.gxwebsoft.cms.entity.DocsBook;
import com.gxwebsoft.cms.param.DocsBookParam;
import com.gxwebsoft.cms.service.DocsBookService;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.web.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* 书籍记录表控制器
*
* @author 科技小王子
* @since 2024-03-23 19:40:02
*/
@Api(tags = "书籍记录表管理")
@RestController
@RequestMapping("/api/cms/docs-book")
public class DocsBookController extends BaseController {
@Resource
private DocsBookService docsBookService;
@ApiOperation("分页查询书籍记录表")
@GetMapping("/page")
public ApiResult<PageResult<DocsBook>> page(DocsBookParam param) {
// 使用关联查询
return success(docsBookService.pageRel(param));
}
@ApiOperation("查询全部书籍记录表")
@GetMapping()
public ApiResult<List<DocsBook>> list(DocsBookParam param) {
// 使用关联查询
return success(docsBookService.listRel(param));
}
@ApiOperation("根据id查询书籍记录表")
@GetMapping("/{id}")
public ApiResult<DocsBook> get(@PathVariable("id") Integer id) {
// 使用关联查询
return success(docsBookService.getByIdRel(id));
}
@ApiOperation("添加书籍记录表")
@PostMapping()
public ApiResult<?> save(@RequestBody DocsBook docsBook) {
if (docsBookService.save(docsBook)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("修改书籍记录表")
@PutMapping()
public ApiResult<?> update(@RequestBody DocsBook docsBook) {
if (docsBookService.updateById(docsBook)) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("删除书籍记录表")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (docsBookService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@ApiOperation("批量添加书籍记录表")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<DocsBook> list) {
if (docsBookService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("批量修改书籍记录表")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<DocsBook> batchParam) {
if (batchParam.update(docsBookService, "book_id")) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("批量删除书籍记录表")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (docsBookService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
}
@@ -0,0 +1,105 @@
package com.gxwebsoft.cms.controller;
import com.gxwebsoft.cms.entity.DocsContent;
import com.gxwebsoft.cms.param.DocsContentParam;
import com.gxwebsoft.cms.service.DocsContentService;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.web.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* 文档内容记录表控制器
*
* @author 科技小王子
* @since 2024-03-23 19:51:37
*/
@Api(tags = "文档内容记录表管理")
@RestController
@RequestMapping("/api/cms/docs-content")
public class DocsContentController extends BaseController {
@Resource
private DocsContentService docsContentService;
@ApiOperation("分页查询文档内容记录表")
@GetMapping("/page")
public ApiResult<PageResult<DocsContent>> page(DocsContentParam param) {
// 使用关联查询
return success(docsContentService.pageRel(param));
}
@ApiOperation("查询全部文档内容记录表")
@GetMapping()
public ApiResult<List<DocsContent>> list(DocsContentParam param) {
// 使用关联查询
return success(docsContentService.listRel(param));
}
@ApiOperation("根据id查询文档内容记录表")
@GetMapping("/{id}")
public ApiResult<DocsContent> get(@PathVariable("id") Integer id) {
// 使用关联查询
return success(docsContentService.getByIdRel(id));
}
@ApiOperation("添加文档内容记录表")
@PostMapping()
public ApiResult<?> save(@RequestBody DocsContent docsContent) {
if (docsContentService.save(docsContent)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("修改文档内容记录表")
@PutMapping()
public ApiResult<?> update(@RequestBody DocsContent docsContent) {
if (docsContentService.updateById(docsContent)) {
return success("保存成功");
}
return fail("保存失败");
}
@ApiOperation("删除文档内容记录表")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (docsContentService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@ApiOperation("批量添加文档内容记录表")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<DocsContent> list) {
if (docsContentService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("批量修改文档内容记录表")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<DocsContent> batchParam) {
if (batchParam.update(docsContentService, "id")) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("批量删除文档内容记录表")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (docsContentService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
}
@@ -1,9 +1,20 @@
package com.gxwebsoft.cms.controller; package com.gxwebsoft.cms.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gxwebsoft.cms.entity.Docs; import com.gxwebsoft.cms.entity.Docs;
import com.gxwebsoft.cms.entity.DocsBook;
import com.gxwebsoft.cms.entity.DocsContent;
import com.gxwebsoft.cms.param.DocsBookParam;
import com.gxwebsoft.cms.param.DocsContentParam;
import com.gxwebsoft.cms.param.DocsParam; import com.gxwebsoft.cms.param.DocsParam;
import com.gxwebsoft.cms.service.DocsBookService;
import com.gxwebsoft.cms.service.DocsContentService;
import com.gxwebsoft.cms.service.DocsService; import com.gxwebsoft.cms.service.DocsService;
import com.gxwebsoft.common.core.web.*; import com.gxwebsoft.common.core.utils.CommonUtil;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.User; import com.gxwebsoft.common.system.entity.User;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@@ -24,20 +35,30 @@ import java.util.List;
public class DocsController extends BaseController { public class DocsController extends BaseController {
@Resource @Resource
private DocsService docsService; private DocsService docsService;
@Resource
private DocsContentService contentService;
@Resource
private DocsBookService bookService;
@ApiOperation("分页查询文档管理记录表") @ApiOperation("分页查询文档管理记录表")
@GetMapping("/page") @GetMapping("/page")
public ApiResult<PageResult<Docs>> page(DocsParam param) { public ApiResult<PageResult<Docs>> page(DocsParam param) {
PageParam<Docs, DocsParam> page = new PageParam<>(param);
page.setDefaultOrder("create_time desc");
return success(docsService.page(page, page.getWrapper()));
// 使用关联查询 // 使用关联查询
//return success(docsService.pageRel(param)); return success(docsService.pageRel(param));
} }
@ApiOperation("查询全部文档管理记录表") @ApiOperation("查询全部文档管理记录表")
@GetMapping() @GetMapping()
public ApiResult<List<Docs>> list(DocsParam param) { public ApiResult<List<Docs>> list(DocsParam param) {
// 通过书籍标识查询所有的目录章节
if(param.getCode() != null){
final DocsBookParam bookParam = new DocsBookParam();
bookParam.setCode(param.getCode());
final List<DocsBook> books = bookService.listRel(bookParam);
final DocsBook book = CommonUtil.listGetOne(books);
param.setBookId(book.getBookId());
return success(docsService.listRel(param));
}
// 使用关联查询 // 使用关联查询
return success(docsService.listRel(param)); return success(docsService.listRel(param));
} }
@@ -45,9 +66,40 @@ public class DocsController extends BaseController {
@ApiOperation("根据id查询文档管理记录表") @ApiOperation("根据id查询文档管理记录表")
@GetMapping("/{id}") @GetMapping("/{id}")
public ApiResult<Docs> get(@PathVariable("id") Integer id) { public ApiResult<Docs> get(@PathVariable("id") Integer id) {
return success(docsService.getById(id)); final Docs docs = docsService.getByIdRel(id);
// 使用关联查询 final DocsContentParam param = new DocsContentParam();
//return success(docsService.getByIdRel(id)); param.setDocsId(id);
final List<DocsContent> list = contentService.listRel(param);
DocsContent content = CommonUtil.listGetOne(list);
docs.setContent(content.getContent());
docs.setContentId(content.getId());
// 更新阅读数量
docs.setActualViews(docs.getActualViews() + 1);
docsService.updateById(docs);
return success(docs);
}
@ApiOperation("读取上一篇")
@GetMapping("/getPrevious/{id}")
public ApiResult<Docs> getPrevious(@PathVariable("id") Integer id) {
LambdaQueryWrapper<Docs> wrapper = new LambdaQueryWrapper<>();
wrapper.lt(Docs::getDocsId,id);
wrapper.eq(Docs::getStatus,0);
wrapper.orderByDesc(Docs::getDocsId);
wrapper.last("limit 1");
final Docs article = docsService.getOne(wrapper);
return success(article);
}
@ApiOperation("读取下一篇")
@GetMapping("/getNext/{id}")
public ApiResult<Docs> getNext(@PathVariable("id") Integer id) {
LambdaQueryWrapper<Docs> wrapper = new LambdaQueryWrapper<>();
wrapper.gt(Docs::getDocsId,id);
wrapper.eq(Docs::getStatus,0);
wrapper.orderByAsc(Docs::getDocsId);
wrapper.last("limit 1");
final Docs article = docsService.getOne(wrapper);
return success(article);
} }
@ApiOperation("添加文档管理记录表") @ApiOperation("添加文档管理记录表")
@@ -1,18 +1,14 @@
package com.gxwebsoft.cms.entity; package com.gxwebsoft.cms.entity;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableLogic;
import java.io.Serializable;
import java.util.Date;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
/** /**
* 文档管理记录表 * 文档管理记录表
* *
@@ -30,6 +26,9 @@ public class Docs implements Serializable {
@TableId(value = "docs_id", type = IdType.AUTO) @TableId(value = "docs_id", type = IdType.AUTO)
private Integer docsId; private Integer docsId;
@ApiModelProperty(value = "书籍ID")
private Integer bookId;
@ApiModelProperty(value = "文档标题") @ApiModelProperty(value = "文档标题")
private String title; private String title;
@@ -45,10 +44,21 @@ public class Docs implements Serializable {
@ApiModelProperty(value = "可见性(public,private,protected)") @ApiModelProperty(value = "可见性(public,private,protected)")
private String visibility; private String visibility;
@ApiModelProperty(value = "虚拟阅读量(仅用作展示)")
private Integer virtualViews;
@ApiModelProperty(value = "实际阅读量")
private Integer actualViews;
@ApiModelProperty(value = "排序(数字越小越靠前)") @ApiModelProperty(value = "排序(数字越小越靠前)")
private Integer sortNumber; private Integer sortNumber;
@ApiModelProperty(value = "文档内容") @ApiModelProperty(value = "文章内容ID")
@TableField(exist = false)
private Integer contentId;
@ApiModelProperty(value = "文章内容")
@TableField(exist = false)
private String content; private String content;
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
@@ -0,0 +1,63 @@
package com.gxwebsoft.cms.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
/**
* 书籍记录表
*
* @author 科技小王子
* @since 2024-03-23 19:40:02
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "DocsBook对象", description = "书籍记录表")
@TableName("cms_docs_book")
public class DocsBook implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "ID")
@TableId(value = "book_id", type = IdType.AUTO)
private Integer bookId;
@ApiModelProperty(value = "书籍名称")
private String name;
@ApiModelProperty(value = "书籍标识")
private String code;
@ApiModelProperty(value = "封面图")
private String photo;
@ApiModelProperty(value = "备注")
private String comments;
@ApiModelProperty(value = "书籍介绍")
private String content;
@ApiModelProperty(value = "排序(数字越小越靠前)")
private Integer sortNumber;
@ApiModelProperty(value = "状态, 0正常, 1冻结")
private Integer status;
@ApiModelProperty(value = "是否删除, 0否, 1是")
@TableLogic
private Integer deleted;
@ApiModelProperty(value = "租户id")
private Integer tenantId;
@ApiModelProperty(value = "注册时间")
private Date createTime;
}
@@ -0,0 +1,43 @@
package com.gxwebsoft.cms.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
/**
* 文档内容记录表
*
* @author 科技小王子
* @since 2024-03-23 19:51:37
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "DocsContent对象", description = "文档内容记录表")
@TableName("cms_docs_content")
public class DocsContent implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "ID")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "文档ID")
private Integer docsId;
@ApiModelProperty(value = "文档内容")
private String content;
@ApiModelProperty(value = "租户id")
private Integer tenantId;
@ApiModelProperty(value = "注册时间")
private Date createTime;
}
@@ -0,0 +1,37 @@
package com.gxwebsoft.cms.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gxwebsoft.cms.entity.DocsBook;
import com.gxwebsoft.cms.param.DocsBookParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 书籍记录表Mapper
*
* @author 科技小王子
* @since 2024-03-23 19:40:02
*/
public interface DocsBookMapper extends BaseMapper<DocsBook> {
/**
* 分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return List<DocsBook>
*/
List<DocsBook> selectPageRel(@Param("page") IPage<DocsBook> page,
@Param("param") DocsBookParam param);
/**
* 查询全部
*
* @param param 查询参数
* @return List<User>
*/
List<DocsBook> selectListRel(@Param("param") DocsBookParam param);
}
@@ -0,0 +1,37 @@
package com.gxwebsoft.cms.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gxwebsoft.cms.entity.DocsContent;
import com.gxwebsoft.cms.param.DocsContentParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 文档内容记录表Mapper
*
* @author 科技小王子
* @since 2024-03-23 19:51:37
*/
public interface DocsContentMapper extends BaseMapper<DocsContent> {
/**
* 分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return List<DocsContent>
*/
List<DocsContent> selectPageRel(@Param("page") IPage<DocsContent> page,
@Param("param") DocsContentParam param);
/**
* 查询全部
*
* @param param 查询参数
* @return List<User>
*/
List<DocsContent> selectListRel(@Param("param") DocsContentParam param);
}
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gxwebsoft.cms.mapper.DocsBookMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
FROM cms_docs_book a
<where>
<if test="param.bookId != null">
AND a.book_id = #{param.bookId}
</if>
<if test="param.name != null">
AND a.name LIKE CONCAT('%', #{param.name}, '%')
</if>
<if test="param.code != null">
AND a.code = #{param.code}
</if>
<if test="param.photo != null">
AND a.photo LIKE CONCAT('%', #{param.photo}, '%')
</if>
<if test="param.comments != null">
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
</if>
<if test="param.content != null">
AND a.content LIKE CONCAT('%', #{param.content}, '%')
</if>
<if test="param.sortNumber != null">
AND a.sort_number = #{param.sortNumber}
</if>
<if test="param.deleted != null">
AND a.deleted = #{param.deleted}
</if>
<if test="param.deleted == null">
AND a.deleted = 0
</if>
<if test="param.createTimeStart != null">
AND a.create_time &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{param.createTimeEnd}
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.cms.entity.DocsBook">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.cms.entity.DocsBook">
<include refid="selectSql"></include>
</select>
</mapper>
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gxwebsoft.cms.mapper.DocsContentMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
FROM cms_docs_content a
<where>
<if test="param.id != null">
AND a.id = #{param.id}
</if>
<if test="param.docsId != null">
AND a.docs_id = #{param.docsId}
</if>
<if test="param.content != null">
AND a.content LIKE CONCAT('%', #{param.content}, '%')
</if>
<if test="param.createTimeStart != null">
AND a.create_time &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{param.createTimeEnd}
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.cms.entity.DocsContent">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.cms.entity.DocsContent">
<include refid="selectSql"></include>
</select>
</mapper>
@@ -10,6 +10,9 @@
<if test="param.docsId != null"> <if test="param.docsId != null">
AND a.docs_id = #{param.docsId} AND a.docs_id = #{param.docsId}
</if> </if>
<if test="param.bookId != null">
AND a.book_id = #{param.bookId}
</if>
<if test="param.title != null"> <if test="param.title != null">
AND a.title LIKE CONCAT('%', #{param.title}, '%') AND a.title LIKE CONCAT('%', #{param.title}, '%')
</if> </if>
@@ -0,0 +1,53 @@
package com.gxwebsoft.cms.param;
import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType;
import com.gxwebsoft.common.core.web.BaseParam;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 书籍记录表查询参数
*
* @author 科技小王子
* @since 2024-03-23 19:40:02
*/
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "DocsBookParam对象", description = "书籍记录表查询参数")
public class DocsBookParam extends BaseParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "ID")
@QueryField(type = QueryType.EQ)
private Integer bookId;
@ApiModelProperty(value = "书籍名称")
private String name;
@ApiModelProperty(value = "书籍标识")
@QueryField(type = QueryType.EQ)
private String code;
@ApiModelProperty(value = "封面图")
private String photo;
@ApiModelProperty(value = "备注")
private String comments;
@ApiModelProperty(value = "文档内容")
private String content;
@ApiModelProperty(value = "排序(数字越小越靠前)")
@QueryField(type = QueryType.EQ)
private Integer sortNumber;
@ApiModelProperty(value = "是否删除, 0否, 1是")
@QueryField(type = QueryType.EQ)
private Integer deleted;
}
@@ -0,0 +1,36 @@
package com.gxwebsoft.cms.param;
import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType;
import com.gxwebsoft.common.core.web.BaseParam;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 文档内容记录表查询参数
*
* @author 科技小王子
* @since 2024-03-23 19:51:37
*/
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "DocsContentParam对象", description = "文档内容记录表查询参数")
public class DocsContentParam extends BaseParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "ID")
@QueryField(type = QueryType.EQ)
private Integer id;
@ApiModelProperty(value = "文档ID")
@QueryField(type = QueryType.EQ)
private Integer docsId;
@ApiModelProperty(value = "文档内容")
private String content;
}
@@ -26,6 +26,14 @@ public class DocsParam extends BaseParam {
@QueryField(type = QueryType.EQ) @QueryField(type = QueryType.EQ)
private Integer docsId; private Integer docsId;
@ApiModelProperty(value = "书籍ID")
@QueryField(type = QueryType.EQ)
private Integer bookId;
@ApiModelProperty(value = "书籍标识")
@QueryField(type = QueryType.EQ)
private String code;
@ApiModelProperty(value = "文档标题") @ApiModelProperty(value = "文档标题")
private String title; private String title;
@@ -0,0 +1,42 @@
package com.gxwebsoft.cms.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.cms.entity.DocsBook;
import com.gxwebsoft.cms.param.DocsBookParam;
import java.util.List;
/**
* 书籍记录表Service
*
* @author 科技小王子
* @since 2024-03-23 19:40:02
*/
public interface DocsBookService extends IService<DocsBook> {
/**
* 分页关联查询
*
* @param param 查询参数
* @return PageResult<DocsBook>
*/
PageResult<DocsBook> pageRel(DocsBookParam param);
/**
* 关联查询全部
*
* @param param 查询参数
* @return List<DocsBook>
*/
List<DocsBook> listRel(DocsBookParam param);
/**
* 根据id查询
*
* @param bookId ID
* @return DocsBook
*/
DocsBook getByIdRel(Integer bookId);
}
@@ -0,0 +1,42 @@
package com.gxwebsoft.cms.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.cms.entity.DocsContent;
import com.gxwebsoft.cms.param.DocsContentParam;
import java.util.List;
/**
* 文档内容记录表Service
*
* @author 科技小王子
* @since 2024-03-23 19:51:37
*/
public interface DocsContentService extends IService<DocsContent> {
/**
* 分页关联查询
*
* @param param 查询参数
* @return PageResult<DocsContent>
*/
PageResult<DocsContent> pageRel(DocsContentParam param);
/**
* 关联查询全部
*
* @param param 查询参数
* @return List<DocsContent>
*/
List<DocsContent> listRel(DocsContentParam param);
/**
* 根据id查询
*
* @param id ID
* @return DocsContent
*/
DocsContent getByIdRel(Integer id);
}
@@ -0,0 +1,47 @@
package com.gxwebsoft.cms.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.cms.mapper.DocsBookMapper;
import com.gxwebsoft.cms.service.DocsBookService;
import com.gxwebsoft.cms.entity.DocsBook;
import com.gxwebsoft.cms.param.DocsBookParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 书籍记录表Service实现
*
* @author 科技小王子
* @since 2024-03-23 19:40:02
*/
@Service
public class DocsBookServiceImpl extends ServiceImpl<DocsBookMapper, DocsBook> implements DocsBookService {
@Override
public PageResult<DocsBook> pageRel(DocsBookParam param) {
PageParam<DocsBook, DocsBookParam> page = new PageParam<>(param);
page.setDefaultOrder("create_time desc");
List<DocsBook> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@Override
public List<DocsBook> listRel(DocsBookParam param) {
List<DocsBook> list = baseMapper.selectListRel(param);
// 排序
PageParam<DocsBook, DocsBookParam> page = new PageParam<>();
page.setDefaultOrder("create_time desc");
return page.sortRecords(list);
}
@Override
public DocsBook getByIdRel(Integer bookId) {
DocsBookParam param = new DocsBookParam();
param.setBookId(bookId);
return param.getOne(baseMapper.selectListRel(param));
}
}
@@ -0,0 +1,47 @@
package com.gxwebsoft.cms.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.cms.mapper.DocsContentMapper;
import com.gxwebsoft.cms.service.DocsContentService;
import com.gxwebsoft.cms.entity.DocsContent;
import com.gxwebsoft.cms.param.DocsContentParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 文档内容记录表Service实现
*
* @author 科技小王子
* @since 2024-03-23 19:51:37
*/
@Service
public class DocsContentServiceImpl extends ServiceImpl<DocsContentMapper, DocsContent> implements DocsContentService {
@Override
public PageResult<DocsContent> pageRel(DocsContentParam param) {
PageParam<DocsContent, DocsContentParam> page = new PageParam<>(param);
//page.setDefaultOrder("create_time desc");
List<DocsContent> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@Override
public List<DocsContent> listRel(DocsContentParam param) {
List<DocsContent> list = baseMapper.selectListRel(param);
// 排序
PageParam<DocsContent, DocsContentParam> page = new PageParam<>();
//page.setDefaultOrder("create_time desc");
return page.sortRecords(list);
}
@Override
public DocsContent getByIdRel(Integer id) {
DocsContentParam param = new DocsContentParam();
param.setId(id);
return param.getOne(baseMapper.selectListRel(param));
}
}
@@ -23,7 +23,7 @@ public class DocsServiceImpl extends ServiceImpl<DocsMapper, Docs> implements Do
@Override @Override
public PageResult<Docs> pageRel(DocsParam param) { public PageResult<Docs> pageRel(DocsParam param) {
PageParam<Docs, DocsParam> page = new PageParam<>(param); PageParam<Docs, DocsParam> page = new PageParam<>(param);
//page.setDefaultOrder("create_time desc"); page.setDefaultOrder("sort_number asc, create_time desc");
List<Docs> list = baseMapper.selectPageRel(page, param); List<Docs> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal()); return new PageResult<>(list, page.getTotal());
} }
@@ -47,6 +47,8 @@ public class CmsGenerator {
// "cms_article_comment", // "cms_article_comment",
// "cms_article_content", // "cms_article_content",
// "cms_docs", // "cms_docs",
// "cms_docs_book",
// "cms_docs_content",
// "cms_ad", // "cms_ad",
// "cms_ad_record", // "cms_ad_record",
// "cms_navigation", // "cms_navigation",