Browse Source

作者:张哲
时间:2023/08/29
类型:优化
描述:问题3:维护人支持多选

zizg 1 year ago
parent
commit
7b394f7e44

+ 26 - 6
src/main/java/com/redxun/knowledge/album/service/AlbumCategoryServiceImpl.java

@@ -26,6 +26,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -102,7 +103,10 @@ public class AlbumCategoryServiceImpl extends SuperServiceImpl<AlbumCategoryMapp
                             albumCategoryVo2.setCreateByName(userService.queryUser(albumCategoryVo2.getCreateBy()).getFullName());
                         }
                         if (StringUtils.isNotEmpty(albumCategoryVo2.getMaintainer())){
-                            albumCategoryVo2.setMaintainerName(userService.queryUser(albumCategoryVo2.getMaintainer()).getFullName());
+                            String maintainerName = Arrays.stream(albumCategoryVo2.getMaintainer().split(",")).
+                                    map(maintainer -> userService.queryOsUserDto(maintainer).getFullName()).
+                                    collect(Collectors.joining(","));
+                            albumCategoryVo2.setMaintainerName(maintainerName);
                         }
                         allAlbumCategory1.add(albumCategoryVo2);
                     }
@@ -141,7 +145,10 @@ public class AlbumCategoryServiceImpl extends SuperServiceImpl<AlbumCategoryMapp
                     albumCategoryVo.setCreateByName(userService.queryUser(albumCategoryVo.getCreateBy()).getFullName());
                 }
                 if (StringUtils.isNotEmpty(albumCategoryVo.getMaintainer())){
-                    albumCategoryVo.setMaintainerName(userService.queryUser(albumCategoryVo.getMaintainer()).getFullName());
+                    String maintainerName = Arrays.stream(albumCategoryVo.getMaintainer().split(",")).
+                            map(maintainer -> userService.queryOsUserDto(maintainer).getFullName()).
+                            collect(Collectors.joining(","));
+                    albumCategoryVo.setMaintainerName(maintainerName);
                 }
                 albumCategoryVo.setIsPermission(permission(albumCategoryVo.getCreateBy(),albumCategoryVo.getMaintainer(),userId));
                 childrenIdList.add(albumCategoryVo.getPkId());
@@ -157,7 +164,10 @@ public class AlbumCategoryServiceImpl extends SuperServiceImpl<AlbumCategoryMapp
                 e.setCreateByName(userService.queryUser(e.getCreateBy()).getFullName());
             }
             if (StringUtils.isNotEmpty(e.getMaintainer())){
-                e.setMaintainerName(userService.queryUser(e.getMaintainer()).getFullName());
+                String maintainerName = Arrays.stream(e.getMaintainer().split(",")).
+                        map(maintainer -> userService.queryOsUserDto(maintainer).getFullName()).
+                        collect(Collectors.joining(","));
+                e.setMaintainerName(maintainerName);
             }
             e.setIsPermission(permission(e.getCreateBy(),e.getMaintainer(),userId));
         });
@@ -203,9 +213,14 @@ public class AlbumCategoryServiceImpl extends SuperServiceImpl<AlbumCategoryMapp
         AlbumCategory albumCategory = albumCategoryMapper.selectById(ids);
         //判断是否能进行修改(创建人或维护人满足一个即可修改)
         String userId = userService.queryLoginUser();
