公共知识库开发
This commit is contained in:
parent
8c15c22455
commit
a789769764
@ -91,4 +91,6 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode TBUP_NOT_EXISTS = new ErrorCode( 1_009_019_000, "点赞不存在");
|
ErrorCode TBUP_NOT_EXISTS = new ErrorCode( 1_009_019_000, "点赞不存在");
|
||||||
// ========== 文件编辑 1_009_020_000 ==========
|
// ========== 文件编辑 1_009_020_000 ==========
|
||||||
ErrorCode ONLYOF_NOT_EXISTS = new ErrorCode(1_009_020_000 , "文件编辑不存在");
|
ErrorCode ONLYOF_NOT_EXISTS = new ErrorCode(1_009_020_000 , "文件编辑不存在");
|
||||||
|
// ========== 公共知识 1_009_021_000 ==========
|
||||||
|
ErrorCode KNOWLEDGE_PUBLIC_NOT_EXISTS = new ErrorCode(1_009_021_000, "公共知识不存在");
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,129 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.controller.admin.knows;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
//import cn.iocoder.yudao.module.bpm.convert.knows.KnowledgeConvert;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.knows.KnowledgePublicDO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.knows.KnowtypeDO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.service.knows.KnowtypeService;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
||||||
|
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.servlet.http.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.bpm.convert.knows.KnowledgePublicConvert;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.knows.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.knows.KnowledgePublicDO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.knows.CommentPublicDO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.service.knows.KnowledgePublicService;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 公共知识")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/bpm/knowledge-public")
|
||||||
|
@Validated
|
||||||
|
public class KnowledgePublicController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private KnowtypeService knowtypeService;
|
||||||
|
@Resource
|
||||||
|
private DeptService deptService;
|
||||||
|
@Resource
|
||||||
|
private KnowledgePublicService knowledgePublicService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建公共知识")
|
||||||
|
@PreAuthorize("@ss.hasPermission('bpm:knowledge-public:create')")
|
||||||
|
public CommonResult<Long> createKnowledgePublic(@Valid @RequestBody KnowledgePublicSaveReqVO createReqVO) {
|
||||||
|
return success(knowledgePublicService.createKnowledgePublic(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新公共知识")
|
||||||
|
@PreAuthorize("@ss.hasPermission('bpm:knowledge-public:update')")
|
||||||
|
public CommonResult<Boolean> updateKnowledgePublic(@Valid @RequestBody KnowledgePublicSaveReqVO updateReqVO) {
|
||||||
|
knowledgePublicService.updateKnowledgePublic(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除公共知识")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('bpm:knowledge-public:delete')")
|
||||||
|
public CommonResult<Boolean> deleteKnowledgePublic(@RequestParam("id") Long id) {
|
||||||
|
knowledgePublicService.deleteKnowledgePublic(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得公共知识")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('bpm:knowledge-public:query')")
|
||||||
|
public CommonResult<KnowledgePublicRespVO> getKnowledgePublic(@RequestParam("id") Long id) {
|
||||||
|
KnowledgePublicDO knowledgePublic = knowledgePublicService.getKnowledgePublic(id);
|
||||||
|
return success(BeanUtils.toBean(knowledgePublic, KnowledgePublicRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得公共知识分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('bpm:knowledge-public:query')")
|
||||||
|
public CommonResult<PageResult<KnowledgePublicRespVO>> getKnowledgePublicPage(@Valid KnowledgePublicPageReqVO pageReqVO) {
|
||||||
|
PageResult<KnowledgePublicDO> pageResult = knowledgePublicService.getKnowledgePublicPage(pageReqVO);
|
||||||
|
//return success(BeanUtils.toBean(pageResult, KnowledgePublicRespVO.class));
|
||||||
|
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||||
|
return success(new PageResult<>(pageResult.getTotal()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Long, DeptDO> deptMap = deptService.getDeptMap(convertList(pageResult.getList(), KnowledgePublicDO::getDeptId));
|
||||||
|
Map<Long, KnowtypeDO> knowTypeMap = knowtypeService.getKnowtypeMap(convertList(pageResult.getList(), KnowledgePublicDO::getTypeId));
|
||||||
|
// 转换并返回结果
|
||||||
|
return success(new PageResult<>(KnowledgePublicConvert.INSTANCE.convertList(pageResult.getList(), deptMap, knowTypeMap), pageResult.getTotal()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出公共知识 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('bpm:knowledge-public:export')")
|
||||||
|
@ApiAccessLog(operateType = EXPORT)
|
||||||
|
public void exportKnowledgePublicExcel(@Valid KnowledgePublicPageReqVO pageReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
List<KnowledgePublicDO> list = knowledgePublicService.getKnowledgePublicPage(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "公共知识.xls", "数据", KnowledgePublicRespVO.class,
|
||||||
|
BeanUtils.toBean(list, KnowledgePublicRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 子表(公告知识评论) ====================
|
||||||
|
|
||||||
|
@GetMapping("/comment-public/list-by-know-id")
|
||||||
|
@Operation(summary = "获得公告知识评论列表")
|
||||||
|
@Parameter(name = "knowId", description = "类型id")
|
||||||
|
@PreAuthorize("@ss.hasPermission('bpm:knowledge-public:query')")
|
||||||
|
public CommonResult<List<CommentPublicDO>> getCommentPublicListByKnowId(@RequestParam("knowId") Long knowId) {
|
||||||
|
return success(knowledgePublicService.getCommentPublicListByKnowId(knowId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.controller.admin.knows.vo;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 公共知识分页 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class KnowledgePublicPageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "作者", example = "芋艿")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
@Schema(description = "类型id", example = "19644")
|
||||||
|
private Long typeId;
|
||||||
|
|
||||||
|
@Schema(description = "部门id", example = "30380")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
@Schema(description = "知识标题")
|
||||||
|
private String knowTitle;
|
||||||
|
|
||||||
|
@Schema(description = "内容")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
@Schema(description = "知识状态", example = "0")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Schema(description = "文件路径")
|
||||||
|
private String filePath;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
|
@Schema(description = "流程实例的编号", example = "7315")
|
||||||
|
private String processInstanceId;
|
||||||
|
|
||||||
|
@Schema(description = "申请人的用户编号", example = "16518")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@Schema(description = "审批状态", example = "1")
|
||||||
|
private Integer flowStatus;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.controller.admin.knows.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.alibaba.excel.annotation.*;
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 公共知识 Response VO")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class KnowledgePublicRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "28653")
|
||||||
|
@ExcelProperty("id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "作者", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||||
|
@ExcelProperty("作者")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
@Schema(description = "类型id", example = "19644")
|
||||||
|
@ExcelProperty("类型id")
|
||||||
|
private Long typeId;
|
||||||
|
|
||||||
|
@Schema(description = "类型名称", example = "环境")
|
||||||
|
@ExcelProperty("类型名称")
|
||||||
|
private String typeName;
|
||||||
|
|
||||||
|
@Schema(description = "部门名称", example = "IT 部")
|
||||||
|
@ExcelProperty("部门名称")
|
||||||
|
private String deptName;
|
||||||
|
|
||||||
|
@Schema(description = "作者名称", example = "张三")
|
||||||
|
@ExcelProperty("作者名称")
|
||||||
|
private String nickName;
|
||||||
|
|
||||||
|
@Schema(description = "部门id", example = "30380")
|
||||||
|
@ExcelProperty("部门id")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
@Schema(description = "知识标题")
|
||||||
|
@ExcelProperty("知识标题")
|
||||||
|
private String knowTitle;
|
||||||
|
|
||||||
|
@Schema(description = "内容")
|
||||||
|
@ExcelProperty("内容")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
@Schema(description = "知识状态", example = "0")
|
||||||
|
@ExcelProperty(value = "知识状态", converter = DictConvert.class)
|
||||||
|
@DictFormat("common_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Schema(description = "文件路径")
|
||||||
|
@ExcelProperty("文件路径")
|
||||||
|
private String [] filePath;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@Schema(description = "流程实例的编号", example = "7315")
|
||||||
|
@ExcelProperty("流程实例的编号")
|
||||||
|
private String processInstanceId;
|
||||||
|
|
||||||
|
@Schema(description = "申请人的用户编号", example = "16518")
|
||||||
|
@ExcelProperty("申请人的用户编号")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@Schema(description = "审批状态", example = "1")
|
||||||
|
@ExcelProperty("审批状态")
|
||||||
|
private Integer flowStatus;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.controller.admin.knows.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.knows.CommentPublicDO;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 公共知识新增/修改 Request VO")
|
||||||
|
@Data
|
||||||
|
public class KnowledgePublicSaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "28653")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "作者", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||||
|
@NotEmpty(message = "作者不能为空")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
@Schema(description = "类型id", example = "19644")
|
||||||
|
private Long typeId;
|
||||||
|
|
||||||
|
@Schema(description = "部门id", example = "30380")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
@Schema(description = "知识标题")
|
||||||
|
private String knowTitle;
|
||||||
|
|
||||||
|
@Schema(description = "内容")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
@Schema(description = "知识状态", example = "0")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Schema(description = "文件路径")
|
||||||
|
private String [] filePath;
|
||||||
|
|
||||||
|
@Schema(description = "流程实例的编号", example = "7315")
|
||||||
|
private String processInstanceId;
|
||||||
|
|
||||||
|
@Schema(description = "申请人的用户编号", example = "16518")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@Schema(description = "审批状态", example = "1")
|
||||||
|
private Integer flowStatus;
|
||||||
|
|
||||||
|
@Schema(description = "公告知识评论列表")
|
||||||
|
private List<CommentPublicDO> commentPublics;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.convert.knows;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.knows.vo.KnowledgePublicRespVO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.knows.KnowledgePublicDO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.knows.KnowtypeDO;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface KnowledgePublicConvert {
|
||||||
|
KnowledgePublicConvert INSTANCE = Mappers.getMapper(KnowledgePublicConvert.class);
|
||||||
|
// default List<KnowledgeRespVO> convertList(List<KnowledgeDO> list, Map<Long, DeptDO> deptMap) {
|
||||||
|
// return CollectionUtils.convertList(list, konw -> convert(konw, deptMap.get(konw.getDeptId())));
|
||||||
|
// }
|
||||||
|
// 列表转换方法
|
||||||
|
// default List<KnowledgeRespVO> convertList(List<KnowledgeDO> list, Map<Long, DeptDO> deptMap, Map<Long, KnowtypeDO> knowTypeMap,Map<Long, AdminUserDO> userMap) {
|
||||||
|
// return list.stream().map(knowledgeDO -> {
|
||||||
|
// DeptDO deptDO = deptMap.get(knowledgeDO.getDeptId());
|
||||||
|
// KnowtypeDO knowtypeDO = knowTypeMap.get(knowledgeDO.getTypeId());
|
||||||
|
// AdminUserDO userDO = userMap.get(knowledgeDO.getUserid());
|
||||||
|
// return convert(knowledgeDO, deptDO, knowtypeDO,userDO);
|
||||||
|
// }).collect(Collectors.toList());
|
||||||
|
// }
|
||||||
|
default List<KnowledgePublicRespVO> convertList(List<KnowledgePublicDO> list, Map<Long, DeptDO> deptMap, Map<Long, KnowtypeDO> knowTypeMap) {
|
||||||
|
return list.stream().map(knowledgePublicDO -> {
|
||||||
|
DeptDO deptDO = deptMap.get(knowledgePublicDO.getDeptId());
|
||||||
|
KnowtypeDO knowtypeDO = knowTypeMap.get(knowledgePublicDO.getTypeId());
|
||||||
|
return convert(knowledgePublicDO, deptDO, knowtypeDO);
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
default KnowledgePublicRespVO convert(KnowledgePublicDO konw, DeptDO dept, KnowtypeDO knowtype) {
|
||||||
|
KnowledgePublicRespVO KnowledgePublicVO = BeanUtils.toBean(konw, KnowledgePublicRespVO.class);
|
||||||
|
if (dept != null) {
|
||||||
|
KnowledgePublicVO.setDeptName(dept.getName());
|
||||||
|
}
|
||||||
|
if (knowtype != null) {
|
||||||
|
KnowledgePublicVO.setTypeName(knowtype.getName());
|
||||||
|
}
|
||||||
|
return KnowledgePublicVO;
|
||||||
|
}
|
||||||
|
// default KnowledgeRespVO convert(KnowledgeDO konw, DeptDO dept, KnowtypeDO knowtype, AdminUserDO user) {
|
||||||
|
// KnowledgeRespVO KnowledgeVO = BeanUtils.toBean(konw, KnowledgeRespVO.class);
|
||||||
|
// if (dept != null) {
|
||||||
|
// KnowledgeVO.setDeptName(dept.getName());
|
||||||
|
// }
|
||||||
|
// if (knowtype != null) {
|
||||||
|
// KnowledgeVO.setTypeName(knowtype.getName());
|
||||||
|
// }
|
||||||
|
// if (user != null) {
|
||||||
|
// KnowledgeVO.setNickName(user.getNickname());
|
||||||
|
// }
|
||||||
|
// return KnowledgeVO;
|
||||||
|
// }
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.dal.dataobject.knows;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公告知识评论 DO
|
||||||
|
*
|
||||||
|
* @author 君风
|
||||||
|
*/
|
||||||
|
@TableName("des_comment_public")
|
||||||
|
@KeySequence("des_comment_public_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CommentPublicDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 类型id
|
||||||
|
*/
|
||||||
|
private Long knowId;
|
||||||
|
/**
|
||||||
|
* 内容
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.dal.dataobject.knows;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公共知识 DO
|
||||||
|
*
|
||||||
|
* @author 君风
|
||||||
|
*/
|
||||||
|
@TableName("des_knowledge_public")
|
||||||
|
@KeySequence("des_knowledge_public_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class KnowledgePublicDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 作者
|
||||||
|
*/
|
||||||
|
private String userName;
|
||||||
|
/**
|
||||||
|
* 类型id
|
||||||
|
*/
|
||||||
|
private Long typeId;
|
||||||
|
/**
|
||||||
|
* 部门id
|
||||||
|
*/
|
||||||
|
private Long deptId;
|
||||||
|
/**
|
||||||
|
* 知识标题
|
||||||
|
*/
|
||||||
|
private String knowTitle;
|
||||||
|
/**
|
||||||
|
* 内容
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
/**
|
||||||
|
* 知识状态
|
||||||
|
*
|
||||||
|
* 枚举 {@link TODO common_status 对应的类}
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
/**
|
||||||
|
* 文件路径
|
||||||
|
*/
|
||||||
|
private String filePath;
|
||||||
|
/**
|
||||||
|
* 流程实例的编号
|
||||||
|
*/
|
||||||
|
private String processInstanceId;
|
||||||
|
/**
|
||||||
|
* 申请人的用户编号
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 审批状态
|
||||||
|
*/
|
||||||
|
private Integer flowStatus;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.dal.mysql.knows;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.knows.CommentPublicDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公告知识评论 Mapper
|
||||||
|
*
|
||||||
|
* @author 君风
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface CommentPublicMapper extends BaseMapperX<CommentPublicDO> {
|
||||||
|
|
||||||
|
default List<CommentPublicDO> selectListByKnowId(Long knowId) {
|
||||||
|
return selectList(CommentPublicDO::getKnowId, knowId);
|
||||||
|
}
|
||||||
|
|
||||||
|
default int deleteByKnowId(Long knowId) {
|
||||||
|
return delete(CommentPublicDO::getKnowId, knowId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.dal.mysql.knows;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.knows.KnowledgePublicDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.knows.vo.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公共知识 Mapper
|
||||||
|
*
|
||||||
|
* @author 君风
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface KnowledgePublicMapper extends BaseMapperX<KnowledgePublicDO> {
|
||||||
|
|
||||||
|
default PageResult<KnowledgePublicDO> selectPage(KnowledgePublicPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<KnowledgePublicDO>()
|
||||||
|
.eqIfPresent(KnowledgePublicDO::getUserName, reqVO.getUserName())
|
||||||
|
.eqIfPresent(KnowledgePublicDO::getTypeId, reqVO.getTypeId())
|
||||||
|
.eqIfPresent(KnowledgePublicDO::getDeptId, reqVO.getDeptId())
|
||||||
|
.likeIfPresent(KnowledgePublicDO::getKnowTitle, reqVO.getKnowTitle())
|
||||||
|
.likeIfPresent(KnowledgePublicDO::getContent, reqVO.getContent())
|
||||||
|
.eqIfPresent(KnowledgePublicDO::getStatus, reqVO.getStatus())
|
||||||
|
.eqIfPresent(KnowledgePublicDO::getFilePath, reqVO.getFilePath())
|
||||||
|
.betweenIfPresent(KnowledgePublicDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.eqIfPresent(KnowledgePublicDO::getProcessInstanceId, reqVO.getProcessInstanceId())
|
||||||
|
.eqIfPresent(KnowledgePublicDO::getUserId, reqVO.getUserId())
|
||||||
|
.eqIfPresent(KnowledgePublicDO::getFlowStatus, reqVO.getFlowStatus())
|
||||||
|
.orderByDesc(KnowledgePublicDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.service.knows;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.knows.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.knows.KnowledgePublicDO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.knows.CommentPublicDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公共知识 Service 接口
|
||||||
|
*
|
||||||
|
* @author 君风
|
||||||
|
*/
|
||||||
|
public interface KnowledgePublicService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建公共知识
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long createKnowledgePublic(@Valid KnowledgePublicSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新公共知识
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateKnowledgePublic(@Valid KnowledgePublicSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除公共知识
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deleteKnowledgePublic(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得公共知识
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 公共知识
|
||||||
|
*/
|
||||||
|
KnowledgePublicDO getKnowledgePublic(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得公共知识分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 公共知识分页
|
||||||
|
*/
|
||||||
|
PageResult<KnowledgePublicDO> getKnowledgePublicPage(KnowledgePublicPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
// ==================== 子表(公告知识评论) ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得公告知识评论列表
|
||||||
|
*
|
||||||
|
* @param knowId 类型id
|
||||||
|
* @return 公告知识评论列表
|
||||||
|
*/
|
||||||
|
List<CommentPublicDO> getCommentPublicListByKnowId(Long knowId);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,112 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.service.knows;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.knows.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.knows.KnowledgePublicDO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.knows.CommentPublicDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.mysql.knows.KnowledgePublicMapper;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.mysql.knows.CommentPublicMapper;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公共知识 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 君风
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class KnowledgePublicServiceImpl implements KnowledgePublicService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private KnowledgePublicMapper knowledgePublicMapper;
|
||||||
|
@Resource
|
||||||
|
private CommentPublicMapper commentPublicMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Long createKnowledgePublic(KnowledgePublicSaveReqVO createReqVO) {
|
||||||
|
// 插入
|
||||||
|
KnowledgePublicDO knowledgePublic = BeanUtils.toBean(createReqVO, KnowledgePublicDO.class);
|
||||||
|
knowledgePublicMapper.insert(knowledgePublic);
|
||||||
|
|
||||||
|
// 插入子表
|
||||||
|
createCommentPublicList(knowledgePublic.getId(), createReqVO.getCommentPublics());
|
||||||
|
// 返回
|
||||||
|
return knowledgePublic.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void updateKnowledgePublic(KnowledgePublicSaveReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validateKnowledgePublicExists(updateReqVO.getId());
|
||||||
|
// 更新
|
||||||
|
KnowledgePublicDO updateObj = BeanUtils.toBean(updateReqVO, KnowledgePublicDO.class);
|
||||||
|
knowledgePublicMapper.updateById(updateObj);
|
||||||
|
|
||||||
|
// 更新子表
|
||||||
|
updateCommentPublicList(updateReqVO.getId(), updateReqVO.getCommentPublics());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void deleteKnowledgePublic(Long id) {
|
||||||
|
// 校验存在
|
||||||
|
validateKnowledgePublicExists(id);
|
||||||
|
// 删除
|
||||||
|
knowledgePublicMapper.deleteById(id);
|
||||||
|
|
||||||
|
// 删除子表
|
||||||
|
deleteCommentPublicByKnowId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateKnowledgePublicExists(Long id) {
|
||||||
|
if (knowledgePublicMapper.selectById(id) == null) {
|
||||||
|
throw exception(KNOWLEDGE_PUBLIC_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KnowledgePublicDO getKnowledgePublic(Long id) {
|
||||||
|
return knowledgePublicMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<KnowledgePublicDO> getKnowledgePublicPage(KnowledgePublicPageReqVO pageReqVO) {
|
||||||
|
return knowledgePublicMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 子表(公告知识评论) ====================
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CommentPublicDO> getCommentPublicListByKnowId(Long knowId) {
|
||||||
|
return commentPublicMapper.selectListByKnowId(knowId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createCommentPublicList(Long knowId, List<CommentPublicDO> list) {
|
||||||
|
list.forEach(o -> o.setKnowId(knowId));
|
||||||
|
commentPublicMapper.insertBatch(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCommentPublicList(Long knowId, List<CommentPublicDO> list) {
|
||||||
|
deleteCommentPublicByKnowId(knowId);
|
||||||
|
list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新
|
||||||
|
createCommentPublicList(knowId, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteCommentPublicByKnowId(Long knowId) {
|
||||||
|
commentPublicMapper.deleteByKnowId(knowId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -223,7 +223,7 @@ yudao:
|
|||||||
topic: ${spring.application.name}-websocket # 消息发送的 Kafka Topic
|
topic: ${spring.application.name}-websocket # 消息发送的 Kafka Topic
|
||||||
consumer-group: ${spring.application.name}-websocket-consumer # 消息发送的 Kafka Consumer Group
|
consumer-group: ${spring.application.name}-websocket-consumer # 消息发送的 Kafka Consumer Group
|
||||||
swagger:
|
swagger:
|
||||||
title: 芋道快速开发平台
|
title: 君凤科技快速开发平台
|
||||||
description: 提供管理后台、用户 App 的所有功能
|
description: 提供管理后台、用户 App 的所有功能
|
||||||
version: ${yudao.info.version}
|
version: ${yudao.info.version}
|
||||||
url: ${yudao.web.admin-ui.url}
|
url: ${yudao.web.admin-ui.url}
|
||||||
|
Loading…
Reference in New Issue
Block a user