回复评论增加toUserNickName

This commit is contained in:
tianfeng 2026-01-29 18:58:51 +08:00
parent 6b0b018f0f
commit 290cc419db

View File

@ -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.num.NumUtils;
import com.red.circle.tool.core.sequence.IdWorkerUtils;
import java.util.Arrays;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
@ -63,9 +70,10 @@ public class DynamicCommentCmdExe {
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)) {
return convert(dynamicComment, userProfile);
return convert(dynamicComment, userProfileMap);
}
dynamicPopularService.updateScore(dynamicContent.getId(), dynamicCacheService.getCommentScore(),
@ -78,10 +86,10 @@ public class DynamicCommentCmdExe {
//发送消息给动态被回复人
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();
commentListCO.setId(dynamicComment.getId());
commentListCO.setDynamicId(dynamicComment.getDynamicContentId());
@ -89,10 +97,19 @@ public class DynamicCommentCmdExe {
commentListCO.setContent(dynamicComment.getContent());
commentListCO.setCreateTime(dynamicComment.getCreateTime());
commentListCO.setRootCommentId(dynamicComment.getRootCommentId());
commentListCO.setUserId(userProfile.getId());
commentListCO.setUserAvatar(userProfile.getUserAvatar());
commentListCO.setUserNickname(userProfile.getUserNickname());
commentListCO.setUserSex(userProfile.getUserSex());
UserProfile userProfile = userProfileMap.get(dynamicComment.getCreateUser());
if (userProfile != null) {
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;
}