瀏覽代碼

合集游览更新 优化代码

fangqing 4 月之前
父節點
當前提交
1ebca9b81c

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

@@ -277,12 +277,14 @@ public class CommunityCollectionServiceImpl extends ServiceImpl<CommunityCollect
         int offset = (pageNum - 1) * pageSize;
         List<CommunityCollectionVo> communityCollectionVos = communityCollectionMapper.selectUserCollection(userId, articleId, offset, pageSize, searchType);
         for (CommunityCollectionVo communityCollectionVo : communityCollectionVos) {
-            JSONArray objects = selectArticleInfoInCollection(communityCollectionVo.getId(), 1L);
-            Long articleNumber =  0L;
-            if (!objects.isEmpty()){
-                articleNumber =  objects.getJSONObject(0).getLong("articleNumber");
-            }
-            communityCollectionVo.setArticleCount(articleNumber);
+            Long aLong = communityCollectionArticleMapper.selectCount(new QueryWrapper<CommunityCollectionArticle>()
+                    .eq("collection_id", communityCollectionVo.getId())
+                    .and((wrapper) -> {
+                        wrapper.ne("is_delete", true)
+                                .or()
+                                .isNull("is_delete");
+                    }));
+            communityCollectionVo.setArticleCount(aLong);
         }
         return communityCollectionVos;
     }

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

@@ -12,7 +12,7 @@
         a.images,
         a.is_delete,
         COUNT(b.article_id) AS articleCount,
-        SUM(a.heat) AS pageViews,
+        a.heat AS pageViews,
         a.create_by,
         a.update_by,
         a.create_time,
@@ -46,7 +46,7 @@
         a.images,
         a.is_delete,
         COUNT(b.article_id) AS articleCount,
-        SUM(a.heat) AS pageViews,
+        a.heat AS pageViews,
         a.create_by,
         a.update_by,
         a.create_time,