浏览代码

作者:张哲
时间:2023/08/18
类型:修改
描述:3.知识仓库分类和审核流程增加维护人功能

zizg 1 年之前
父节点
当前提交
40dc42462c

+ 3 - 0
src/main/java/com/redxun/knowledge/entity/dao/KnowledgeApprovalNodeFlower.java

@@ -41,6 +41,9 @@ public class KnowledgeApprovalNodeFlower extends BaseExtEntity<String> {
     @TableField(value = "IS_DEL")
     @TableLogic
     private Integer isDel;
+    //维护人
+    @TableField(value = "MAINTAINER")
+    private String maintainer;
 
     @Override
     public String getPkId() {

+ 3 - 0
src/main/java/com/redxun/knowledge/entity/dao/KnowledgeCategory.java

@@ -51,6 +51,9 @@ public class KnowledgeCategory extends BaseExtEntity<java.lang.String> {
     @TableField(value = "IS_DEL")
     @TableLogic
     private Integer isDel;
+    //维护人
+    @TableField(value = "MAINTAINER")
+    private String maintainer;
 
     @Override
     public String getPkId() {

+ 2 - 0
src/main/java/com/redxun/knowledge/entity/dto/KnowledgeApprovalNodeFlowerDto.java

@@ -35,6 +35,8 @@ public class KnowledgeApprovalNodeFlowerDto {
     private Set<String> categoryId;
 
     private List<KnowledgeApprovalNodeDto> knowledgeApprovalNode;
+    //维护人
+    private String maintainer;
 }
 
 

+ 1 - 1
src/main/java/com/redxun/knowledge/mapper/KnowledgeApprovalNodeFlowerMapper.java

@@ -27,7 +27,7 @@ public interface KnowledgeApprovalNodeFlowerMapper extends BaseMapper<KnowledgeA
      * 查询全部节点
      * @return
      */
-    List<KnowledgeApprovalNodeFlowerVo> findAllNodes();
+    List<KnowledgeApprovalNodeFlowerVo> findAllNodes(@Param("userId") String userId);
 
     /**
      * pc端查询审核流程

+ 1 - 1
src/main/java/com/redxun/knowledge/mapper/KnowledgeCategoryMapper.java

@@ -20,7 +20,7 @@ public interface KnowledgeCategoryMapper extends BaseDao<KnowledgeCategory> {
     IPage findAllKnowledgeCategory(IPage page, @Param("params") Map<String, Object> params, @Param("w") Map<String, Object> order);
 
     // 查询孩子节点,递归
-    List<KnowledgeCategoryAdminVo> selectKnowledgeCategoryByParent(String pkId);
+    List<KnowledgeCategoryAdminVo> selectKnowledgeCategoryByParent(@Param("pkId") String pkId,@Param("userId") String userId);
 
     KnowledgeCategoryAdminVo selectByCategoryId(String categoryId);
 

+ 9 - 1
src/main/java/com/redxun/knowledge/service/KnowledgeApprovalNodeServiceImpl.java

@@ -18,6 +18,7 @@ import com.redxun.knowledge.entity.vo.KnowledgeApprovalNodeFlowerVo;
 import com.redxun.knowledge.entity.vo.KnowledgeApprovalNodeVo;
 import com.redxun.knowledge.entity.vo.KnowledgeApprovalVo;
 import com.redxun.knowledge.mapper.*;
+import lombok.SneakyThrows;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -103,6 +104,12 @@ public class KnowledgeApprovalNodeServiceImpl extends SuperServiceImpl<Knowledge
     public String insertApprovalNodes(KnowledgeApprovalNodeFlowerDto knowledgeApprovalNodeFlowerDto) throws Exception {
         //修改(清除原本数据)
         if (StringUtils.isNotEmpty(knowledgeApprovalNodeFlowerDto.getPkId())) {
+            //判断是否能进行修改(创建人或维护人满足一个即可修改)
+            KnowledgeApprovalNodeFlower knowledgeApprovalNodeFlower = knowledgeApprovalNodeFlowerMapper.selectById(knowledgeApprovalNodeFlowerDto.getPkId());
+            String userId = userService.queryLoginUser();
+            if (!userId.equals(knowledgeApprovalNodeFlower.getCreateBy()) && !userId.equals(knowledgeApprovalNodeFlower.getMaintainer())){
+                throw new RuntimeException("您没有权限进行此操作");
+            }
             knowledgeApprovalNodeMapper.deleteByFlowerId(knowledgeApprovalNodeFlowerDto.getPkId());
             knowledgeApprovalNodeCategoryMapper.deleteByFlowerId(knowledgeApprovalNodeFlowerDto.getPkId());
         }
@@ -169,7 +176,8 @@ public class KnowledgeApprovalNodeServiceImpl extends SuperServiceImpl<Knowledge
      * @return
      */
     public List<KnowledgeApprovalNodeFlowerVo> findAllNodes() {
-        List<KnowledgeApprovalNodeFlowerVo> result = knowledgeApprovalNodeFlowerMapper.findAllNodes();
+        String userId = userService.queryLoginUser();
+        List<KnowledgeApprovalNodeFlowerVo> result = knowledgeApprovalNodeFlowerMapper.findAllNodes(userId);
         result.forEach(e -> {
             if (flowerName.equals(e.getFlowerName())) {
                 e.setCategory(new ArrayList<>());

+ 9 - 7
src/main/java/com/redxun/knowledge/service/KnowledgeCategoryServiceImpl.java

@@ -82,7 +82,7 @@ public class KnowledgeCategoryServiceImpl extends SuperServiceImpl<KnowledgeCate
         if (knowledgeCategory != null) {
             BeanUtils.copyProperties(knowledgeCategory, knowledgeCategoryAdminVo);
         }
-        List<KnowledgeCategoryAdminVo> childrens = findChildrens(knowledgeCategoryAdminVo);
+        List<KnowledgeCategoryAdminVo> childrens = findChildrens(knowledgeCategoryAdminVo,null);
         knowledgeCategoryAdminVo.setChildren(childrens);
         return knowledgeCategoryAdminVo;
     }
@@ -95,6 +95,8 @@ public class KnowledgeCategoryServiceImpl extends SuperServiceImpl<KnowledgeCate
      */
     public IPage findAllKnowledgeCategory(QueryFilter filter) {
         Map<String, Object> params = PageHelper.constructParams(filter);
+        String userId = userService.queryLoginUser();
+        filter.getParams().put("userId",userId);
         IPage page = knowledgeCategoryMapper.findAllKnowledgeCategory(filter.getPage(), filter.getParams(), params);
         List<KnowledgeCategoryAdminVo> knowledgeCategoryList = page.getRecords();
         // 如果有name参数,特殊处理
@@ -105,7 +107,7 @@ public class KnowledgeCategoryServiceImpl extends SuperServiceImpl<KnowledgeCate
             knowledgeCategoryList.forEach(e -> {
                 e.setLevel(1);
                 e.setOperatorName(userService.queryUser(e.getUpdateBy()).getFullName());
-                List<KnowledgeCategoryAdminVo> childrens = findChildrens(e);
+                List<KnowledgeCategoryAdminVo> childrens = findChildrens(e,userId);
                 if (childrens.size() == 0) {
                     e.setChildren(null);
                 } else {
@@ -125,7 +127,7 @@ public class KnowledgeCategoryServiceImpl extends SuperServiceImpl<KnowledgeCate
             knowledgeCategoryList.forEach(e -> {
                 e.setLevel(1);
                 e.setOperatorName(userService.queryUser(e.getUpdateBy()).getFullName());
-                List<KnowledgeCategoryAdminVo> childrens = findChildrens(e);
+                List<KnowledgeCategoryAdminVo> childrens = findChildrens(e,userId);
                 if (childrens.size() == 0) {
                     e.setChildren(null);
                 } else {
@@ -282,8 +284,8 @@ public class KnowledgeCategoryServiceImpl extends SuperServiceImpl<KnowledgeCate
     }
 
     // 查询孩子节点(递归)
-    public List<KnowledgeCategoryAdminVo> findChildrens(KnowledgeCategoryAdminVo knowledgeCategoryAdminVo) {
-        List<KnowledgeCategoryAdminVo> knowledgeCategorieChild = knowledgeCategoryMapper.selectKnowledgeCategoryByParent(knowledgeCategoryAdminVo.getPkId());
+    public List<KnowledgeCategoryAdminVo> findChildrens(KnowledgeCategoryAdminVo knowledgeCategoryAdminVo,String userId) {
+        List<KnowledgeCategoryAdminVo> knowledgeCategorieChild = knowledgeCategoryMapper.selectKnowledgeCategoryByParent(knowledgeCategoryAdminVo.getPkId(),userId);
         List<KnowledgeCategoryAdminVo> knowledgeCategories = knowledgeCategorieChild.stream().
                 sorted(Comparator.comparingInt(KnowledgeCategoryAdminVo::getSort)).
                 map(e -> {
@@ -294,7 +296,7 @@ public class KnowledgeCategoryServiceImpl extends SuperServiceImpl<KnowledgeCate
         knowledgeCategoryAdminVo.setChildren(knowledgeCategories);
         knowledgeCategories.forEach(e -> {
             e.setLevel(knowledgeCategoryAdminVo.getLevel() + 1);
-            List<KnowledgeCategoryAdminVo> allChildren = findChildrens(e);
+            List<KnowledgeCategoryAdminVo> allChildren = findChildrens(e,userId);
             if (allChildren.size() == 0) {
                 e.setChildren(null);
             } else {
@@ -390,7 +392,7 @@ public class KnowledgeCategoryServiceImpl extends SuperServiceImpl<KnowledgeCate
         // 查询其孩子节点
         collect.forEach(e -> {
             e.setLevel(1);
-            List<KnowledgeCategoryAdminVo> childrens = findChildrens(e);
+            List<KnowledgeCategoryAdminVo> childrens = findChildrens(e,null);
             e.setChildren(childrens);
         });
         return collect;

+ 1 - 1
src/main/resources/mapper/knowledge/KnowledgeApprovalNodeFlowerMapper.xml

@@ -58,7 +58,7 @@
                  left join KM_KNOWLEDGE_APPROVAL_NODE node
                            on flower.PK_ID = node.FLOWER_ID and node.IS_DEL = 0
                  left join KM_KNOWLEDGE_APPROVAL_NODE_CATEGORY category on flower.PK_ID = category.FLOWER_ID and category.IS_DEL = 0
-       where flower.IS_DEL = 0
+       where flower.IS_DEL = 0 and (flower.CREATE_BY_ = #{userId} or MAINTAINER = #{userId})
        order by flower.CREATE_TIME_,node.IS_FINAL,node.sort
     </select>
 

+ 5 - 2
src/main/resources/mapper/knowledge/KnowledgeCategoryMapper.xml

@@ -47,10 +47,10 @@
         FROM KM_KNOWLEDGE_CATEGORY
         <where>
             <if test="@rx.Ognl@isNotEmpty(params.name)">
-                and instr(NAME,#{params.name}) > 0
+                and instr(NAME,#{params.name}) > 0 and (CREATE_BY_ = #{params.userId} or MAINTAINER = #{params.userId})
             </if>
             <if test="@rx.Ognl@isEmpty(params.name)">
-                and IS_DEL = 0 and PARENT = 0
+                and IS_DEL = 0 and PARENT = 0 and (CREATE_BY_ = #{params.userId} or MAINTAINER = #{params.userId})
             </if>
 
         </where>
@@ -63,6 +63,9 @@
         FROM KM_KNOWLEDGE_CATEGORY
         <where>
             IS_DEL = 0 and PARENT = #{pkId}
+            <if test="userId != null">
+                and (CREATE_BY_ = #{userId} or MAINTAINER = #{userId})
+            </if>
         </where>
     </select>