瀏覽代碼

作者:张哲
时间:2023/03/02
类型:优化
描述:里程碑(2)知识地图:不显示外部系统内容问题

ZizgZh 2 年之前
父節點
當前提交
91eb2f9e50

+ 3 - 0
src/main/java/com/redxun/knowledge/map/entity/dao/MapContent.java

@@ -65,6 +65,9 @@ public class MapContent  extends BaseExtEntity<String> {
     @TableLogic
     private Integer isDel;
 
+    @TableField(exist = false)
+    private Integer knowledgeIsDel;
+
 
 
     @Override

+ 4 - 1
src/main/java/com/redxun/knowledge/map/service/MapRouteServiceImpl.java

@@ -75,7 +75,10 @@ public class MapRouteServiceImpl extends SuperServiceImpl<MapRouteMapper, MapRou
         String userId = userService.queryLoginUser();
         if (mapService.hasRole(map.getPkId())) {
             List<MapContent> mapContentList = mapContentMapper.findAllMapContent(routeId);
-            List<MapContentVo> result = mapContentList.stream().limit(tops).map(mapContent -> {
+            //过滤掉知识ID不为空且知识被删除的数据
+            List<MapContent> collect = mapContentList.stream().
+                    filter(e -> !(e.getKnowledgeId() != null && e.getKnowledgeIsDel() == null)).collect(Collectors.toList());
+            List<MapContentVo> result = collect.stream().limit(tops).map(mapContent -> {
                 MapContentVo mapContentVo = new MapContentVo();
                 BeanUtils.copyProperties(mapContent, mapContentVo);
                 Knowledge knowledge = knowledgeMapper.selectById(mapContent.getKnowledgeId());

+ 10 - 4
src/main/java/com/redxun/knowledge/map/service/MapServiceImpl.java

@@ -213,8 +213,11 @@ public class MapServiceImpl extends SuperServiceImpl<MapMapper, Map> implements
             mapVo.setRoutes(mapRouteVoList);
             mapRouteVoList.forEach(mapRouteVo -> {
                 List<MapContent> mapContentList = mapContentMapper.findAllMapContent(mapRouteVo.getPkId());
-                if (!CollectionUtils.isEmpty(mapContentList)) {
-                    List<MapContentVo> mapContentVoList = mapContentList.stream().map(mapContent -> {
+                //过滤掉知识ID不为空且知识被删除的数据
+                List<MapContent> collect = mapContentList.stream().
+                        filter(e -> !(e.getKnowledgeId() != null && e.getKnowledgeIsDel() == null)).collect(Collectors.toList());
+                if (!CollectionUtils.isEmpty(collect)) {
+                    List<MapContentVo> mapContentVoList = collect.stream().map(mapContent -> {
                         MapContentVo mapContentVo = new MapContentVo();
                         BeanUtils.copyProperties(mapContent, mapContentVo);
                         if (mapContent.getKnowledgeId() != null) {
@@ -373,8 +376,11 @@ public class MapServiceImpl extends SuperServiceImpl<MapMapper, Map> implements
                     //设置学习路径状态
                     route.setState(0);
                     List<MapContent> contentList = mapContentMapper.findAllMapContent(route.getPkId());
-                    if (!CollectionUtils.isEmpty(contentList)){
-                        List<MapContentVo> contents = contentList.parallelStream().map(mapContent -> {
+                    //过滤掉知识ID不为空且知识被删除的数据
+                    List<MapContent> collect = contentList.stream().
+                            filter(e -> !(e.getKnowledgeId() != null && e.getKnowledgeIsDel() == null)).collect(Collectors.toList());
+                    if (!CollectionUtils.isEmpty(collect)){
+                        List<MapContentVo> contents = collect.parallelStream().map(mapContent -> {
                             MapContentVo content = new MapContentVo();
                             BeanUtils.copyProperties(mapContent, content);
                             //查看知识

+ 2 - 2
src/main/resources/mapper/knowledge/map/MapContentMapper.xml

@@ -62,9 +62,9 @@
     </delete>
 
     <select id="findAllMapContent" resultType="com.redxun.knowledge.map.entity.dao.MapContent">
-        select mc.*
+        select mc.*,k.IS_DEL as knowledgeIsDel
         from KM_MAP_CONTENT mc
-                 join KM_KNOWLEDGE k
+                left join KM_KNOWLEDGE k
                       on mc.KNOWLEDGE_ID = k.PK_ID and k.IS_DEL = 0
         where mc.IS_DEL = 0 and ROUTE_ID = #{routeId}
         order by mc.SORT