Merge remote-tracking branch 'origin/dev_1.0.0' into dev_1.0.0

release_1.0.0
xueqingkun 8 months ago
commit 2600422585

@ -0,0 +1,34 @@
package com.supervision.knowsub.controller;
import com.supervision.knowsub.service.FileService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
@Slf4j
@RestController
@Tag(name = "文件管理类")
@RequiredArgsConstructor
@RequestMapping("file")
public class FileController {
private final FileService fileService;
@Operation(summary = "文件上传")
@PostMapping("upload")
public String fileUpload(@RequestParam(name = "file") MultipartFile file) throws IOException {
byte[] bytes = file.getBytes();
return fileService.uploadFile(file.getOriginalFilename(), bytes);
}
@Operation(summary = "根据文件ID删除文件")
@GetMapping("deleteFileById")
public void deleteFileById(String fileId){
fileService.deleteFileById(fileId);
}
}

@ -1,7 +1,9 @@
package com.supervision.knowsub.controller.knowledge;
import cn.hutool.core.lang.Assert;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.supervision.knowsub.entity.vo.knowledge.SaveKnowLedgeReqVO;
import com.supervision.knowsub.entity.vo.knowledge.ModifyKnowledgeReqVO;
import com.supervision.knowsub.entity.vo.knowledge.SaveKnowledgeReqVO;
import com.supervision.knowsub.service.KnowledgeManageService;
import com.supervision.knowsub.model.Knowledge;
import io.swagger.v3.oas.annotations.Operation;
@ -40,17 +42,18 @@ public class KnowledgeManageController {
@Operation(summary = "新增知识库")
@PostMapping("saveKnowledge")
public void saveKnowledge(@RequestBody SaveKnowLedgeReqVO reqVO) {
public void saveKnowledge(@RequestBody SaveKnowledgeReqVO reqVO) {
knowledgeManageService.saveKnowledge(reqVO);
}
@Operation(summary = "修改知识库")
@Operation(summary = "修改知识库(已撤回才能编辑)")
@PostMapping("updateKnowledge")
public void updateKnowledge() {
public void updateKnowledge(@RequestBody ModifyKnowledgeReqVO reqVO) {
Assert.notBlank(reqVO.getKnowledgeId(),"知识ID不能为空");
knowledgeManageService.updateKnowledge(reqVO);
}
@Operation(summary = "回知识库")
@Operation(summary = "回知识库")
@GetMapping("recallKnowledge")
public void recallKnowledge() {

@ -4,7 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class KnowLedgeLinkVO {
public class KnowledgeLinkVO {
@Schema(description = "链接名称")
private String linkName;

@ -0,0 +1,11 @@
package com.supervision.knowsub.entity.vo.knowledge;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class ModifyKnowledgeReqVO extends SaveKnowledgeReqVO{
private String knowledgeId;
}

@ -1,12 +1,22 @@
package com.supervision.knowsub.entity.vo.knowledge;
import cn.hutool.core.date.DateTime;
import com.supervision.knowsub.model.KnowledgeBaseInfo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
public class SaveKnowLedgeReqVO {
public class SaveKnowledgeReqVO {
@Schema(description = "操作类型 1草稿 2提交")
@Max(value = 2, message = "操作类型 1草稿 2提交")
@Min(value = 1, message = "操作类型 1草稿 2提交")
private Integer operate;
@Schema(description = "报送人ID")
private String userId;
@ -23,34 +33,21 @@ public class SaveKnowLedgeReqVO {
@Schema(description = "摘要")
private String excerpt;
@Schema(description = "相关附件列表")
@Schema(description = "相关附件列表 file_info表ID")
private List<String> fileIdList;
@Schema(description = "链接列表")
private List<KnowLedgeLinkVO> linkList;
private List<KnowledgeLinkVO> linkList;
@Schema(description = "发布部门")
private String publishDept;
@Schema(description = "发文时间")
private String publishTime;
@Schema(description = "时效性 1长期有效 2临时有效")
private Integer timeliness;
@Schema(description = "到期自动失效 1到期自动失效")
private Integer autoLoseEffect;
@Schema(description = "所属地域")
private String territory;
private DateTime publishDate;
@Schema(description = "政策类型")
private String policyType;
@Schema(description = "知识标签")
private String knowLedgeTag;
@Schema(description = "公开范围 1公开 2不公开")
private String publishScope;
@Schema(description = "知识的基础信息")
private KnowledgeBaseInfo knowledgeBaseInfo;
}

@ -0,0 +1,42 @@
package com.supervision.knowsub.enums;
/**
* * 1 稿
* * 2
* * 3
* * 4
* * 5
* * 10 ()
* * 11 ()
* * 12 ()
*/
public enum StatusEnum {
DRAFT(1, "草稿"),
PASS(2, "通过"),
REJECT(3, "驳回"),
RECALL(4, "已撤回"),
INVALID(5, "已失效"),
DELETE(6, "已删除"),
WAIT_APPROVAL(10, "待审批(新增)"),
WAIT_APPROVAL_DELETE(11, "待审批(删除)"),
WAIT_APPROVAL_RECALL(12, "待审批(撤回)");
private final Integer status;
private final String desc;
StatusEnum(Integer status, String desc) {
this.status = status;
this.desc = desc;
}
public Integer getStatus() {
return status;
}
public String getDesc() {
return desc;
}
}

@ -0,0 +1,10 @@
package com.supervision.knowsub.service;
import org.springframework.web.multipart.MultipartFile;
public interface FileService {
String uploadFile(String fileName, byte[] fileBytes);
void deleteFileById(String fileId);
}

@ -1,9 +1,16 @@
package com.supervision.knowsub.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.supervision.knowsub.entity.vo.knowledge.ModifyKnowledgeReqVO;
import com.supervision.knowsub.entity.vo.knowledge.SaveKnowledgeReqVO;
import com.supervision.knowsub.model.Knowledge;
import org.springframework.web.bind.annotation.RequestBody;
public interface KnowledgeManageService {
IPage<Knowledge> queryKnowledgePage(Integer status,String title, String publishDeptName, Integer pageNum, Integer pageSize);
IPage<Knowledge> queryKnowledgePage(Integer status, String title, String publishDeptName, Integer pageNum, Integer pageSize);
void saveKnowledge(SaveKnowledgeReqVO reqVO);
void updateKnowledge(ModifyKnowledgeReqVO reqVO);
}

@ -0,0 +1,60 @@
package com.supervision.knowsub.service.impl;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.unit.DataSizeUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.supervision.knowsub.model.FileBlob;
import com.supervision.knowsub.model.FileInfo;
import com.supervision.knowsub.service.FileBlobService;
import com.supervision.knowsub.service.FileInfoService;
import com.supervision.knowsub.service.FileService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
@Service
@Slf4j
@RequiredArgsConstructor
public class FileServiceImpl implements FileService {
private final FileInfoService fileInfoService;
private final FileBlobService fileBlobService;
@Override
@Transactional(rollbackFor = Exception.class)
public String uploadFile(String fileName, byte[] fileBytes) {
log.info("{}:文件进行保存", fileName);
FileBlob fileBlob = new FileBlob();
fileBlob.setBlobByte(fileBytes);
fileBlob.insert();
FileInfo fileInfo = new FileInfo();
fileInfo.setFileName(fileName);
fileInfo.setFileSize(fileBytes.length);
fileInfo.setFileSizeStr(DataSizeUtil.format(fileBytes.length));
fileInfo.setFileType(FileUtil.getSuffix(fileName));
fileInfo.setFileBlobId(fileBlob.getId());
fileInfoService.save(fileInfo);
log.info("{}:文件保存成功", fileName);
return fileInfo.getId();
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteFileById(String fileId) {
FileInfo one = fileInfoService.lambdaQuery().eq(FileInfo::getId, fileId).one();
if (ObjectUtil.isNotEmpty(one)){
fileBlobService.removeById(one.getFileBlobId());
fileInfoService.removeById(fileId);
}
}
}

@ -1,15 +1,24 @@
package com.supervision.knowsub.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Assert;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.supervision.knowsub.service.KnowledgeManageService;
import com.supervision.knowsub.model.Knowledge;
import com.supervision.knowsub.service.KnowledgeService;
import com.supervision.knowsub.entity.vo.knowledge.KnowledgeLinkVO;
import com.supervision.knowsub.entity.vo.knowledge.ModifyKnowledgeReqVO;
import com.supervision.knowsub.entity.vo.knowledge.SaveKnowledgeReqVO;
import com.supervision.knowsub.enums.StatusEnum;
import com.supervision.knowsub.exception.BusinessException;
import com.supervision.knowsub.model.*;
import com.supervision.knowsub.service.*;
import com.supervision.knowsub.util.UserUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@Slf4j
@Service
@ -18,12 +27,171 @@ public class KnowledgeManageServiceImpl implements KnowledgeManageService {
private final KnowledgeService knowledgeService;
private final KnowledgeContextService knowledgeContextService;
private final KnowledgeBaseInfoService knowledgeBaseInfoService;
private final KnowledgeAttachmentService knowledgeAttachmentService;
private final KnowledgeLinkService knowledgeLinkService;
private final FileService fileService;
@Override
public IPage<Knowledge> queryKnowledgePage(Integer status, String title, String publishDeptName, Integer pageNum, Integer pageSize) {
return knowledgeService.lambdaQuery().eq(ObjectUtil.isNotEmpty(status), Knowledge::getStatus, status)
.like(StrUtil.isNotBlank(title), Knowledge::getTitle, title)
.like(StrUtil.isNotBlank(publishDeptName), Knowledge::getPublishDept, publishDeptName)
.page(new Page<>(pageNum, pageSize));
String userId = UserUtil.getUser().getId();
return knowledgeService.queryKnowledgePage(status, title, publishDeptName, userId, pageNum, pageSize);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void saveKnowledge(SaveKnowledgeReqVO reqVO) {
var context = new KnowledgeContext();
context.setContext(reqVO.getContent());
knowledgeContextService.save(context);
Knowledge knowledge = new Knowledge();
knowledge.setTitle(reqVO.getTitle());
knowledge.setContentId(context.getId());
// TODO 这里目前子库设置为空
knowledge.setBaseId(null);
knowledge.setPublishDept(reqVO.getPublishDept());
// 目前只有人工添加
knowledge.setKnowledgeFrom(1);
knowledge.setStatus(reqVO.getOperate() == 1 ? StatusEnum.DRAFT.getStatus() : StatusEnum.WAIT_APPROVAL.getStatus());
knowledge.setSubmittedDeptId(reqVO.getSubmittedDeptId());
if (1 == reqVO.getOperate()) {
knowledge.setDraftBelongUserId(reqVO.getUserId());
}
knowledgeService.save(knowledge);
// 保存知识的基本信息
KnowledgeBaseInfo baseInfo = reqVO.getKnowledgeBaseInfo();
baseInfo.setContextId(context.getId());
knowledgeBaseInfoService.save(baseInfo);
// 附件以及URL没添加
for (String fileId : reqVO.getFileIdList()) {
KnowledgeAttachment attachment = new KnowledgeAttachment();
attachment.setKnowledgeId(knowledge.getId());
attachment.setFileId(fileId);
knowledgeAttachmentService.save(attachment);
}
for (KnowledgeLinkVO knowLedgeLinkVO : reqVO.getLinkList()) {
KnowledgeLink knowledgeLink = new KnowledgeLink();
knowledgeLink.setLinkName(knowLedgeLinkVO.getLinkName());
knowledgeLink.setLinkUrl(knowLedgeLinkVO.getLinkUrl());
knowledgeLinkService.save(knowledgeLink);
}
// 这里需要进行判断,如果状态为2,说明要走流程
if (1 != reqVO.getOperate()) {
// TODO 这里需要走流程
}
}
/**
*
* @param reqVO
*/
@Override
public void updateKnowledge(ModifyKnowledgeReqVO reqVO) {
Knowledge knowledge = knowledgeService.getOptById(reqVO.getKnowledgeId()).orElseThrow(() -> new BusinessException("未找到知识"));
// 首先校验状态,草稿/已撤回/已失效/驳回,才能修改
Set<Integer> canModifyStatusSet = Set.of(StatusEnum.DRAFT.getStatus(), StatusEnum.RECALL.getStatus(), StatusEnum.INVALID.getStatus(),StatusEnum.REJECT.getStatus());
if (!canModifyStatusSet.contains(knowledge.getStatus())) {
throw new BusinessException("当前状态不支持修改");
}
// 找到对应的content
KnowledgeContext context = knowledgeContextService.getOptById(knowledge.getContentId()).orElse(KnowledgeContext.builder().id(reqVO.getKnowledgeId()).build());
context.updateById();
// 然后更新
knowledge.setTitle(reqVO.getTitle());
// TODO 这里目前子库设置为空
knowledge.setPublishDept(reqVO.getPublishDept());
knowledge.setSubmittedDeptId(reqVO.getSubmittedDeptId());
knowledge.setStatus(reqVO.getOperate() == 1 ? StatusEnum.DRAFT.getStatus() : StatusEnum.WAIT_APPROVAL.getStatus());
// 如果保存为草稿
if (1 == reqVO.getOperate()) {
knowledge.setDraftBelongUserId(reqVO.getUserId());
}
knowledgeService.updateById(knowledge);
// 更新基础信息
KnowledgeBaseInfo knowledgeBaseInfo = reqVO.getKnowledgeBaseInfo();
Assert.notBlank(knowledgeBaseInfo.getKnowledgeId(),"知识ID不能为空");
// 这里需要用SQL进行更新,不能用封装的updateById,因为前端某些字段可能变为空,用updateById不能让那个想为空的变成空
knowledgeBaseInfoService.lambdaUpdate()
.set(KnowledgeBaseInfo::getPolicyType,knowledgeBaseInfo.getPolicyType())
.set(KnowledgeBaseInfo::getTerritory,knowledgeBaseInfo.getTerritory())
.set(KnowledgeBaseInfo::getPublishScope,knowledgeBaseInfo.getPublishScope())
.set(KnowledgeBaseInfo::getKnowledgeTag,knowledgeBaseInfo.getKnowledgeTag())
.set(KnowledgeBaseInfo::getAutoLoseEffect,knowledgeBaseInfo.getAutoLoseEffect())
.set(KnowledgeBaseInfo::getExecTimeBegin,knowledgeBaseInfo.getExecTimeBegin())
.set(KnowledgeBaseInfo::getExecTimeEnd,knowledgeBaseInfo.getExecTimeEnd())
.set(KnowledgeBaseInfo::getTimeliness,knowledgeBaseInfo.getTimeliness())
.set(KnowledgeBaseInfo::getPublishDate,knowledgeBaseInfo.getPublishDate())
.eq(KnowledgeBaseInfo::getKnowledgeId,knowledgeBaseInfo.getKnowledgeId()).update();
// 有可能更新附件
updateKnowledgeFile(reqVO, knowledge);
// 有可能更新URL
updateKnowledgeLink(reqVO, knowledge);
// 这里需要进行判断,如果状态为2,说明要走流程
if (1 != reqVO.getOperate()) {
// TODO 这里需要走流程
}
}
private void updateKnowledgeLink(ModifyKnowledgeReqVO reqVO, Knowledge knowledge) {
// 直接删除原来的
knowledgeLinkService.lambdaUpdate().eq(KnowledgeLink::getKnowledgeId,knowledge.getId()).remove();
for (KnowledgeLinkVO knowLedgeLinkVO : reqVO.getLinkList()) {
KnowledgeLink knowledgeLink = new KnowledgeLink();
knowledgeLink.setLinkName(knowLedgeLinkVO.getLinkName());
knowledgeLink.setLinkUrl(knowLedgeLinkVO.getLinkUrl());
knowledgeLinkService.save(knowledgeLink);
}
}
private void updateKnowledgeFile(ModifyKnowledgeReqVO reqVO, Knowledge knowledge) {
// 获取数据库中的附件ID
List<KnowledgeAttachment> oldFileList = knowledgeAttachmentService.lambdaQuery().eq(KnowledgeAttachment::getKnowledgeId, knowledge.getId()).list();
if (CollUtil.isEmpty(reqVO.getFileIdList())){
if (CollUtil.isNotEmpty(oldFileList)){
knowledgeAttachmentService.lambdaUpdate().eq(KnowledgeAttachment::getKnowledgeId,knowledge.getId()).remove();
// 删除文件
for (KnowledgeAttachment knowledgeAttachment : oldFileList) {
fileService.deleteFileById(knowledgeAttachment.getFileId());
}
}
}else {
List<String> newFileIdList = reqVO.getFileIdList();
// 遍历旧的附件,如果新的附件列表中不包含,则删除
for (KnowledgeAttachment oldFile : oldFileList) {
if (!newFileIdList.contains(oldFile.getId())){
knowledgeAttachmentService.lambdaUpdate().eq(KnowledgeAttachment::getFileId,oldFile.getId()).remove();
fileService.deleteFileById(oldFile.getFileId());
}
}
List<String> oldFileIdList = oldFileList.stream().map(KnowledgeAttachment::getFileId).toList();
// 再添加新的附件
for (String fileId : reqVO.getFileIdList()) {
if (!oldFileIdList.contains(fileId)){
KnowledgeAttachment attachment = new KnowledgeAttachment();
attachment.setKnowledgeId(knowledge.getId());
attachment.setFileId(fileId);
knowledgeAttachmentService.save(attachment);
}
}
}
}
}

@ -0,0 +1,18 @@
package com.supervision.knowsub.mapper;
import com.supervision.knowsub.model.KnowledgeAttachment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author flevance
* @description ks_knowledge_attachment()Mapper
* @createDate 2024-06-25 09:57:08
* @Entity com.supervision.knowsub.model.KnowledgeAttachment
*/
public interface KnowledgeAttachmentMapper extends BaseMapper<KnowledgeAttachment> {
}

@ -0,0 +1,18 @@
package com.supervision.knowsub.mapper;
import com.supervision.knowsub.model.KnowledgeLink;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author flevance
* @description ks_knowledge_link(-)Mapper
* @createDate 2024-06-25 09:57:08
* @Entity com.supervision.knowsub.model.KnowledgeLink
*/
public interface KnowledgeLinkMapper extends BaseMapper<KnowledgeLink> {
}

@ -1,5 +1,7 @@
package com.supervision.knowsub.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.supervision.knowsub.model.Knowledge;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@ -11,6 +13,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface KnowledgeMapper extends BaseMapper<Knowledge> {
IPage<Knowledge> queryKnowledgePage(Integer status, String title, String publishDeptName,String userId, Page<Knowledge> page);
}

@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
/**
@ -13,7 +15,7 @@ import lombok.Data;
*/
@TableName(value ="ks_file_blob")
@Data
public class FileBlob implements Serializable {
public class FileBlob extends Model<FileBlob> implements Serializable {
/**
*
*/

@ -5,7 +5,10 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
/**
@ -28,13 +31,20 @@ public class FileInfo implements Serializable {
/**
*
*/
private String fileSize;
private Integer fileSize;
/**
*
*/
private String fileSizeStr;
/**
*
*/
private String fileType;
/**
* ID
*/

@ -10,9 +10,10 @@ import lombok.Data;
/**
*
*
* @TableName ks_knowledge
*/
@TableName(value ="ks_knowledge")
@TableName(value = "ks_knowledge")
@Data
@Schema(description = "知识库对象")
public class Knowledge implements Serializable {
@ -54,9 +55,9 @@ public class Knowledge implements Serializable {
private Integer knowledgeFrom;
/**
* 1稿 2 3 4 5 6
* 1稿 2 3 4 5 6
*/
@Schema(description = "流转状态 1草稿 2待审批 3驳回 4通过 5删除 6已失效")
@Schema(description = "流转状态 1草稿 2待审批 3驳回 4通过 5已失效 6已撤回")
private Integer status;
/**
@ -65,6 +66,9 @@ public class Knowledge implements Serializable {
@Schema(description = "报送部门ID")
private String submittedDeptId;
@Schema(description = "草稿归属人ID,注意,在发布之后或撤回之后应该及时修改")
private String draftBelongUserId;
/**
* ID
*/

@ -0,0 +1,56 @@
package com.supervision.knowsub.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Data;
/**
*
* @TableName ks_knowledge_attachment
*/
@TableName(value ="ks_knowledge_attachment")
@Data
public class KnowledgeAttachment implements Serializable {
/**
*
*/
@TableId
private String id;
/**
* ID
*/
private String knowledgeId;
/**
* ID(file_infoID)
*/
private String fileId;
/**
* ID
*/
private String createUserId;
/**
*
*/
private LocalDateTime createTime;
/**
* ID
*/
private String updateUserId;
/**
*
*/
private LocalDateTime updateTime;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.*;
import java.io.Serializable;
import java.util.Date;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
@ -21,64 +22,79 @@ public class KnowledgeBaseInfo implements Serializable {
@TableId
private String id;
@Schema(description = "知识ID")
private String knowledgeId;
/**
* ID
*/
@Schema(description = "内容ID")
private String contextId;
/**
* ID
*/
@Schema(description = "封面ID 暂时没规划")
private String coverId;
/**
*
* 1 2
*/
@Schema(description = "来源 1人工添加(默认) 2系统导入")
private String source;
/**
*
*/
@Schema(description = "所属地域")
private String territory;
/**
*
*/
@Schema(description = "发布时间")
private Date publishDate;
/**
* 1 2
*/
@Schema(description = "时效性 1长期有效 2临时有效")
private Integer timeliness;
/**
* 1
*/
@Schema(description = "到期自动失效 1到期自动失效")
private Integer autoLoseEffect;
/**
*
*/
@Schema(description = "执行期限开始")
private Date execTimeBegin;
/**
*
*/
@Schema(description = "执行期限结束")
private Date execTimeEnd;
/**
* ,,;
*/
@Schema(description = "知识标签,直接输入内容,暂时用;分割")
private String knowledgeTag;
/**
*
*/
@Schema(description = "政策类型")
private String policyType;
/**
* 1 2
*/
@Schema(description = "公开范围 1公开 2不公开")
private Integer publishScope;
/**

@ -4,7 +4,12 @@ import com.baomidou.mybatisplus.annotation.*;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
@ -12,7 +17,10 @@ import lombok.Data;
*/
@TableName(value ="ks_knowledge_context")
@Data
public class KnowledgeContext implements Serializable {
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class KnowledgeContext extends Model<KnowledgeContext> implements Serializable {
/**
*
*/

@ -0,0 +1,58 @@
package com.supervision.knowsub.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Data;
/**
* -
* @TableName ks_knowledge_link
*/
@TableName(value ="ks_knowledge_link")
@Data
public class KnowledgeLink implements Serializable {
/**
*
*/
@TableId
private String id;
private String knowledgeId;
/**
*
*/
private String linkName;
/**
*
*/
private String linkUrl;
/**
* ID
*/
private String createUserId;
/**
*
*/
private LocalDateTime createTime;
/**
* ID
*/
private String updateUserId;
/**
*
*/
private LocalDateTime updateTime;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,13 @@
package com.supervision.knowsub.service;
import com.supervision.knowsub.model.KnowledgeAttachment;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author flevance
* @description ks_knowledge_attachment()Service
* @createDate 2024-06-25 09:57:08
*/
public interface KnowledgeAttachmentService extends IService<KnowledgeAttachment> {
}

@ -0,0 +1,13 @@
package com.supervision.knowsub.service;
import com.supervision.knowsub.model.KnowledgeLink;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author flevance
* @description ks_knowledge_link(-)Service
* @createDate 2024-06-25 09:57:08
*/
public interface KnowledgeLinkService extends IService<KnowledgeLink> {
}

@ -1,5 +1,6 @@
package com.supervision.knowsub.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.supervision.knowsub.model.Knowledge;
import com.baomidou.mybatisplus.extension.service.IService;
@ -10,4 +11,15 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface KnowledgeService extends IService<Knowledge> {
/**
*
* @param status
* @param title ,
* @param publishDeptName ,
* @param pageNum pageNum
* @param pageSize pageSize
* @return IPage<Knowledge>
*/
IPage<Knowledge> queryKnowledgePage(Integer status, String title, String publishDeptName,String userId, Integer pageNum, Integer pageSize);
}

@ -0,0 +1,22 @@
package com.supervision.knowsub.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.supervision.knowsub.model.KnowledgeAttachment;
import com.supervision.knowsub.service.KnowledgeAttachmentService;
import com.supervision.knowsub.mapper.KnowledgeAttachmentMapper;
import org.springframework.stereotype.Service;
/**
* @author flevance
* @description ks_knowledge_attachment()Service
* @createDate 2024-06-25 09:57:08
*/
@Service
public class KnowledgeAttachmentServiceImpl extends ServiceImpl<KnowledgeAttachmentMapper, KnowledgeAttachment>
implements KnowledgeAttachmentService{
}

@ -0,0 +1,22 @@
package com.supervision.knowsub.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.supervision.knowsub.model.KnowledgeLink;
import com.supervision.knowsub.service.KnowledgeLinkService;
import com.supervision.knowsub.mapper.KnowledgeLinkMapper;
import org.springframework.stereotype.Service;
/**
* @author flevance
* @description ks_knowledge_link(-)Service
* @createDate 2024-06-25 09:57:08
*/
@Service
public class KnowledgeLinkServiceImpl extends ServiceImpl<KnowledgeLinkMapper, KnowledgeLink>
implements KnowledgeLinkService{
}

@ -1,5 +1,7 @@
package com.supervision.knowsub.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.supervision.knowsub.model.Knowledge;
import com.supervision.knowsub.service.KnowledgeService;
@ -7,14 +9,18 @@ import com.supervision.knowsub.mapper.KnowledgeMapper;
import org.springframework.stereotype.Service;
/**
* @author Administrator
* @description ks_knowledge()Service
* @createDate 2024-06-24 11:35:15
*/
* @author Administrator
* @description ks_knowledge()Service
* @createDate 2024-06-24 11:35:15
*/
@Service
public class KnowledgeServiceImpl extends ServiceImpl<KnowledgeMapper, Knowledge>
implements KnowledgeService{
implements KnowledgeService {
@Override
public IPage<Knowledge> queryKnowledgePage(Integer status, String title, String publishDeptName, String userId, Integer pageNum, Integer pageSize) {
return this.baseMapper.queryKnowledgePage(status, title, publishDeptName, userId, new Page<>(pageNum, pageSize));
}
}

@ -5,19 +5,21 @@
<mapper namespace="com.supervision.knowsub.mapper.FileInfoMapper">
<resultMap id="BaseResultMap" type="com.supervision.knowsub.model.FileInfo">
<result property="id" column="id" jdbcType="VARCHAR"/>
<result property="fileName" column="file_name" jdbcType="VARCHAR"/>
<result property="fileSize" column="file_size" jdbcType="VARCHAR"/>
<result property="fileType" column="file_type" jdbcType="VARCHAR"/>
<result property="fileBlobId" column="file_blob_id" jdbcType="VARCHAR"/>
<result property="createUserId" column="create_user_id" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateUserId" column="update_user_id" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="id" column="id" jdbcType="VARCHAR"/>
<result property="fileName" column="file_name" jdbcType="VARCHAR"/>
<result property="fileSize" column="file_size" jdbcType="BIGINT"/>
<result property="fileSizeStr" column="file_size_str" jdbcType="VARCHAR"/>
<result property="fileType" column="file_type" jdbcType="VARCHAR"/>
<result property="fileBlobId" column="file_blob_id" jdbcType="VARCHAR"/>
<result property="createUserId" column="create_user_id" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateUserId" column="update_user_id" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,file_name,file_size,
id
,file_name,file_size,file_size_str,
file_type,file_blob_id,create_user_id,
create_time,update_user_id,update_time
</sql>

@ -0,0 +1,22 @@
<?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.supervision.knowsub.mapper.KnowledgeAttachmentMapper">
<resultMap id="BaseResultMap" type="com.supervision.knowsub.model.KnowledgeAttachment">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="knowledgeId" column="knowledge_id" jdbcType="VARCHAR"/>
<result property="fileId" column="file_id" jdbcType="VARCHAR"/>
<result property="createUserId" column="create_user_id" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateUserId" column="update_user_id" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,knowledge_id,file_id,
create_user_id,create_time,update_user_id,
update_time
</sql>
</mapper>

@ -0,0 +1,24 @@
<?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.supervision.knowsub.mapper.KnowledgeLinkMapper">
<resultMap id="BaseResultMap" type="com.supervision.knowsub.model.KnowledgeLink">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="knowledgeId" column="knowledge_id" jdbcType="VARCHAR"/>
<result property="linkName" column="link_name" jdbcType="VARCHAR"/>
<result property="linkUrl" column="link_url" jdbcType="VARCHAR"/>
<result property="createUserId" column="create_user_id" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateUserId" column="update_user_id" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id
,link_name,link_url,
create_user_id,create_time,update_user_id,
update_time
</sql>
</mapper>

@ -5,24 +5,47 @@
<mapper namespace="com.supervision.knowsub.mapper.KnowledgeMapper">
<resultMap id="BaseResultMap" type="com.supervision.knowsub.model.Knowledge">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="title" column="title" jdbcType="VARCHAR"/>
<result property="contentId" column="content_id" jdbcType="VARCHAR"/>
<result property="baseId" column="base_id" jdbcType="VARCHAR"/>
<result property="publishDept" column="publish_dept_id" jdbcType="VARCHAR"/>
<result property="knowledgeFrom" column="knowledge_from" jdbcType="INTEGER"/>
<result property="status" column="status" jdbcType="INTEGER"/>
<result property="submittedDeptId" column="submitted_dept" jdbcType="VARCHAR"/>
<result property="createUserId" column="create_user_id" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateUserId" column="update_user_id" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="title" column="title" jdbcType="VARCHAR"/>
<result property="contentId" column="content_id" jdbcType="VARCHAR"/>
<result property="baseId" column="base_id" jdbcType="VARCHAR"/>
<result property="publishDept" column="publish_dept_id" jdbcType="VARCHAR"/>
<result property="knowledgeFrom" column="knowledge_from" jdbcType="INTEGER"/>
<result property="status" column="status" jdbcType="INTEGER"/>
<result property="submittedDeptId" column="submitted_dept" jdbcType="VARCHAR"/>
<result property="draftBelongUserId" column="draft_belong_user_id" jdbcType="VARCHAR"/>
<result property="createUserId" column="create_user_id" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateUserId" column="update_user_id" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,title,content_id,
id
,title,content_id,
base_id,publish_dept,knowledge_from,
status,submitted_dept_id,create_user_id,
create_time,update_user_id,update_time
</sql>
<select id="queryKnowledgePage" resultType="com.supervision.knowsub.model.Knowledge">
select
<include refid="Base_Column_List"/>
from ks_knowledge
<where>
-- 如果是null,则是全部,这时查询归属于自己的草稿,和其他非草稿的所有的
<if test="status == null">
and ( draft_belong_user_id = #{userId} or status != 1)
</if>
<if test="status != null">
and ( status = #{status} )
</if>
<if test="title != null and title != ''">
and title like concat('%',#{title},'%')
</if>
<if test="publishDeptName != null and publishDeptName != ''">
and publish_dept_id like concat('%',#{publishDeptName},'%')
</if>
</where>
order by create
</select>
</mapper>

Loading…
Cancel
Save