fix clear comment region

main
wangqing 9 months ago
parent 8c55f0313e
commit d59a8bc439

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

Loading…
Cancel
Save