-        if (!userId.equals(albumCategory.getCreateBy()) && !userId.equals(albumCategory.getMaintainer())){
+        if (!userId.equals(albumCategory.getCreateBy())){
             throw new RuntimeException("您没有权限进行此操作");
         }
+        if (StringUtils.isNotEmpty(albumCategory.getMaintainer())){
+            if (!Arrays.asList(albumCategory.getMaintainer().split(",")).contains(userId)){
+                throw new RuntimeException("您没有权限进行此操作");
+            }
+        }
         List<AlbumInfo> albumInfoList = albumInfoMapper.
                 selectList(new QueryWrapper<AlbumInfo>().eq("CATEGORY_ID", ids));
         if (CollectionUtils.isNotEmpty(albumInfoList)) {
@@ -237,9 +252,14 @@ public class AlbumCategoryServiceImpl extends SuperServiceImpl<AlbumCategoryMapp
         }
         //判断是否能进行修改(创建人或维护人满足一个即可修改)
         String userId = userService.queryLoginUser();
-        if (!userId.equals(albumCategory.getCreateBy()) && !userId.equals(albumCategory.getMaintainer())){
+        if (!userId.equals(albumCategory.getCreateBy())){
             throw new RuntimeException("您没有权限进行此操作");
         }
+        if (StringUtils.isNotEmpty(albumCategory.getMaintainer())){
+            if (!Arrays.asList(albumCategory.getMaintainer().split(",")).contains(userId)){
+                throw new RuntimeException("您没有权限进行此操作");
+            }
+        }
         if (albumCategory.getParent().isEmpty()) {
             albumCategory.setParent("0");
         }
@@ -368,7 +388,7 @@ public class AlbumCategoryServiceImpl extends SuperServiceImpl<AlbumCategoryMapp
      * @return
      */
     private int permission(String createBy,String maintainer,String userId){
-        if (userId.equals(createBy) || userId.equals(maintainer)){
+        if (userId.equals(createBy) || (StringUtils.isNotEmpty(maintainer) && Arrays.asList(maintainer.split(",")).contains(userId))){
             return 0;
         } else {
             return 1;

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

@@ -516,10 +516,10 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
                 albumApproverNodeVo.setCreateByName(userService.queryUser(e.getCreateBy()).getFullName());
             }
             if (StringUtils.isNotEmpty(e.getMaintainer())){
-                JPaasUser jPaasUser = userService.queryUser(e.getMaintainer());
-                if (jPaasUser != null){
-                    albumApproverNodeVo.setMaintainerName(jPaasUser.getFullName());
-                }
+                String maintainerName = Arrays.stream(e.getMaintainer().split(",")).
+                        map(maintainer -> userService.queryOsUserDto(maintainer).getFullName()).
+                        collect(Collectors.joining(","));
+                albumApproverNodeVo.setMaintainerName(maintainerName);
             }
             return albumApproverNodeVo;
         }).collect(Collectors.toList());
@@ -541,10 +541,10 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
                 albumApproverNodeVo.setCreateByName(userService.queryUser(e.getCreateBy()).getFullName());
             }
             if (StringUtils.isNotEmpty(e.getMaintainer())){
-                JPaasUser jPaasUser = userService.queryUser(e.getMaintainer());
-                if (jPaasUser != null){
-                    albumApproverNodeVo.setMaintainerName(jPaasUser.getFullName());
-                }
+                String maintainerName = Arrays.stream(e.getMaintainer().split(",")).
+                        map(maintainer -> userService.queryOsUserDto(maintainer).getFullName()).
+                        collect(Collectors.joining(","));
+                albumApproverNodeVo.setMaintainerName(maintainerName);
             }
             return albumApproverNodeVo;
         }).collect(Collectors.toList());

+ 14 - 4
src/main/java/com/redxun/knowledge/analysis/controller/AnalysisCommonController.java

@@ -21,10 +21,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * 文件名: CommonController
@@ -357,4 +354,17 @@ public class AnalysisCommonController {
         List<KnowledgeSumAndYelpSumListVo> result = analysisCommonService.knowledgeSumAndYelpSumList(type,beginTime,endTime);
         return jsonResult.setData(result);
     }
+
+    @ApiOperation("员工行为页面返回左上角时间")
+    @GetMapping("getRoundTime")
+    public JsonResult getRoundTime(){
+        JsonResult jsonResult = JsonResult.getSuccessResult("");
+        Map<String,Object> result = new HashMap<>();
+        //获取当前年
+        Calendar calendar = Calendar.getInstance();
+        int year = calendar.get(Calendar.YEAR);
+        result.put("beginTime",DateUtils.format(DateUtils.getFirstOfYear(year)));
+        result.put("endTime",DateUtils.format(DateUtils.getLastOfYear(year)));
+        return jsonResult.setData(result);
+    }
 }

+ 11 - 4
src/main/java/com/redxun/knowledge/service/KnowledgeApprovalNodeServiceImpl.java

@@ -108,9 +108,14 @@ public class KnowledgeApprovalNodeServiceImpl extends SuperServiceImpl<Knowledge
             //判断是否能进行修改(创建人或维护人满足一个即可修改)
             KnowledgeApprovalNodeFlower knowledgeApprovalNodeFlower = knowledgeApprovalNodeFlowerMapper.selectById(knowledgeApprovalNodeFlowerDto.getPkId());
             String userId = userService.queryLoginUser();
-            if (!userId.equals(knowledgeApprovalNodeFlower.getCreateBy()) && !userId.equals(knowledgeApprovalNodeFlower.getMaintainer())){
+            if (!userId.equals(knowledgeApprovalNodeFlower.getCreateBy())){
                 throw new RuntimeException("您没有权限进行此操作");
             }
+            if (StringUtils.isNotEmpty(knowledgeApprovalNodeFlower.getMaintainer())){
+                if (!Arrays.asList(knowledgeApprovalNodeFlower.getMaintainer().split(",")).contains(userId)){
+                    throw new RuntimeException("您没有权限进行此操作");
+                }
+            }
             knowledgeApprovalNodeMapper.deleteByFlowerId(knowledgeApprovalNodeFlowerDto.getPkId());
             knowledgeApprovalNodeCategoryMapper.deleteByFlowerId(knowledgeApprovalNodeFlowerDto.getPkId());
         }
