评论功能消息通知完善

This commit is contained in:
x ronger 2020-03-08 01:00:28 +08:00
parent ef56fba867
commit a21339d68d

View File

@ -81,20 +81,29 @@ public class CommentServiceImpl extends AbstractService<Comment> implements Comm
commentSharpUrl.append("/comment/").append(comment.getIdComment()); commentSharpUrl.append("/comment/").append(comment.getIdComment());
commentMapper.updateCommentSharpUrl(comment.getIdComment(), commentSharpUrl.toString()); commentMapper.updateCommentSharpUrl(comment.getIdComment(), commentSharpUrl.toString());
// 评论者不是作者本人则进行消息通知 String commentContent = comment.getCommentContent();
if (!article.getArticleAuthorId().equals(comment.getCommentAuthorId())) { if(StringUtils.isNotBlank(commentContent)){
String commentContent = comment.getCommentContent(); Integer length = commentContent.length();
if(StringUtils.isNotBlank(commentContent)){ if(length > MAX_PREVIEW){
Integer length = commentContent.length(); length = 200;
if(length > MAX_PREVIEW){ }
length = 200; String commentPreviewContent = commentContent.substring(0,length);
} commentContent = Html2TextUtil.getContent(commentPreviewContent);
String commentPreviewContent = commentContent.substring(0,length); // 评论者不是作者本人则进行消息通知
commentContent = Html2TextUtil.getContent(commentPreviewContent); if (article.getArticleAuthorId().equals(comment.getCommentAuthorId())) {
NotificationUtils.saveNotification(article.getArticleAuthorId(),comment.getIdComment(), NotificationConstant.Comment, commentContent); NotificationUtils.saveNotification(article.getArticleAuthorId(),comment.getIdComment(), NotificationConstant.Comment, commentContent);
} }
// 判断是否是回复消息
if (comment.getCommentOriginalCommentId() != null) {
Comment originalComment = commentMapper.selectByPrimaryKey(comment.getCommentOriginalCommentId());
// 回复消息时,评论者不是上级评论作者则进行消息通知
if (!comment.getCommentAuthorId().equals(originalComment.getCommentAuthorId())) {
NotificationUtils.saveNotification(originalComment.getCommentAuthorId(),comment.getIdComment(), NotificationConstant.Comment, commentContent);
}
}
} }
return map; return map;
} }
} }