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

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

ZizgZh пре 2 година
родитељ
комит
8312b95df7

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

@@ -1,7 +1,5 @@
 package com.redxun.knowledge.album.service;
 
-import cn.hutool.core.util.PageUtil;
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -21,7 +19,6 @@ import com.redxun.knowledge.album.mapper.AlbumCategoryMapper;
 import com.redxun.knowledge.album.mapper.AlbumInfoMapper;
 import com.redxun.knowledge.common.UserService;
 import com.redxun.knowledge.utils.PageListUtils;
-import org.apache.xalan.xsltc.compiler.util.NamedMethodGenerator;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;

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

@@ -707,7 +707,9 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
             albumApprove.setIsFinal(albumApprovalNode.getIsFinal());
             albumApprove.setUpdateBy(userService.queryLoginUser());
             albumApprove.setName(albumApprovalNode.getName());
-            albumApprove.setApprovalBatch(albumApproveListBatch.get(0).getApprovalBatch() + 1);
+            if(CollectionUtils.isNotEmpty(albumApproveListBatch)){
+                albumApprove.setApprovalBatch(albumApproveListBatch.get(0).getApprovalBatch() + 1);
+            }
             return albumApprove;
         }).collect(Collectors.toList());
         //批量添加

+ 2 - 1
src/main/java/com/redxun/knowledge/map/entity/vo/KnowledgeVo.java

@@ -11,6 +11,7 @@ import org.springframework.format.annotation.DateTimeFormat;
 
 import java.io.Serializable;
 import java.util.Date;
+import java.util.List;
 
 /**
  * 文件名: KnowledgeVo
@@ -28,7 +29,7 @@ public class KnowledgeVo implements Serializable {
     private String pkId;
 
     //知识分类
-    private String category;
+    private List<String> category;
 
     //知识名称
     private String titles;

+ 14 - 6
src/main/java/com/redxun/knowledge/map/service/MapServiceImpl.java

@@ -28,7 +28,6 @@ import com.redxun.knowledge.service.CommonServiceImpl;
 import com.redxun.knowledge.service.KnowledgeCategoryServiceImpl;
 import com.redxun.knowledge.service.KnowledgeServiceImpl;
 import org.apache.commons.lang.StringUtils;
-import org.owasp.esapi.util.CollectionsUtil;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -40,6 +39,7 @@ import java.io.Serializable;
 import java.util.*;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
 /**
@@ -124,25 +124,29 @@ public class MapServiceImpl extends SuperServiceImpl<MapMapper, Map> implements
             mapContentMapper.deleteBatchIds(Arrays.asList(mapById.getPkId()));
             mapLearningMapper.deleteBatchIds(Arrays.asList(mapById.getPkId()));
             List<MapRouteDto> routes = mapDto.getRoutes();
+            //排序处理
+            AtomicInteger sortRoute = new AtomicInteger(1);
             routes.forEach(route -> {
                 MapRoute mapRoute = new MapRoute();
                 BeanUtils.copyProperties(route, mapRoute);
                 mapRoute.setPkId(IdGenerator.getIdStr());
                 mapRoute.setMapId(mapById.getPkId());
                 mapRoute.setUpdateBy(userService.queryLoginUser());
+                mapRoute.setSort(sortRoute.getAndIncrement());
                 mapRouteMapper.insert(mapRoute);
                 MapRoute mapRouteById = mapRouteMapper.selectById(mapRoute.getPkId());
                 // 向学习内容表中添加数据
                 if (!CollectionUtils.isEmpty(route.getContents())) {
-                    mapContentMapper.deleteBatchIds(Arrays.asList(mapById.getPkId()));
-                    mapLearningMapper.deleteBatchIds(Arrays.asList(mapById.getPkId()));
                     List<MapContentDto> contents = route.getContents();
+                    //排序处理
+                    AtomicInteger sortMapContent = new AtomicInteger(1);
                     contents.forEach(content -> {
                         MapContent mapContent = new MapContent();
                         BeanUtils.copyProperties(content, mapContent);
                         mapContent.setPkId(IdGenerator.getIdStr());
                         mapContent.setMapId(mapRouteById.getMapId());
                         mapContent.setRouteId(mapRouteById.getPkId());
+                        mapContent.setSort(sortMapContent.getAndIncrement());
                         mapContent.setUpdateBy(userService.queryLoginUser());
                         mapContentMapper.insert(mapContent);
                     });
@@ -510,15 +514,19 @@ public class MapServiceImpl extends SuperServiceImpl<MapMapper, Map> implements
             knowledgeVo.setAttachmentType(strArray[suffixIndex]);
         }
         //添加分类信息
+        List<String> category = new ArrayList<>();
         KnowledgeCategoryAdminVo knowledgeCategoryAdminVo = knowledgeCategoryService.findAllParentByCategoryId(knowledge.getCategoryId());
         String name3 = knowledgeCategoryAdminVo.getName();
-        knowledgeVo.setCategory(name3);
+        category.add(name3);
+        knowledgeVo.setCategory(category);
         if (knowledgeCategoryAdminVo.getParents() != null){
             String name2 = knowledgeCategoryAdminVo.getParents().getName();
-            knowledgeVo.setCategory(name2 + " " + name3);
+            category.add(0,name2);
+            knowledgeVo.setCategory(category);
             if (knowledgeCategoryAdminVo.getParents().getParents() != null){
                 String name1 = knowledgeCategoryAdminVo.getParents().getParents().getName();
-                knowledgeVo.setCategory(name1 + " " +name2 + " " + name3);
+                category.add(0,name1);
+                knowledgeVo.setCategory(category);
             }
         }
         return knowledgeVo;