@@ -192,9 +197,11 @@ public class KnowledgeApprovalNodeServiceImpl extends SuperServiceImpl<Knowledge
                 }
             });
             e.setCreateByName(userService.queryUser(e.getCreateBy()).getFullName());
-            JPaasUser jPaasUser = userService.queryUser(e.getMaintainer());
-            if (jPaasUser != null){
-                e.setMaintainerName(jPaasUser.getFullName());
+            if (StringUtils.isNotEmpty(e.getMaintainer())){
+                String maintainerName = Arrays.stream(e.getMaintainer().split(",")).
+                        map(maintainer -> userService.queryOsUserDto(maintainer).getFullName()).
+                        collect(Collectors.joining(","));
+                e.setMaintainerName(maintainerName);
             }
             e.setCategoryName(category);
         });

+ 28 - 12
src/main/java/com/redxun/knowledge/service/KnowledgeCategoryServiceImpl.java

@@ -113,9 +113,11 @@ public class KnowledgeCategoryServiceImpl extends SuperServiceImpl<KnowledgeCate
                 e.setIsPermission(permission(e.getCreateBy(),e.getMaintainer(),userId));
                 e.setOperatorName(userService.queryUser(e.getUpdateBy()).getFullName());
                 e.setCreateByName(userService.queryUser(e.getCreateBy()).getFullName());
