From 41c2a000db45af402a69c809b9d51d45fd242b32 Mon Sep 17 00:00:00 2001 From: wangqing <408564126@qq.com> Date: Sun, 3 Mar 2024 08:42:14 +0800 Subject: [PATCH] fix: clear cache when thumbup --- .../com/luoo/comment/controller/CommentController.java | 8 ++++++++ .../java/com/luoo/comment/service/CommentService.java | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/luoo_comment/src/main/java/com/luoo/comment/controller/CommentController.java b/luoo_comment/src/main/java/com/luoo/comment/controller/CommentController.java index 9a5bea6..6625e0f 100644 --- a/luoo_comment/src/main/java/com/luoo/comment/controller/CommentController.java +++ b/luoo_comment/src/main/java/com/luoo/comment/controller/CommentController.java @@ -359,6 +359,14 @@ public class CommentController extends BaseController { // return Result.failed(StatusCode.COMMENT_REPEAT_THUMBUP); // } + + Comment comment = commentService.findById(commentId); + cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_COMMENT_PAGE_HOT+"_"+comment.getRootJournalId()); + cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_COMMENT_PAGE_NEW+"_"+comment.getRootJournalId()); + + if(StringUtils.isNotEmpty(comment.getParentId())) { + cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_COMMENT_PAGE_CHILDREN+"_"+comment.getParentId()); + } // 判断当前用户是否已经点赞 Integer flag = likeService.likePublication(commentId,userId,2,avatar,nickName); if (flag==0) { 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 933bc46..20ceca7 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,8 +76,8 @@ public class CommentService { } if(StringUtils.isEmpty(comment.getParentId())) { - cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_COMMENT_PAGE_HOT+"_"+comment.getJournalId()); - cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_COMMENT_PAGE_NEW+"_"+comment.getJournalId()); + 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()); }