Commit 436eb668 authored by 刘基明's avatar 刘基明

评论的主题+用户信息

parent 30450304
......@@ -4,15 +4,18 @@ import com.google.common.collect.Sets;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.exception.BizException;
import com.tanpu.common.util.JsonUtil;
import com.tanpu.community.api.beans.qo.*;
import com.tanpu.community.api.beans.qo.ESThemeQo;
import com.tanpu.community.api.beans.qo.FormerThemeQo;
import com.tanpu.community.api.beans.qo.ThemeContentQo;
import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.req.homepage.QueryRecordThemeReq;
import com.tanpu.community.api.beans.req.theme.*;
import com.tanpu.community.api.beans.resp.CreateThemeResp;
import com.tanpu.community.api.beans.resp.ThemeFullSearchResp;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoNew;
import com.tanpu.community.api.enums.*;
import com.tanpu.community.cache.RedisCache;
import com.tanpu.community.dao.entity.community.*;
import com.tanpu.community.dao.entity.user.UserInfoEntity;
import com.tanpu.community.feign.fatools.FeignClientForFatools;
import com.tanpu.community.service.*;
import com.tanpu.community.service.base.ESService;
......@@ -33,8 +36,7 @@ import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
import static com.tanpu.community.api.constants.RedisKeyConstant.CACHE_FORMER_THEME_ID;
import static com.tanpu.community.api.constants.RedisKeyConstant.CACHE_THEME_ID;
import static com.tanpu.community.api.constants.RedisKeyConstant.*;
@Slf4j
@Service
......@@ -248,9 +250,7 @@ public class ThemeManager {
private void buildThemeExtraInfoByUser(String userId, ThemeQo themeQo) {
String themeId = themeQo.getThemeId();
//是否关注作者
String authorId = themeQo.getAuthorId();
Set<String> fansSet = new HashSet<>(followRelService.queryFansByFollowerId(userId));
themeQo.setFollow(fansSet.contains(authorId));
themeQo.setFollow(followRelService.checkFollow(themeQo.getAuthorId(),userId));
//是否点赞
CollectionEntity likeEntity = collectionService.getNotDeleteTargetCollection(themeId, userId, CollectionTypeEnum.LIKE_THEME);
themeQo.setHasLiked(likeEntity != null);
......@@ -439,7 +439,8 @@ public class ThemeManager {
//评论列表
List<CommentEntity> commentEntities = commentService.queryThemesByUserId(req.getUserId(), req.getLastId(), req.getPageSize());
//当前用户信息
UserInfoEntity userInfoEntity = userInfoService.queryUserById(req.getUserId());
UserInfoNew userInfo = redisCache.getObject(StringUtils.joinWith(CACGE_FEIGN_USER_INFO, req.getUserId()),
60 * 10, () ->this.getUserInfo(req.getUserId()) , UserInfoNew.class);
Set<String> replyThemeIds = commentEntities.stream().map(CommentEntity::getThemeId).collect(Collectors.toSet());
if (CollectionUtils.isEmpty(replyThemeIds)) {
return commentThemeList;
......@@ -464,13 +465,19 @@ public class ThemeManager {
FormerThemeQo f = ConvertUtil.themeQo2FormerThemeQo(themeQo);
//ThemeContentQo和原主题包装到FormerThemeQo中包装到ThemeQo中
ThemeQo commentThemeQo = ThemeQo.builder()
.authorId(userInfoEntity.getId())
.nickName(userInfoEntity.getUiUsernameMp())
.userImg(userInfoEntity.getUiHeadimgMp())
.authorId(userInfo.getUserId())
.nickName(userInfo.getNickName())
.userImg(userInfo.getHeadImageUrl())
.userType(userInfo.getUserType())
.levelGrade(userInfo.getLevelGrade())
.userInvestorType(userInfo.getUserInvestorType())
.belongUserOrgId(userInfo.getBelongUserOrgId())
.belongUserOrgName(userInfo.getBelongUserOrgName())
.content(Arrays.asList(commentContent))
.formerTheme(f)
.commentId(commentEntity.getCommentId())
.themeType(ThemeTypeEnum.RES_COMMENT.getCode())
.follow(followRelService.checkFollow(themeQo.getAuthorId(),userId))
.build();
commentThemeList.add(commentThemeQo);
......@@ -478,4 +485,13 @@ public class ThemeManager {
return commentThemeList;
}
private UserInfoNew getUserInfo(String authorId){
CommonResp<UserInfoNew> userInfoNewCommonResp = feignClientForFatools.queryUsersListNew(authorId);
if (userInfoNewCommonResp.isNotSuccess()) {
throw new BizException("内部接口调用失败");
}
return userInfoNewCommonResp.getData();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment