提交知识管理代码
parent
7b9d194a5b
commit
28babec162
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -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_info表ID)
|
||||
*/
|
||||
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;
|
||||
}
|
@ -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> {
|
||||
|
||||
}
|
@ -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{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -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>
|
Loading…
Reference in New Issue