Răsfoiți Sursa

文章列表获取优化

fangqing 4 luni în urmă
părinte
comite
0f7f695d9f

+ 10 - 3
ruoyi-generator/src/main/java/com/ruoyi/generator/service/CommunityArticleServiceImpl.java

@@ -246,13 +246,20 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
             articleVo.setCollectionVo(communityCollectionMapper.selectCollectById(userId, articleVo.getId()));
 
             //设置中奖信息
-            articleVo.setCommentRaffleVo(communityCommentRaffleMapper.selectOne(
+            CommunityCommentRaffleVo communityCommentRaffleVo = new CommunityCommentRaffleVo();
+            CommunityCommentRaffle communityCommentRaffle = communityCommentRaffleMapper.selectOne(
                     new QueryWrapper<CommunityCommentRaffle>()
                             .eq("article_id", articleVo.getId())
                             .and((wrapper) -> {
                                 wrapper.ne("is_delete", true).or().isNull("is_delete");
-                            })));
-
+                            }));
+            if (communityCommentRaffle != null) {
+                BeanUtils.copyProperties(communityCommentRaffle, communityCommentRaffleVo);
+                CommunityUserInfoVo communityUserInfoVo = communityArticleService.selectCommunityUserInfoById(communityCommentRaffle.getUserId());
+                communityCommentRaffleVo.setUserName(communityUserInfoVo.getNickName());
+                communityCommentRaffleVo.setUserAvatar(communityUserInfoVo.getAvatar());
+                articleVo.setCommentRaffleVo(communityCommentRaffleVo);
+            }
             //文章下的评论
 //            List<Map<String, Object>> comments = articleVo.getComments();
 //            for (Map<String, Object> communityArticleCommentVo : comments) {

+ 1 - 1
ruoyi-generator/src/main/java/com/ruoyi/generator/vo/CommunityArticleVo.java

@@ -135,7 +135,7 @@ public class CommunityArticleVo extends BaseEntity implements Serializable {
     private CommunityCollectionVo collectionVo;
 
     @ApiModelProperty("文章合集")
-    private CommunityCommentRaffle CommentRaffleVo;
+    private CommunityCommentRaffleVo CommentRaffleVo;
 
 
     /**