Prechádzať zdrojové kódy

作者:张哲
时间:2023/09/07
类型:优化
描述:知识、专辑分类及审核流程管理员最大权限

zizg 1 rok pred
rodič
commit
082e7d5213

+ 9 - 3
src/main/java/com/redxun/knowledge/album/service/AlbumCategoryServiceImpl.java

@@ -398,10 +398,16 @@ public class AlbumCategoryServiceImpl extends SuperServiceImpl<AlbumCategoryMapp
      * @return
      */
     private int permission(String createBy,String maintainer,String userId){
-        if (userId.equals(createBy) || (StringUtils.isNotEmpty(maintainer) && Arrays.asList(maintainer.split(",")).contains(userId))){
-            return 0;
+        if (StringUtils.isNotEmpty(userId)) {
+            if (userId.equals(createBy) ||
+                    (StringUtils.isNotEmpty(maintainer) && Arrays.asList(maintainer.split(",")).contains(userId)) ||
+                    userId.equals("1")){
+                return 0;
+            } else {
+                return 1;
+            }
         } else {
-            return 1;
+            return 2;
         }
 
     }

+ 6 - 2
src/main/java/com/redxun/knowledge/album/service/AlbumInfoServiceImpl.java

@@ -508,7 +508,9 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
     public List<AlbumApproverNodeVo> approveFlowsAlbumApprovalNode() {
         String userId = userService.queryLoginUser();
         List<AlbumApprovalNode> albumApprovalNodeList = albumApprovalNodeService.findAllAlbumApprovalNode(userId);
-        albumApprovalNodeList = albumApprovalNodeList.stream().filter(h -> userId.equals(h.getCreateBy()) || (StringUtils.isNotEmpty(h.getMaintainer()) && Arrays.asList(h.getMaintainer().split(",")).contains(userId))).collect(Collectors.toList());
+        if (!"1".equals(userId)){
+            albumApprovalNodeList = albumApprovalNodeList.stream().filter(h -> userId.equals(h.getCreateBy()) || (StringUtils.isNotEmpty(h.getMaintainer()) && Arrays.asList(h.getMaintainer().split(",")).contains(userId))).collect(Collectors.toList());
+        }
         List<AlbumApproverNodeVo> collect = albumApprovalNodeList.parallelStream().map(e -> {
             AlbumApproverNodeVo albumApproverNodeVo = new AlbumApproverNodeVo();
             BeanUtils.copyProperties(e, albumApproverNodeVo);
@@ -534,7 +536,9 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
     public List<AlbumApproverNodeVo> approveFlowsAlbumYelpApprovalNode() {
         String userId = userService.queryLoginUser();
         List<AlbumYelpApprovalNode> albumYelpApprovalNodeList = albumYelpApprovalNodeService.findAllAlbumApprovalNode(userId);
-        albumYelpApprovalNodeList = albumYelpApprovalNodeList.stream().filter(h -> userId.equals(h.getCreateBy()) || (StringUtils.isNotEmpty(h.getMaintainer()) && Arrays.asList(h.getMaintainer().split(",")).contains(userId))).collect(Collectors.toList());
+        if (!"1".equals(userId)){
+            albumYelpApprovalNodeList = albumYelpApprovalNodeList.stream().filter(h -> userId.equals(h.getCreateBy()) || (StringUtils.isNotEmpty(h.getMaintainer()) && Arrays.asList(h.getMaintainer().split(",")).contains(userId))).collect(Collectors.toList());
+        }
         List<AlbumApproverNodeVo> collect = albumYelpApprovalNodeList.parallelStream().map(e -> {
             AlbumApproverNodeVo albumApproverNodeVo = new AlbumApproverNodeVo();
             BeanUtils.copyProperties(e, albumApproverNodeVo);

+ 6 - 3
src/main/java/com/redxun/knowledge/service/KnowledgeApprovalNodeServiceImpl.java

@@ -188,9 +188,12 @@ public class KnowledgeApprovalNodeServiceImpl extends SuperServiceImpl<Knowledge
     public List<KnowledgeApprovalNodeFlowerVo> findAllNodes() {
         String userId = userService.queryLoginUser();
         List<KnowledgeApprovalNodeFlowerVo> result = knowledgeApprovalNodeFlowerMapper.findAllNodes(userId);
-        result = result.stream().
-                filter(h -> userId.equals(h.getCreateBy()) || (StringUtils.isNotEmpty(h.getMaintainer()) && Arrays.asList(h.getMaintainer().split(",")).contains(userId))).
-                collect(Collectors.toList());
+        //if not admin
+        if (!"1".equals(userId)){
+            result = result.stream().
+                    filter(h -> userId.equals(h.getCreateBy()) || (StringUtils.isNotEmpty(h.getMaintainer()) && Arrays.asList(h.getMaintainer().split(",")).contains(userId))).
+                    collect(Collectors.toList());
+        }
         result.forEach(e -> {
             if (flowerName.equals(e.getFlowerName())) {
                 e.setCategory(new ArrayList<>());

+ 3 - 1
src/main/java/com/redxun/knowledge/service/KnowledgeCategoryServiceImpl.java

@@ -471,7 +471,9 @@ public class KnowledgeCategoryServiceImpl extends SuperServiceImpl<KnowledgeCate
      */
     private int permission(String createBy,String maintainer,String userId){
         if (StringUtils.isNotEmpty(userId)){
-            if (userId.equals(createBy) || (StringUtils.isNotEmpty(maintainer) && Arrays.asList(maintainer.split(",")).contains(userId))){
+            if (userId.equals(createBy) ||
+                    (StringUtils.isNotEmpty(maintainer) && Arrays.asList(maintainer.split(",")).contains(userId)) ||
+                    userId.equals("1")){
                 return 0;
             } else {
                 return 1;