소스 검색

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

zizg 1 년 전
부모
커밋
49c6c3e285
1개의 변경된 파일11개의 추가작업 그리고 2개의 파일을 삭제
  1. 11 2
      src/main/java/com/redxun/knowledge/service/KnowledgeCategoryServiceImpl.java

+ 11 - 2
src/main/java/com/redxun/knowledge/service/KnowledgeCategoryServiceImpl.java

@@ -198,6 +198,11 @@ public class KnowledgeCategoryServiceImpl extends SuperServiceImpl<KnowledgeCate
     @CacheEvict(value = {"knowledgeCategory","knowledgeCategoryPc"}, allEntries=true,cacheManager = "redisCacheManager")
     public int update(KnowledgeCategory entity) {
         KnowledgeCategory knowledgeCategory = this.get(entity.getPkId());
+        //判断是否能进行修改(创建人或维护人满足一个即可修改)
+        String userId = userService.queryLoginUser();
+        if (!userId.equals(knowledgeCategory.getCreateBy()) && !userId.equals(knowledgeCategory.getMaintainer())){
+            throw new RuntimeException("您没有权限进行此操作");
+        }
         if (knowledgeCategory.getIsSys() == 1) {
             throw new RuntimeException("系统内置节点,无法修改");
         }
@@ -252,14 +257,18 @@ public class KnowledgeCategoryServiceImpl extends SuperServiceImpl<KnowledgeCate
     @Transactional(rollbackFor = Exception.class)
     @CacheEvict(value = {"knowledgeCategory","knowledgeCategoryPc"}, allEntries=true,cacheManager = "redisCacheManager")
     public Integer deleteKnowledgeCategory(String knowledgeCategoryId) {
-
+        KnowledgeCategory knowledgeCategory = this.baseMapper.selectById(knowledgeCategoryId);
+        //判断是否能进行修改(创建人或维护人满足一个即可修改)
+        String userId = userService.queryLoginUser();
+        if (!userId.equals(knowledgeCategory.getCreateBy()) && !userId.equals(knowledgeCategory.getMaintainer())){
+            throw new RuntimeException("您没有权限进行此操作");
+        }
         // 查询该分类下是否还有知识
         Boolean hasKnowledge = hasKnowledge(knowledgeCategoryId);
         if (hasKnowledge) {
             return 0;
         }
         // 查询该分类的下是否还有子分类
-        KnowledgeCategory knowledgeCategory = this.baseMapper.selectById(knowledgeCategoryId);
         Boolean hasChirld = findHasChirld(knowledgeCategory);
         if (hasChirld) {
             return 1;