🐛 是否回复评论判断 bug 修复

This commit is contained in:
ronger 2020-03-11 09:44:39 +08:00
parent b73dbb727e
commit 1d68044df5

View File

@ -14,6 +14,7 @@ import com.rymcu.vertical.util.NotificationUtils;
import com.rymcu.vertical.util.Utils; import com.rymcu.vertical.util.Utils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -52,6 +53,7 @@ public class CommentServiceImpl extends AbstractService<Comment> implements Comm
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public Map postComment(Comment comment, HttpServletRequest request) { public Map postComment(Comment comment, HttpServletRequest request) {
Map map = new HashMap(1); Map map = new HashMap(1);
if(comment.getCommentArticleId() == null){ if(comment.getCommentArticleId() == null){
@ -94,7 +96,7 @@ public class CommentServiceImpl extends AbstractService<Comment> implements Comm
NotificationUtils.saveNotification(article.getArticleAuthorId(),comment.getIdComment(), NotificationConstant.Comment, commentContent); NotificationUtils.saveNotification(article.getArticleAuthorId(),comment.getIdComment(), NotificationConstant.Comment, commentContent);
} }
// 判断是否是回复消息 // 判断是否是回复消息
if (comment.getCommentOriginalCommentId() != null) { if (comment.getCommentOriginalCommentId() != null && comment.getCommentOriginalCommentId() != 0) {
Comment originalComment = commentMapper.selectByPrimaryKey(comment.getCommentOriginalCommentId()); Comment originalComment = commentMapper.selectByPrimaryKey(comment.getCommentOriginalCommentId());
// 回复消息时,评论者不是上级评论作者则进行消息通知 // 回复消息时,评论者不是上级评论作者则进行消息通知
if (!comment.getCommentAuthorId().equals(originalComment.getCommentAuthorId())) { if (!comment.getCommentAuthorId().equals(originalComment.getCommentAuthorId())) {