1.update comment component

main
Gary 8 months ago
parent ad0e43cc7a
commit 0b8ad47f63

@ -35,6 +35,7 @@ import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;
import util.IdWorker;
import util.StringTools;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
@ -191,7 +192,7 @@ public class CommentController extends BaseController {
UserInfo commentUserInfo = userInfoService.findById(comment.getUserId());
comment.setNickName(commentUserInfo.getNickName());
comment.setAvatar(Constants.RESOURCE_PREFIX+commentUserInfo.getAvatar());
comment.setAvatar(getAvatar(commentUserInfo));
if(StringUtils.isNotEmpty(comment.getReplyToUserId())){
UserInfo replyToUserInfo = userInfoService.findById(comment.getReplyToUserId());
comment.setReplyToNickname(replyToUserInfo.getNickName());
@ -211,7 +212,7 @@ public class CommentController extends BaseController {
Comment topComment = commentService.findByParentId(comment.get_id(),1,1).getContent().get(0);
UserInfo topCommentUserInfo = userInfoService.findById(topComment.getUserId());
topComment.setNickName(topCommentUserInfo.getNickName());
topComment.setAvatar(Constants.RESOURCE_PREFIX+topCommentUserInfo.getAvatar());
topComment.setAvatar(getAvatar(topCommentUserInfo));
if(StringUtils.isNotEmpty(topComment.getReplyToUserId())){
UserInfo topReplyUserInfo = userInfoService.findById(topComment.getReplyToUserId());
topComment.setReplyToNickname(topReplyUserInfo.getNickName());
@ -228,13 +229,20 @@ public class CommentController extends BaseController {
private CommentResp getCommentResp(Comment comment) {
private String getAvatar(UserInfo commentUserInfo) {
if(StringTools.isEmpty(commentUserInfo.getThumbnail())) {
return Constants.RESOURCE_PREFIX+commentUserInfo.getAvatar();
}
return Constants.RESOURCE_PREFIX+commentUserInfo.getThumbnail();
}
private CommentResp getCommentResp(Comment comment) {
UserInfo commentUserInfo = userInfoService.findById(comment.getUserId());
comment.setNickName(commentUserInfo.getNickName());
comment.setAvatar(Constants.RESOURCE_PREFIX+commentUserInfo.getAvatar());
comment.setAvatar(getAvatar(commentUserInfo));
if(StringUtils.isNotEmpty(comment.getReplyToUserId())){
UserInfo replyToUserInfo = userInfoService.findById(comment.getReplyToUserId());
@ -255,7 +263,7 @@ public class CommentController extends BaseController {
Comment topComment = commentService.findByParentId(comment.get_id(),1,1).getContent().get(0);
UserInfo topCommentUserInfo = userInfoService.findById(topComment.getUserId());
topComment.setNickName(topCommentUserInfo.getNickName());
topComment.setAvatar(Constants.RESOURCE_PREFIX+topCommentUserInfo.getAvatar());
topComment.setAvatar(getAvatar(topCommentUserInfo));
if(StringUtils.isNotEmpty(topComment.getReplyToUserId())){
UserInfo topReplyUserInfo = userInfoService.findById(topComment.getReplyToUserId());
topComment.setReplyToNickname(topReplyUserInfo.getNickName());

@ -39,6 +39,10 @@ public class UserInfo implements Serializable {
*
*/
private String avatar;
/**
* 200X200
*/
private String thumbnail;
/**
*
*/

Loading…
Cancel
Save