🐛 消息通知关联数据删除后报错问题修复
This commit is contained in:
parent
65a30ed420
commit
1d02fb6664
@ -51,7 +51,9 @@ public class NotificationServiceImpl extends AbstractService<Notification> imple
|
|||||||
List<NotificationDTO> notifications = new ArrayList<>();
|
List<NotificationDTO> notifications = new ArrayList<>();
|
||||||
list.forEach(notification -> {
|
list.forEach(notification -> {
|
||||||
NotificationDTO notificationDTO = genNotification(notification);
|
NotificationDTO notificationDTO = genNotification(notification);
|
||||||
notifications.add(notificationDTO);
|
if (Objects.nonNull(notificationDTO.getAuthor())) {
|
||||||
|
notifications.add(notificationDTO);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return notifications;
|
return notifications;
|
||||||
}
|
}
|
||||||
@ -67,37 +69,45 @@ public class NotificationServiceImpl extends AbstractService<Notification> imple
|
|||||||
case "0":
|
case "0":
|
||||||
// 系统公告/帖子
|
// 系统公告/帖子
|
||||||
article = articleService.findArticleDTOById(notification.getDataId(), 0);
|
article = articleService.findArticleDTOById(notification.getDataId(), 0);
|
||||||
notificationDTO.setDataTitle("系统公告");
|
if (Objects.nonNull(article)) {
|
||||||
notificationDTO.setDataUrl(article.getArticlePermalink());
|
notificationDTO.setDataTitle("系统公告");
|
||||||
user = userService.findById(article.getArticleAuthorId().toString());
|
notificationDTO.setDataUrl(article.getArticlePermalink());
|
||||||
notificationDTO.setAuthor(genAuthor(user));
|
user = userService.findById(article.getArticleAuthorId().toString());
|
||||||
|
notificationDTO.setAuthor(genAuthor(user));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "1":
|
case "1":
|
||||||
// 关注
|
// 关注
|
||||||
follow = followService.findById(notification.getDataId().toString());
|
follow = followService.findById(notification.getDataId().toString());
|
||||||
notificationDTO.setDataTitle("关注提醒");
|
notificationDTO.setDataTitle("关注提醒");
|
||||||
user = userService.findById(follow.getFollowerId().toString());
|
if (Objects.nonNull(follow)) {
|
||||||
notificationDTO.setDataUrl(getFollowLink(follow.getFollowingType(), user.getNickname()));
|
user = userService.findById(follow.getFollowerId().toString());
|
||||||
notificationDTO.setAuthor(genAuthor(user));
|
notificationDTO.setDataUrl(getFollowLink(follow.getFollowingType(), user.getNickname()));
|
||||||
|
notificationDTO.setAuthor(genAuthor(user));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "2":
|
case "2":
|
||||||
// 回帖
|
// 回帖
|
||||||
comment = commentService.findById(notification.getDataId().toString());
|
comment = commentService.findById(notification.getDataId().toString());
|
||||||
article = articleService.findArticleDTOById(comment.getCommentArticleId(), 0);
|
article = articleService.findArticleDTOById(comment.getCommentArticleId(), 0);
|
||||||
notificationDTO.setDataTitle(article.getArticleTitle());
|
if (Objects.nonNull(article)) {
|
||||||
notificationDTO.setDataUrl(comment.getCommentSharpUrl());
|
notificationDTO.setDataTitle(article.getArticleTitle());
|
||||||
user = userService.findById(comment.getCommentAuthorId().toString());
|
notificationDTO.setDataUrl(comment.getCommentSharpUrl());
|
||||||
notificationDTO.setAuthor(genAuthor(user));
|
user = userService.findById(comment.getCommentAuthorId().toString());
|
||||||
|
notificationDTO.setAuthor(genAuthor(user));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "3":
|
case "3":
|
||||||
// 关注用户发布文章
|
// 关注用户发布文章
|
||||||
case "4":
|
case "4":
|
||||||
// 关注文章更新
|
// 关注文章更新
|
||||||
article = articleService.findArticleDTOById(notification.getDataId(), 0);
|
article = articleService.findArticleDTOById(notification.getDataId(), 0);
|
||||||
notificationDTO.setDataTitle("关注通知");
|
if (Objects.nonNull(article)) {
|
||||||
notificationDTO.setDataUrl(article.getArticlePermalink());
|
notificationDTO.setDataTitle("关注通知");
|
||||||
user = userService.findById(article.getArticleAuthorId().toString());
|
notificationDTO.setDataUrl(article.getArticlePermalink());
|
||||||
notificationDTO.setAuthor(genAuthor(user));
|
user = userService.findById(article.getArticleAuthorId().toString());
|
||||||
|
notificationDTO.setAuthor(genAuthor(user));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user