From d5dc047c8071ca3a53c276fd8bdb2460398b3827 Mon Sep 17 00:00:00 2001 From: wangqing <408564126@qq.com> Date: Mon, 4 Mar 2024 22:54:54 +0800 Subject: [PATCH] fix delete comment with parentCommentCount-1 --- .../java/com/luoo/comment/service/CommentService.java | 8 ++++++++ 1 file changed, 8 insertions(+) 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 dcfae38..2444753 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 @@ -149,6 +149,14 @@ 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()); rabbitTemplate.convertAndSend(Constants.RABBIT_MESSAGE_CLEAN_JOURANL_QUERY_PAGE,comment.getRootJournalId()); + + if (StringUtils.isNotEmpty(comment.getParentId())){ + Query query = new Query(); + query.addCriteria(Criteria.where("_id").is(comment.getRootId())); + Update update = new Update(); + update.inc("commentCount",-1); + mongoTemplate.updateFirst(query,update,"comment"); + } // comment.setContent("原评论已删除"); // 同步publicationLike和CommentHis