fix commentList avatar errors

main
wangqing 8 months ago
parent 942f2a3296
commit 89a53aa006

@ -194,21 +194,27 @@ public class CommentController extends BaseController {
comment.setHaveThumbup(isExists); // comment.setHaveThumbup(isExists); //
UserInfo commentUserInfo = userInfoService.findById(comment.getUserId()); UserInfo commentUserInfo = userInfoService.findById(comment.getUserId());
comment.setNickName(commentUserInfo.getNickName()); if(null != commentUserInfo) {
comment.setAvatar(getAvatar(commentUserInfo)); comment.setNickName(commentUserInfo.getNickName());
if(StringUtils.isNotEmpty(comment.getReplyToUserId())){ comment.setAvatar(getAvatar(commentUserInfo));
UserInfo replyToUserInfo = userInfoService.findById(comment.getReplyToUserId()); if(StringUtils.isNotEmpty(comment.getReplyToUserId())){
comment.setReplyToNickname(replyToUserInfo.getNickName()); UserInfo replyToUserInfo = userInfoService.findById(comment.getReplyToUserId());
comment.setReplyToNickname(replyToUserInfo.getNickName());
}
} }
CommentResp commentResp = new CommentResp(); CommentResp commentResp = new CommentResp();
if (StringUtils.isNotEmpty(commentUserInfo.getBadges())){ if (null!= commentUserInfo) {
Set<Integer> badgeSet = new HashSet<>(); if (StringUtils.isNotEmpty(commentUserInfo.getBadges())){
Arrays.stream(commentUserInfo.getBadges().split(",")).forEach(b->{ Set<Integer> badgeSet = new HashSet<>();
int code=Integer.valueOf(b.substring(0, 1)); Arrays.stream(commentUserInfo.getBadges().split(",")).forEach(b->{
badgeSet.add(code); int code=Integer.valueOf(b.substring(0, 1));
}); badgeSet.add(code);
commentResp.setBadgeList(new ArrayList<>(badgeSet)); });
commentResp.setBadgeList(new ArrayList<>(badgeSet));
}
} }
BeanUtils.copyProperties(comment,commentResp); BeanUtils.copyProperties(comment,commentResp);
if(comment.getCommentCount()>0){ if(comment.getCommentCount()>0){
@ -254,8 +260,8 @@ public class CommentController extends BaseController {
CommentResp commentResp = new CommentResp(); CommentResp commentResp = new CommentResp();
BeanUtils.copyProperties(comment,commentResp); BeanUtils.copyProperties(comment,commentResp);
if (null != commentUserInfo) { if (null != commentUserInfo) {
comment.setNickName(commentUserInfo.getNickName()); commentResp.setNickName(commentUserInfo.getNickName());
comment.setAvatar(getAvatar(commentUserInfo)); commentResp.setAvatar(getAvatar(commentUserInfo));
if (StringUtils.isNotEmpty(commentUserInfo.getBadges())){ if (StringUtils.isNotEmpty(commentUserInfo.getBadges())){
Set<Integer> badgeSet = new HashSet<>(); Set<Integer> badgeSet = new HashSet<>();
Arrays.stream(commentUserInfo.getBadges().split(",")).forEach(b->{ Arrays.stream(commentUserInfo.getBadges().split(",")).forEach(b->{

Loading…
Cancel
Save