Commit 813c73e8 authored by 刘基明's avatar 刘基明

点赞评论消息通知 fix

parent ac15232a
......@@ -93,16 +93,18 @@ public class NotificationManager {
themeNotifyQo.setUserInvestorType(userInfo.getUserInvestorType());
themeNotifyQo.setBelongUserOrgId(userInfo.getBelongUserOrgId());
themeNotifyQo.setBelongUserOrgName(userInfo.getBelongUserOrgName());
// 评论根据commentEntity找到ThemeId
if (NotificationTypeEnum.COMMENT.getCode().equals(themeNotifyQo.getMessageType()) ||
NotificationTypeEnum.COMMENT_LIKE.getCode().equals(themeNotifyQo.getMessageType())) {
// 评论类型将commentId替换为themeId
CommentEntity commentEntity = commentService.queryByCommentId(themeNotifyQo.getCommentId());
themeNotifyQo.setFormerThemeId(commentEntity.getThemeId());
}
// 封装引用对象
if (StringUtils.isNotEmpty(themeNotifyQo.getFormerThemeId())) {
if (NotificationTypeEnum.COMMENT.getCode().equals(themeNotifyQo.getMessageType())) {
// 评论类型将commentId替换为themeId
CommentEntity commentEntity = commentService.queryByCommentId(themeNotifyQo.getFormerThemeId());
themeNotifyQo.setFormerThemeId(commentEntity.getThemeId());
}
ThemeEntity former = themeService.queryByThemeId(themeNotifyQo.getFormerThemeId());
if (former != null) {
themeNotifyQo.setFormerUserName(currentUser.getNickName());
if (StringUtils.isNotBlank(former.getTopicId())) {
......@@ -121,30 +123,6 @@ public class NotificationManager {
// 引用主题已被删除
themeNotifyQo.setFormerThemeId(null);
}
}
// 评论点赞类型
if (NotificationTypeEnum.COMMENT_LIKE.getCode().equals(themeNotifyQo.getMessageType())) {
CommentEntity commentEntity = commentService.queryByCommentId(themeNotifyQo.getCommentId());
if (commentEntity!=null){
themeNotifyQo.setContent(null);
}else {
themeNotifyQo.setFormerThemeId(commentEntity.getThemeId());
themeNotifyQo.setContent(commentEntity.getContent());
ThemeEntity themeEntity = themeService.queryByThemeId(commentEntity.getThemeId());
if (themeEntity != null) {
themeNotifyQo.setFormerUserName(getUserInfo(themeEntity.getAuthorId()).getNickName());
themeNotifyQo.setFormerTopicId(themeEntity.getTopicId());
if (ThemeTypeEnum.DISCUSSION.getCode().equals(themeEntity.getThemeType()) || ThemeTypeEnum.FORWARD.getCode().equals(themeEntity.getThemeType())) {
List<ThemeContentQo> themeContentQos = JsonUtil.toBean(themeEntity.getContent(), new TypeReference<List<ThemeContentQo>>() {
});
themeNotifyQo.setFormerContent(themeContentQos.get(0).getValue());
} else if (ThemeTypeEnum.LONG_TEXT.getCode().equals(themeEntity.getThemeType())) {
themeNotifyQo.setFormerContent(themeEntity.getTitle());
}
}
}
}
// 外部话题
if (StringUtils.isNotBlank(themeNotifyQo.getTopicId())) {
......
......@@ -250,6 +250,12 @@ public class ConvertUtil {
) {
themeNotifyQo.setFormerThemeId(entity.getTargetId());
}
// 评、点赞评论 评论Id
if (entity.getMessageType().equals(NotificationTypeEnum.COMMENT_LIKE.getCode()) ||
entity.getMessageType().equals(NotificationTypeEnum.COMMENT.getCode())
) {
themeNotifyQo.setCommentId(entity.getTargetId());
}
// 转发有话题信息
if (entity.getMessageType().equals(NotificationTypeEnum.FORWARD.getCode())) {
themeNotifyQo.setFormerThemeId(entity.getTargetId());
......@@ -266,22 +272,8 @@ public class ConvertUtil {
}
}
// 点赞需要聚合头像和人数
if (entity.getMessageType().equals(NotificationTypeEnum.LIKE.getCode())) {
if (!StringUtils.isEmpty(entity.getContent())) {
try {
NotificationLikeDO notificationLikeDO = JsonUtil.toBean(entity.getContent(), NotificationLikeDO.class);
themeNotifyQo.setLikeUserCount(notificationLikeDO.getCount());
ArrayList<UserBriefInfoQO> likeUsers = new ArrayList<>();
notificationLikeDO.getSet().stream().forEach(o->likeUsers.add(UserBriefInfoQO.builder().userId(o).build()));
themeNotifyQo.setLikeUsers(likeUsers);
}catch (Exception e){
throw new BizException("消息通知-点赞类型-反序列化异常:"+ entity.getContent());
}
}
}
// 点赞评论需要聚合头像和人数,并写入commentId
if (entity.getMessageType().equals(NotificationTypeEnum.COMMENT_LIKE.getCode())) {
if (entity.getMessageType().equals(NotificationTypeEnum.LIKE.getCode()) ||
entity.getMessageType().equals(NotificationTypeEnum.COMMENT_LIKE.getCode())) {
if (!StringUtils.isEmpty(entity.getContent())) {
try {
......@@ -290,14 +282,11 @@ public class ConvertUtil {
ArrayList<UserBriefInfoQO> likeUsers = new ArrayList<>();
notificationLikeDO.getSet().stream().forEach(o->likeUsers.add(UserBriefInfoQO.builder().userId(o).build()));
themeNotifyQo.setLikeUsers(likeUsers);
themeNotifyQo.setCommentId(entity.getTargetId());
}catch (Exception e){
throw new BizException("消息通知-点赞类型-反序列化异常:"+ entity.getContent());
}
}
}
return themeNotifyQo;
}
......
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