回复评论增加toUserNickName
This commit is contained in:
parent
6b0b018f0f
commit
290cc419db
@ -25,7 +25,14 @@ import com.red.circle.other.inner.model.cmd.user.account.PunishmentAccountCmd;
|
|||||||
import com.red.circle.tool.core.date.TimestampUtils;
|
import com.red.circle.tool.core.date.TimestampUtils;
|
||||||
import com.red.circle.tool.core.num.NumUtils;
|
import com.red.circle.tool.core.num.NumUtils;
|
||||||
import com.red.circle.tool.core.sequence.IdWorkerUtils;
|
import com.red.circle.tool.core.sequence.IdWorkerUtils;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -63,9 +70,10 @@ public class DynamicCommentCmdExe {
|
|||||||
incrCommentQuantity(cmd);
|
incrCommentQuantity(cmd);
|
||||||
|
|
||||||
//评论自己创建的动态或者自己回复自己不发送消息
|
//评论自己创建的动态或者自己回复自己不发送消息
|
||||||
UserProfile userProfile = userProfileGateway.getByUserId(cmd.getReqUserId());
|
Set<Long> userIdSet = Stream.of(cmd.getReqUserId(), cmd.getToUserId()).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||||
|
Map<Long, UserProfile> userProfileMap = userProfileGateway.mapByUserIds(userIdSet);
|
||||||
if (isOwnDynamic(cmd, dynamicContent)) {
|
if (isOwnDynamic(cmd, dynamicContent)) {
|
||||||
return convert(dynamicComment, userProfile);
|
return convert(dynamicComment, userProfileMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
dynamicPopularService.updateScore(dynamicContent.getId(), dynamicCacheService.getCommentScore(),
|
dynamicPopularService.updateScore(dynamicContent.getId(), dynamicCacheService.getCommentScore(),
|
||||||
@ -78,10 +86,10 @@ public class DynamicCommentCmdExe {
|
|||||||
|
|
||||||
//发送消息给动态被回复人
|
//发送消息给动态被回复人
|
||||||
saveDynamicMessage(cmd, DynamicMessageEnum.REPLY_COMMENT);
|
saveDynamicMessage(cmd, DynamicMessageEnum.REPLY_COMMENT);
|
||||||
return convert(dynamicComment, userProfile);
|
return convert(dynamicComment, userProfileMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DynamicCommentListCO convert(DynamicComment dynamicComment, UserProfile userProfile) {
|
private DynamicCommentListCO convert(DynamicComment dynamicComment, Map<Long, UserProfile> userProfileMap) {
|
||||||
DynamicCommentListCO commentListCO = new DynamicCommentListCO();
|
DynamicCommentListCO commentListCO = new DynamicCommentListCO();
|
||||||
commentListCO.setId(dynamicComment.getId());
|
commentListCO.setId(dynamicComment.getId());
|
||||||
commentListCO.setDynamicId(dynamicComment.getDynamicContentId());
|
commentListCO.setDynamicId(dynamicComment.getDynamicContentId());
|
||||||
@ -89,10 +97,19 @@ public class DynamicCommentCmdExe {
|
|||||||
commentListCO.setContent(dynamicComment.getContent());
|
commentListCO.setContent(dynamicComment.getContent());
|
||||||
commentListCO.setCreateTime(dynamicComment.getCreateTime());
|
commentListCO.setCreateTime(dynamicComment.getCreateTime());
|
||||||
commentListCO.setRootCommentId(dynamicComment.getRootCommentId());
|
commentListCO.setRootCommentId(dynamicComment.getRootCommentId());
|
||||||
commentListCO.setUserId(userProfile.getId());
|
|
||||||
commentListCO.setUserAvatar(userProfile.getUserAvatar());
|
UserProfile userProfile = userProfileMap.get(dynamicComment.getCreateUser());
|
||||||
commentListCO.setUserNickname(userProfile.getUserNickname());
|
if (userProfile != null) {
|
||||||
commentListCO.setUserSex(userProfile.getUserSex());
|
commentListCO.setUserId(userProfile.getId());
|
||||||
|
commentListCO.setUserAvatar(userProfile.getUserAvatar());
|
||||||
|
commentListCO.setUserNickname(userProfile.getUserNickname());
|
||||||
|
commentListCO.setUserSex(userProfile.getUserSex());
|
||||||
|
}
|
||||||
|
|
||||||
|
UserProfile toUser = userProfileMap.get(dynamicComment.getToUserId());
|
||||||
|
if (toUser != null) {
|
||||||
|
commentListCO.setToUserNickname(toUser.getUserNickname());
|
||||||
|
}
|
||||||
return commentListCO;
|
return commentListCO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user