diff --git a/luoo_comment/src/main/java/com/luoo/comment/pojo/CommentHis.java b/luoo_comment/src/main/java/com/luoo/comment/pojo/CommentHis.java index 20ca750..a416875 100644 --- a/luoo_comment/src/main/java/com/luoo/comment/pojo/CommentHis.java +++ b/luoo_comment/src/main/java/com/luoo/comment/pojo/CommentHis.java @@ -17,6 +17,7 @@ public class CommentHis { private String userId; // 被评论人userid; + private String parentCommentId; // 父评论ID(被评论的ID) private String content; // 被评论的内容; diff --git a/luoo_comment/src/main/java/com/luoo/comment/service/CommentService.java b/luoo_comment/src/main/java/com/luoo/comment/service/CommentService.java index 20ceca7..28f2eff 100644 --- a/luoo_comment/src/main/java/com/luoo/comment/service/CommentService.java +++ b/luoo_comment/src/main/java/com/luoo/comment/service/CommentService.java @@ -7,6 +7,7 @@ import com.luoo.comment.dao.CommentHisDao; import com.luoo.comment.pojo.Comment; import com.luoo.comment.pojo.CommentHis; import com.luoo.comment.pojo.JournalRespDTO; +import com.luoo.comment.pojo.PublicationLike; import constants.Constants; import dto.UserLoginDto; import dto.UserMessageDto; @@ -96,6 +97,7 @@ public class CommentService { commentHis.setNickName(userLoginDto.getNickName()); commentHis.setCommentContent(comment.getContent()); commentHis.setContent(parentComment.getContent()); + commentHis.setParentCommentId(parentComment.get_id()); commentHis.setCommenterAvatar(Constants.RESOURCE_PREFIX+userLoginDto.getAvatar()); commentHis.setJournalId(parentComment.getJournalId()); commentHis.setJournalImage(parentComment.getJournalImage()); @@ -151,8 +153,32 @@ public class CommentService { cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_COMMENT_PAGE_HOT+"_"+comment.getRootJournalId()); cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_COMMENT_PAGE_NEW+"_"+comment.getRootJournalId()); } - commentDao.deleteById(id); - + comment.setContent("原评论已删除"); + // 同步publicationLike和CommentHis + + // 同步更新publicationLike中的评论信息 + Query query1 = new Query(); + query1.addCriteria(Criteria.where("likedItemId").is(id)); + Update update1 = new Update(); + update1.set("commentContent","原评论已删除"); + mongoTemplate.updateMulti(query1,update1, PublicationLike.class); + + + + // 同步更新CommentHis中的评论信息 + Query query2 = new Query(); + query2.addCriteria(Criteria.where("parentCommentId").is(id)); + Update update2 = new Update(); + update2.set("content","原评论已删除"); + mongoTemplate.updateMulti(query2,update2,CommentHis.class); + + Query query3 = new Query(); + query3.addCriteria(Criteria.where("commentId").is(id)); + Update update3 = new Update(); + update3.set("commentContent","原评论已删除"); + mongoTemplate.updateMulti(query3,update3,CommentHis.class); +// commentDao.deleteById(id); + commentDao.save(comment); } public Page findByParentId(String parentId, int page, int size) { diff --git a/luoo_user/src/main/java/com/luoo/user/pojo/CommentHis.java b/luoo_user/src/main/java/com/luoo/user/pojo/CommentHis.java index 68e026e..4990a4c 100644 --- a/luoo_user/src/main/java/com/luoo/user/pojo/CommentHis.java +++ b/luoo_user/src/main/java/com/luoo/user/pojo/CommentHis.java @@ -18,6 +18,8 @@ public class CommentHis { private String userId; // 被评论人userid; + private String parentCommentId; // 父评论ID(被评论的ID) + private String content; // 被评论的内容; private String commenterId; // 评论人userId