-                JPaasUser jPaasUser = userService.queryUser(e.getMaintainer());
-                if (jPaasUser != null){
-                    e.setMaintainerName(jPaasUser.getFullName());
+                if (StringUtils.isNotEmpty(e.getMaintainer())){
+                    String maintainerName = Arrays.stream(e.getMaintainer().split(",")).
+                            map(maintainer -> userService.queryOsUserDto(maintainer).getFullName()).
+                            collect(Collectors.joining(","));
+                    e.setMaintainerName(maintainerName);
                 }
                 List<KnowledgeCategoryAdminVo> childrens = findChildrens(e,userId);
                 if (childrens.size() == 0) {
@@ -141,9 +143,11 @@ public class KnowledgeCategoryServiceImpl extends SuperServiceImpl<KnowledgeCate
                 e.setIsPermission(permission(e.getCreateBy(),e.getMaintainer(),userId));
                 e.setOperatorName(userService.queryUser(e.getUpdateBy()).getFullName());
                 e.setCreateByName(userService.queryUser(e.getCreateBy()).getFullName());
-                JPaasUser jPaasUser = userService.queryUser(e.getMaintainer());
-                if (jPaasUser != null){
-                    e.setMaintainerName(jPaasUser.getFullName());
+                if (StringUtils.isNotEmpty(e.getMaintainer())){
+                    String maintainerName = Arrays.stream(e.getMaintainer().split(",")).
+                            map(maintainer -> userService.queryOsUserDto(maintainer).getFullName()).
+                            collect(Collectors.joining(","));
+                    e.setMaintainerName(maintainerName);
                 }
                 List<KnowledgeCategoryAdminVo> childrens = findChildrens(e,userId);
                 if (childrens.size() == 0) {
@@ -222,9 +226,14 @@ public class KnowledgeCategoryServiceImpl extends SuperServiceImpl<KnowledgeCate
         KnowledgeCategory knowledgeCategory = this.get(entity.getPkId());
         //判断是否能进行修改(创建人或维护人满足一个即可修改)
         String userId = userService.queryLoginUser();
-        if (!userId.equals(knowledgeCategory.getCreateBy()) && !userId.equals(knowledgeCategory.getMaintainer())){
+        if (!userId.equals(knowledgeCategory.getCreateBy())){
             throw new RuntimeException("您没有权限进行此操作");
         }
+        if (StringUtils.isNotEmpty(knowledgeCategory.getMaintainer())){
+            if (!Arrays.asList(knowledgeCategory.getMaintainer().split(",")).contains(userId)){
+                throw new RuntimeException("您没有权限进行此操作");
+            }
+        }
         if (knowledgeCategory.getIsSys() == 1) {
             throw new RuntimeException("系统内置节点,无法修改");
         }
@@ -282,9 +291,14 @@ public class KnowledgeCategoryServiceImpl extends SuperServiceImpl<KnowledgeCate
         KnowledgeCategory knowledgeCategory = this.baseMapper.selectById(knowledgeCategoryId);
         //判断是否能进行修改(创建人或维护人满足一个即可修改)
         String userId = userService.queryLoginUser();
-        if (!userId.equals(knowledgeCategory.getCreateBy()) && !userId.equals(knowledgeCategory.getMaintainer())){
+        if (!userId.equals(knowledgeCategory.getCreateBy())){
             throw new RuntimeException("您没有权限进行此操作");
         }
+        if (StringUtils.isNotEmpty(knowledgeCategory.getMaintainer())){
+            if (!Arrays.asList(knowledgeCategory.getMaintainer().split(",")).contains(userId)){
+                throw new RuntimeException("您没有权限进行此操作");
+            }
+        }
         // 查询该分类下是否还有知识
         Boolean hasKnowledge = hasKnowledge(knowledgeCategoryId);
         if (hasKnowledge) {
@@ -323,9 +337,11 @@ public class KnowledgeCategoryServiceImpl extends SuperServiceImpl<KnowledgeCate
                     e.setIsPermission(permission(e.getCreateBy(),e.getMaintainer(),userId));
                     e.setOperatorName(userService.queryUser(e.getUpdateBy()).getFullName());
                     e.setCreateByName(userService.queryUser(e.getCreateBy()).getFullName());
-                    JPaasUser jPaasUser = userService.queryUser(e.getMaintainer());
-                    if (jPaasUser != null){
-                        e.setMaintainerName(jPaasUser.getFullName());
+                    if (StringUtils.isNotEmpty(e.getMaintainer())){
+                        String maintainerName = Arrays.stream(e.getMaintainer().split(",")).
+                                map(maintainer -> userService.queryOsUserDto(maintainer).getFullName()).
+                                collect(Collectors.joining(","));
+                        e.setMaintainerName(maintainerName);
                     }
                     return e;
                 }).
@@ -451,7 +467,7 @@ public class KnowledgeCategoryServiceImpl extends SuperServiceImpl<KnowledgeCate
      */
     private int permission(String createBy,String maintainer,String userId){
         if (StringUtils.isNotEmpty(userId)){
-            if (userId.equals(createBy) || userId.equals(maintainer)){
+            if (userId.equals(createBy) || (StringUtils.isNotEmpty(maintainer) && Arrays.asList(maintainer.split(",")).contains(userId))){
                 return 0;
             } else {
                 return 1;

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

@@ -13,7 +13,7 @@
         <result property="createTime" column="CREATE_TIME_" jdbcType="DATE"/>
         <result property="updateBy" column="UPDATE_BY_" jdbcType="VARCHAR"/>
         <result property="updateTime" column="UPDATE_TIME_" jdbcType="DATE"/>
-        <result property="categoryId" column="CATEGORY_ID" jdbcType="VARCHAR"/>
+<!--        <result property="categoryId" column="CATEGORY_ID" jdbcType="VARCHAR"/>-->
     </resultMap>
 
     <sql id="COLUMNS">
@@ -62,7 +62,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 and (flower.CREATE_BY_ = #{userId} or MAINTAINER = #{userId})
+       where flower.IS_DEL = 0 and (flower.CREATE_BY_ = #{userId} or instr(MAINTAINER,#{userId}) > 0)
        order by flower.CREATE_TIME_,node.IS_FINAL,node.sort
     </select>
 

+ 1 - 1
src/main/resources/mapper/knowledge/album/AlbumApprovalNodeMapper.xml

@@ -55,7 +55,7 @@
 
     <select id="findAllAlbumApprovalNode" resultType="com.redxun.knowledge.album.entity.dao.AlbumApprovalNode">
         select * from KM_ALBUM_APPROVAL_NODE where IS_DEL = 0 and
-            (CREATE_BY_ = #{userId} or MAINTAINER = #{userId})
+            (CREATE_BY_ = #{userId} or instr(MAINTAINER,#{userId}) > 0)
     </select>
 
 </mapper>

+ 1 - 1
src/main/resources/mapper/knowledge/album/AlbumYelpApprovalNodeMapper.xml

@@ -44,7 +44,7 @@
 
     <select id="findAllAlbumApprovalNode" resultType="com.redxun.knowledge.album.entity.dao.AlbumYelpApprovalNode">
         select * from KM_ALBUM_YELP_APPROVAL_NODE where IS_DEL = 0 and
-            (CREATE_BY_ = #{userId} or MAINTAINER = #{userId})
+            (CREATE_BY_ = #{userId} or instr(MAINTAINER,#{userId}) > 0)
     </select>
 
 </mapper>