Răsfoiți Sursa

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

zizg 1 an în urmă
părinte
comite
49c6c3e285

+ 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;