Browse Source

优化代码 selectUserCollection

fangqing 5 months ago
parent
commit
07bcf74d1e

+ 5 - 1
ruoyi-generator/src/main/java/com/ruoyi/generator/service/CommunityCollectionServiceImpl.java

@@ -260,7 +260,11 @@ public class CommunityCollectionServiceImpl extends ServiceImpl<CommunityCollect
         List<CommunityCollectionVo> communityCollectionVos = communityCollectionMapper.selectUserCollection(userId, articleId);
         for (CommunityCollectionVo communityCollectionVo : communityCollectionVos) {
             JSONArray objects = selectArticleInfoInCollection(communityCollectionVo.getId(), 1L);
-            communityCollectionVo.setArticleCount(objects.getJSONObject(0).getLong("articleNumber"));
+            Long articleNumber =  0L;
+            if (objects != null){
+                articleNumber =  objects.getJSONObject(0).getLong("articleNumber");
+            }
+            communityCollectionVo.setArticleCount(articleNumber);
         }
         return communityCollectionVos;
     }