Преглед изворни кода

作者:张哲
时间:2023/02/20
类型:优化
描述:里程碑(2)专辑优化

ZizgZh пре 2 година
родитељ
комит
1fc1db3648

+ 1 - 1
src/main/java/com/redxun/knowledge/album/entity/consts/AlbumConst.java

@@ -19,7 +19,7 @@ public class AlbumConst {
 
     public static final String APPROVAL_FAIL = "审核失败,存在已审核完成的记录!";
 
-    public static final String APPROVAL_FAIL_AUTHORITY = "审核失败,权限已变更,请从新提交!";
+    public static final String APPROVAL_FAIL_AUTHORITY = "审核失败,权限!";
 
     public static final String BATCH_APPROVAL_SUCCESS = "添加成功!";
 

+ 3 - 0
src/main/java/com/redxun/knowledge/album/entity/vo/AlbumInfoVo.java

@@ -101,4 +101,7 @@ public class AlbumInfoVo implements Serializable {
     @ApiModelProperty("负责人头像")
     private String ownerPhoto;
 
+    @ApiModelProperty("专辑负责人id")
+    private String ownerId;
+
 }

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

@@ -237,7 +237,9 @@ public class AlbumApproveServiceImpl extends SuperServiceImpl<AlbumApproveMapper
             }
         }
         if ("1".equals(type)){
-            Page pageResult = PageListUtils.getPages(queryFilter.getPage().getCurrent(), queryFilter.getPage().getSize(), albumApproveListVos);
+            List<AlbumApproveListVo> result = albumApproveListVos.stream().
+                    sorted((t1, t2) -> t2.getCreateTime().compareTo(t1.getCreateTime())).collect(Collectors.toList());
+            Page pageResult = PageListUtils.getPages(queryFilter.getPage().getCurrent(), queryFilter.getPage().getSize(), result);
             return pageResult;
         } else {
             //获取当前登录人的userId和deptId
@@ -254,7 +256,9 @@ public class AlbumApproveServiceImpl extends SuperServiceImpl<AlbumApproveMapper
                     albumApproveListVo1.add(albumApproveListVo);
                 }
             });
-            Page pageResult = PageListUtils.getPages(queryFilter.getPage().getCurrent(), queryFilter.getPage().getSize(),albumApproveListVo1);
+            List<AlbumApproveListVo> result = albumApproveListVo1.stream().
+                    sorted((t1, t2) -> t2.getCreateTime().compareTo(t1.getCreateTime())).collect(Collectors.toList());
+            Page pageResult = PageListUtils.getPages(queryFilter.getPage().getCurrent(), queryFilter.getPage().getSize(),result);
             return pageResult;
         }
     }

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

@@ -86,7 +86,7 @@ public class AlbumCategoryServiceImpl extends SuperServiceImpl<AlbumCategoryMapp
             //一级分类信息
             List<AlbumCategoryVo> allAlbumCategory1 = albumCategoryMapper.findAllAlbumCategory1(queryFilter.getParams(), params);
             if (CollectionUtils.isEmpty(allAlbumCategory1)){
-                return null;
+                return page;
             }
             List<String> childIdList = findChild(allAlbumCategory1, true);
             //查询符合条件的二级分类

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

@@ -177,6 +177,11 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
                     }
                     List<AlbumInfo> collect = ownerIdsList.stream().distinct().collect(Collectors.toList());
                     List<AlbumInfoVo> albumInfoVoListResult = pageInfo(collect);
+                    //不是我创建的专辑(状态设置为2 已发布)
+                    albumInfoVoListResult.stream().filter(e -> !e.getOwnerId().equals(userId)).forEach(h -> {
+                        h.setVersionState(2);
+                        h.setVersionStateName(AlbumVersionEnum.getMessage(2));
+                    });
                     Page page2 = PageListUtils.getPages(queryFilter.getPage().getCurrent(), queryFilter.getPage().getSize(), albumInfoVoListResult);
                     return page2;
                 case "3":
