fix: delete comment ->"原评论已删除"

main
wangqing 9 months ago
parent 264a3ed3d5
commit faa7c7cfa7

@ -17,6 +17,7 @@ public class CommentHis {
private String userId; // 被评论人userid;
private String parentCommentId; // 父评论ID被评论的ID
private String content; // 被评论的内容;

@ -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<Comment> findByParentId(String parentId, int page, int size) {

@ -18,6 +18,8 @@ public class CommentHis {
private String userId; // 被评论人userid;
private String parentCommentId; // 父评论ID被评论的ID
private String content; // 被评论的内容;
private String commenterId; // 评论人userId

Loading…
Cancel
Save