Răsfoiți Sursa

修复获取文章时,标签为null报错的问题

fangzhen 6 luni în urmă
părinte
comite
0ba21bf326

+ 20 - 17
ruoyi-generator/src/main/java/com/ruoyi/generator/service/CommunityArticleServiceImpl.java

@@ -366,26 +366,29 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
             List<CommunityArticleTag> articleTags = communityArticleTagMapper.selectList(new QueryWrapper<CommunityArticleTag>().eq("article_id", articleVo.getId()));
             List<Long> tagList = articleTags.stream().map(CommunityArticleTag::getTagId).collect(Collectors.toList());
             List<Long> tagIds = new ArrayList<>();
-            //判断当前标签是否被当前登录用户拉黑
-            List<CommunityTagBlock> communityTagBlocks = communityTagBlockMapper.selectList(new QueryWrapper<CommunityTagBlock>()
-                    .in("tag_id", tagList)
-                    .eq("user_id", userId));
-
-            for (CommunityTagBlock tagBlock : communityTagBlocks) {
-                if (tagBlock.isBlock()) {
-                    communityArticleVos.remove(articleVo);
-                    break;
+
+            if (!tagList.isEmpty()) {
+                //判断当前标签是否被当前登录用户拉黑
+                List<CommunityTagBlock> communityTagBlocks = communityTagBlockMapper.selectList(new QueryWrapper<CommunityTagBlock>()
+                        .in("tag_id", tagList)
+                        .eq("user_id", userId));
+
+                for (CommunityTagBlock tagBlock : communityTagBlocks) {
+                    if (tagBlock.isBlock()) {
+                        communityArticleVos.remove(articleVo);
+                        break;
+                    }
+                    tagIds.add(tagBlock.getTagId());
                 }
-                tagIds.add(tagBlock.getTagId());
-            }
 
-            if (communityTagBlocks.isEmpty()) {
-                tagIds.addAll(tagList);
-            }
+                if (communityTagBlocks.isEmpty()) {
+                    tagIds.addAll(tagList);
+                }
 
-            if (!tagIds.isEmpty()) {
-                List<CommunityTag> communityTags = communityTagMapper.selectBatchIds(tagIds);
-                articleVo.setTags(communityTags);
+                if (!tagIds.isEmpty()) {
+                    List<CommunityTag> communityTags = communityTagMapper.selectBatchIds(tagIds);
+                    articleVo.setTags(communityTags);
+                }
             }
         }
         return communityArticleVos;