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 2f38994..eef89ca 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 @@ -76,15 +76,12 @@ public class CommentService { comment.setJournalImage(journalRespDTO.getImage()); } - if(StringUtils.isEmpty(comment.getParentId())) { - cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_COMMENT_PAGE_HOT+"_"+comment.getRootJournalId()); - cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_COMMENT_PAGE_NEW+"_"+comment.getRootJournalId()); + // System.out.println("journalId____"+comment.getJournalId()); - } // 如果当前添加的评论,有父节点,那么根节点的评论回复数要加一 if (comment.getParentId()!=null && !"".equals(comment.getParentId())){ - cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_COMMENT_PAGE_CHILDREN+"_"+comment.getParentId()); + // System.out.println("parentId____"+comment.getParentId()); Comment parentComment = commentDao.findById(comment.getParentId()).get(); @@ -134,6 +131,9 @@ public class CommentService { } commentDao.save(comment); + cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_COMMENT_PAGE_CHILDREN+"_"+comment.getParentId()); + 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()); return comment; } @@ -145,12 +145,9 @@ public class CommentService { public void deleteById(String id) { Comment comment =commentDao.findById(id).get(); - if(StringUtils.isNotEmpty(comment.getParentId())) { cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_COMMENT_PAGE_CHILDREN+"_"+comment.getParentId()); - } else { 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()); // comment.setContent("原评论已删除"); // 同步publicationLike和CommentHis