@@ -315,6 +320,7 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
      * @return
      */
     public AlbumInfoDetailVo detail(String pkId) {
+        String userId = userService.queryLoginUser();
         AlbumInfoDetailVo albumInfoDetailVo = new AlbumInfoDetailVo();
         AlbumInfo albumInfo = albumInfoMapper.selectById(pkId);
         BeanUtils.copyProperties(albumInfo, albumInfoDetailVo);
@@ -360,11 +366,11 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
         //专辑详情动作标记
         long count = albumVersions.stream().filter(e -> e.getState() == 2).count();
         List<String> actionFlag = new ArrayList<>();
-        if (albumInfo.getState() == 1 && count > 0) {
+        if (albumInfo.getState() == 1 && count > 0 && albumInfo.getOwnerId().equals(userId)) {
             actionFlag.add("edit");
             actionFlag.add("transfer");
             actionFlag.add("close");
-        } else if (albumInfo.getState() == 0 && count > 0) {
+        } else if (albumInfo.getState() == 0 && count > 0 && albumInfo.getOwnerId().equals(userId)) {
             actionFlag.add("edit");
             actionFlag.add("transfer");
             actionFlag.add("open");
@@ -529,8 +535,10 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
         } else {
             AlbumCategory albumCategoryParent = albumCategoryMapper.
                     selectOne(new LambdaQueryWrapper<AlbumCategory>().eq(AlbumCategory::getPkId, albumCategory.getParent()));
-            albumInfoDetailPcVo.setCategoryLevel2Id(albumCategoryParent.getPkId());
-            albumInfoDetailPcVo.setCategoryLevel2(albumCategoryParent.getName());
+            albumInfoDetailPcVo.setCategoryLevel1Id(albumCategoryParent.getPkId());
+            albumInfoDetailPcVo.setCategoryLevel1(albumCategoryParent.getName());
+            albumInfoDetailPcVo.setCategoryLevel2Id(albumCategory.getPkId());
+            albumInfoDetailPcVo.setCategoryLevel2(albumCategory.getName());
         }
         //判断登录人是否是专辑所属人(是 查看审核中的版本(没有审核中的,查看已发布的) 不是 查看已发布的版本)
         String userId = userService.queryLoginUser();
@@ -563,7 +571,9 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
             albumInfoDetailPcVo.setShowStatus(1);
             albumInfoDetailPcVo.setOwnerId(albumInfo.getOwnerId());
             List<String> actionFlag = new ArrayList<>();
-            actionFlag.add("edit");
+            if (albumInfoDetailPcVo.getVersionState() != 1) {
+                actionFlag.add("edit");
+            }
             albumInfoDetailPcVo.setActionFlag(actionFlag);
         } else {
             //不是专辑所属人,查看已发布的版本信息
@@ -707,7 +717,7 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
             albumApprove.setIsFinal(albumApprovalNode.getIsFinal());
             albumApprove.setUpdateBy(userService.queryLoginUser());
             albumApprove.setName(albumApprovalNode.getName());
-            if(CollectionUtils.isNotEmpty(albumApproveListBatch)){
+            if (CollectionUtils.isNotEmpty(albumApproveListBatch)) {
                 albumApprove.setApprovalBatch(albumApproveListBatch.get(0).getApprovalBatch() + 1);
             }
             return albumApprove;

+ 52 - 48
src/main/java/com/redxun/knowledge/map/service/MapServiceImpl.java

@@ -218,30 +218,32 @@ public class MapServiceImpl extends SuperServiceImpl<MapMapper, Map> implements
                         BeanUtils.copyProperties(mapContent, mapContentVo);
                         if (mapContent.getKnowledgeId() != null) {
                             Knowledge knowledge = knowledgeService.get(mapContent.getKnowledgeId());
-                            String photo = (String) userService.querySexAndPhoto(knowledge.getCreateBy()).get("photo");
-                            mapContentVo.setAuthorHead(photo);
-                            mapContentVo.setTitles(knowledge.getTitles());
-                            mapContentVo.setSummary(knowledge.getSummary());
-                            mapContentVo.setAuthor(knowledge.getAuthor());
-                            mapContentVo.setCreateTime(knowledge.getCreateTime());
-                            mapContentVo.setViews(knowledge.getViews());
-                            // 有文件,截取文件名后缀
-                            String attachmentName = knowledge.getAttachmentName();
-                            if (attachmentName != null){
-                                String[] strArray = attachmentName.split("\\.");
-                                int suffixIndex = strArray.length - 1;
-                                mapContentVo.setAttachmentType(strArray[suffixIndex]);
-                            }
-                            //添加分类信息
-                            KnowledgeCategoryAdminVo knowledgeCategoryAdminVo = knowledgeCategoryService.findAllParentByCategoryId(knowledge.getCategoryId());
-                            String name3 = knowledgeCategoryAdminVo.getName();
-                            mapContentVo.setCategory(name3);
-                            if (knowledgeCategoryAdminVo.getParents() != null){
-                                String name2 = knowledgeCategoryAdminVo.getParents().getName();
-                                mapContentVo.setCategory(name2 + " " + name3);
-                                if (knowledgeCategoryAdminVo.getParents().getParents() != null){
-                                    String name1 = knowledgeCategoryAdminVo.getParents().getParents().getName();
-                                    mapContentVo.setCategory(name1 + " " +name2 + " " + name3);
+                            if (knowledge != null) {
+                                String photo = (String) userService.querySexAndPhoto(knowledge.getCreateBy()).get("photo");
+                                mapContentVo.setAuthorHead(photo);
+                                mapContentVo.setTitles(knowledge.getTitles());
+                                mapContentVo.setSummary(knowledge.getSummary());
+                                mapContentVo.setAuthor(knowledge.getAuthor());
+                                mapContentVo.setCreateTime(knowledge.getCreateTime());
+                                mapContentVo.setViews(knowledge.getViews());
+                                // 有文件,截取文件名后缀
+                                String attachmentName = knowledge.getAttachmentName();
+                                if (attachmentName != null){
+                                    String[] strArray = attachmentName.split("\\.");
+                                    int suffixIndex = strArray.length - 1;
+                                    mapContentVo.setAttachmentType(strArray[suffixIndex]);
+                                }
+                                //添加分类信息
+                                KnowledgeCategoryAdminVo knowledgeCategoryAdminVo = knowledgeCategoryService.findAllParentByCategoryId(knowledge.getCategoryId());
+                                String name3 = knowledgeCategoryAdminVo.getName();
+                                mapContentVo.setCategory(name3);
+                                if (knowledgeCategoryAdminVo.getParents() != null){
+                                    String name2 = knowledgeCategoryAdminVo.getParents().getName();
+                                    mapContentVo.setCategory(name2 + " " + name3);
+                                    if (knowledgeCategoryAdminVo.getParents().getParents() != null){
+                                        String name1 = knowledgeCategoryAdminVo.getParents().getParents().getName();
+                                        mapContentVo.setCategory(name1 + " " +name2 + " " + name3);
+                                    }
                                 }
                             }
                         }
@@ -372,30 +374,32 @@ public class MapServiceImpl extends SuperServiceImpl<MapMapper, Map> implements
                                 //查看知识
                                 if (content.getKnowledgeId() != null) {
                                     Knowledge knowledge = knowledgeService.get(content.getKnowledgeId());
-                                    String photo = (String) userService.querySexAndPhoto(knowledge.getCreateBy()).get("photo");
-                                    content.setAuthorHead(photo);
-                                    content.setTitles(knowledge.getTitles());
-                                    content.setSummary(knowledge.getSummary());
-                                    content.setAuthor(knowledge.getAuthor());
-                                    content.setCreateTime(knowledge.getCreateTime());
-                                    content.setViews(knowledge.getViews());
-                                    // 有文件,截取文件名后缀
-                                    String attachmentName = knowledge.getAttachmentName();
-                                    if (attachmentName != null){
-                                        String[] strArray = attachmentName.split("\\.");
-                                        int suffixIndex = strArray.length - 1;
-                                        content.setAttachmentType(strArray[suffixIndex]);
-                                    }
-                                    //添加分类信息
-                                    KnowledgeCategoryAdminVo knowledgeCategoryAdminVo = knowledgeCategoryService.findAllParentByCategoryId(knowledge.getCategoryId());
-                                    String name3 = knowledgeCategoryAdminVo.getName();
-                                    content.setCategory(name3);
-                                    if (knowledgeCategoryAdminVo.getParents() != null){
-                                        String name2 = knowledgeCategoryAdminVo.getParents().getName();
-                                        content.setCategory(name2 + " " + name3);
-                                        if (knowledgeCategoryAdminVo.getParents().getParents() != null){
-                                            String name1 = knowledgeCategoryAdminVo.getParents().getParents().getName();
-                                            content.setCategory(name1 + " " +name2 + " " + name3);
+                                    if (knowledge != null) {
+                                        String photo = (String) userService.querySexAndPhoto(knowledge.getCreateBy()).get("photo");
+                                        content.setAuthorHead(photo);
+                                        content.setTitles(knowledge.getTitles());
+                                        content.setSummary(knowledge.getSummary());
+                                        content.setAuthor(knowledge.getAuthor());
+                                        content.setCreateTime(knowledge.getCreateTime());
+                                        content.setViews(knowledge.getViews());
+                                        // 有文件,截取文件名后缀
+                                        String attachmentName = knowledge.getAttachmentName();
+                                        if (attachmentName != null){
+                                            String[] strArray = attachmentName.split("\\.");
+                                            int suffixIndex = strArray.length - 1;
+                                            content.setAttachmentType(strArray[suffixIndex]);
+                                        }
+                                        //添加分类信息
+                                        KnowledgeCategoryAdminVo knowledgeCategoryAdminVo = knowledgeCategoryService.findAllParentByCategoryId(knowledge.getCategoryId());
+                                        String name3 = knowledgeCategoryAdminVo.getName();
+                                        content.setCategory(name3);
+                                        if (knowledgeCategoryAdminVo.getParents() != null){
+                                            String name2 = knowledgeCategoryAdminVo.getParents().getName();
+                                            content.setCategory(name2 + " " + name3);
+                                            if (knowledgeCategoryAdminVo.getParents().getParents() != null){
+                                                String name1 = knowledgeCategoryAdminVo.getParents().getParents().getName();
+                                                content.setCategory(name1 + " " +name2 + " " + name3);
+                                            }
                                         }
                                     }
                                 }