Ver Fonte

新增查询是否有合集按钮

fangqing há 4 meses atrás
pai
commit
0a1070e4ba

+ 8 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/Community/CommunityArticle.java

@@ -170,4 +170,12 @@ public class CommunityArticle implements Serializable {
      */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date updateTime;
+
+
+    /**
+     * 文章是否有合集
+     */
+    @ApiModelProperty("文章是否有合集")
+    @TableField(exist = false)
+    private Integer noCollection;
 }

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

@@ -131,6 +131,7 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
         Long id = communityArticle.getId();
         List<Long> articleIds = communityArticle.getArticleIds();
         Integer pageTagType = communityArticle.getPageTagType();
+        Integer noCollection = communityArticle.getNoCollection();
         if (pageTagType != null && pageTagType == 1) {
             List<CommunityUserLikeVo> communityUserLikeVos = selectCommunityUserLikeList(SecurityUtils.getUserId(), null, 1, 999999, 1);
             if (communityUserLikeVos.isEmpty()) {
@@ -160,6 +161,25 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
         int offset = (pageNum - 1) * pageSize;
         communityArticleVos = communityArticleMapper.selectCommunityArticleList(communityArticle, classIds, offset, pageSize, searchType);
 
+        //剔除是否有合集文章
+        List<Long> ids = communityArticleVos.stream().map(item -> item.getId()).collect(Collectors.toList());
+        List<CommunityCollectionArticle> collections = communityCollectionArticleMapper.selectList(new QueryWrapper<CommunityCollectionArticle>()
+                .in("article_id", ids)
+                .and((wrapper) -> {
+                    wrapper.ne("is_delete", true).or().isNull("is_delete");
+                }));
+        List<CommunityArticleVo> articleVos_copy = new ArrayList<>(communityArticleVos);
+        if (noCollection != null){
+            if (noCollection == 1) {
+                for (CommunityArticleVo communityArticleVo : articleVos_copy) {
+                    for (CommunityCollectionArticle collection : collections) {
+                        if(collection.getArticleId().equals(communityArticleVo.getId())){
+                            communityArticleVos.remove(communityArticleVo);
+                        }
+                    }
+                }
+            }
+        }
 
         rspData.setTotal(communityArticleVos.size());
         List<CommunityArticleVo> communityArticleVos_copy = new ArrayList<>(communityArticleVos);