소스 검색

优化代码 selectUserCollection

fangqing 5 달 전
부모
커밋
07bcf74d1e
1개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  1. 5 1
      ruoyi-generator/src/main/java/com/ruoyi/generator/service/CommunityCollectionServiceImpl.java

+ 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;
     }