fangqing hace 1 mes
padre
commit
694d0f1ffd

+ 16 - 6
ruoyi-generator/src/main/java/com/ruoyi/generator/service/CommunityCollectionServiceImpl.java

@@ -178,11 +178,16 @@ public class CommunityCollectionServiceImpl extends ServiceImpl<CommunityCollect
         if (searchType == 1) {
             // 查询最新的文章
             communityArticles = communityArticleMapper.selectList(
-                    new QueryWrapper<CommunityArticle>().in("id", articleIds).and((wrapper) -> {
-                        wrapper.ne("is_delete", true)
+                    new QueryWrapper<CommunityArticle>().in("id", articleIds)
+                            .and((wrapper) -> {wrapper.ne("is_delete", true)
                                 .or()
                                 .isNull("is_delete");
-                    }).orderByDesc("create_time"));
+                    }).and((wrapper) -> {
+                                wrapper.ne("is_draft", true)
+                                        .or()
+                                        .isNull("is_draft");
+                            })
+                            .orderByDesc("create_time"));
         } else {
             // 查询最早的文章
             communityArticles = communityArticleMapper.selectList(
@@ -190,7 +195,12 @@ public class CommunityCollectionServiceImpl extends ServiceImpl<CommunityCollect
                         wrapper.ne("is_delete", true)
                                 .or()
                                 .isNull("is_delete");
-                    }).orderByAsc("create_time"));
+                    }).and((wrapper) -> {
+                                wrapper.ne("is_draft", true)
+                                        .or()
+                                        .isNull("is_draft");
+                            })
+                            .orderByAsc("create_time"));
         }
         collectionObject.put("articleNumber", communityArticles.size());
 
@@ -281,7 +291,7 @@ public class CommunityCollectionServiceImpl extends ServiceImpl<CommunityCollect
     public List<CommunityCollectionVo> selectUserCollection(Long userId, Long articleId, int pageNum, int pageSize, int searchType) {
         int offset = (pageNum - 1) * pageSize;
         List<CommunityCollectionVo> communityCollectionVos = communityCollectionMapper.selectUserCollection(userId, articleId, offset, pageSize, searchType);
-        for (CommunityCollectionVo communityCollectionVo : communityCollectionVos) {
+        /*for (CommunityCollectionVo communityCollectionVo : communityCollectionVos) {
             Long aLong = communityCollectionArticleMapper.selectCount(new QueryWrapper<CommunityCollectionArticle>()
                     .eq("collection_id", communityCollectionVo.getId())
                     .and((wrapper) -> {
@@ -290,7 +300,7 @@ public class CommunityCollectionServiceImpl extends ServiceImpl<CommunityCollect
                                 .isNull("is_delete");
                     }));
             communityCollectionVo.setArticleCount(aLong);
-        }
+        }*/
         return communityCollectionVos;
     }
 

+ 7 - 2
ruoyi-generator/src/main/resources/mapper/community/CommunityCollectionMapper.xml

@@ -13,7 +13,7 @@
         a.collection_tag,
         a.is_delete,
         COUNT(b.article_id) AS articleCount,
-        a.heat AS pageViews,
+        sum(c.page_views) AS pageViews,
         a.create_by,
         a.update_by,
         a.create_time,
@@ -24,6 +24,8 @@
         LEFT JOIN community_article c ON b.article_id = c.id
         WHERE a.user_id = #{userId}
         AND (a.is_delete != '1' OR a.is_delete IS NULL)
+        AND (b.is_delete != '1' OR b.is_delete IS NULL)
+        AND (c.is_delete != '1' OR c.is_delete IS NULL)   AND (c.is_draft != '1' OR c.is_draft IS NULL)
         <if test="articleId != null and articleId != ''">
             AND b.article_id = #{articleId}
         </if>
@@ -49,7 +51,7 @@
         a.collection_tag,
         a.is_delete,
         COUNT(b.article_id) AS articleCount,
-        a.heat AS pageViews,
+        sum(c.page_views)  AS pageViews,
         a.create_by,
         a.update_by,
         a.create_time,
@@ -61,6 +63,9 @@
         LEFT JOIN community_collection_user d ON d.collection_id = a.id
         WHERE d.user_id =  #{userId} AND  d.id  is not null
         AND (a.is_delete != '1' OR a.is_delete IS NULL)
+        AND (b.is_delete != '1' OR b.is_delete IS NULL)
+        AND (d.is_delete != '1' OR d.is_delete IS NULL)
+        AND (c.is_delete != '1' OR c.is_delete IS NULL)   AND (c.is_draft != '1' OR c.is_draft IS NULL)
         <if test="articleId != null and articleId != ''">
             AND b.article_id = #{articleId}
         </if>