Commit 83e7d388 authored by 刘基明's avatar 刘基明

修复评论查询

parent 07dbf80d
......@@ -121,7 +121,7 @@ public class CommentManager {
//更改举报状态
commentService.updateReportStatus(req.getCommentId());
//写入举报记录表
CommentEntity commentEntity = commentService.queryByCommentId(req.getCommentId());
CommentEntity commentEntity = commentService.queryByIdIncludeDelete(req.getCommentId());
reportLogService.insert(ReportTypeEnum.COMMENT, userId, req.getCommentId(), commentEntity.getAuthorId(), req.getReason());
}
......
......@@ -47,7 +47,7 @@ public class CommentService {
}
public CommentEntity queryByCommentId(String commmentId) {
public CommentEntity queryByIdIncludeDelete(String commmentId) {
return commentMapper.selectOne(new LambdaQueryWrapper<CommentEntity>()
.eq(CommentEntity::getCommentId, commmentId));
}
......@@ -58,14 +58,16 @@ public class CommentService {
return 0;
}
return commentMapper.selectList((new LambdaQueryWrapper<CommentEntity>()
.in(CommentEntity::getThemeId, themeIds)))
.in(CommentEntity::getThemeId, themeIds))
.eq(CommentEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED))
.size();
}
//统计主题集合的评论量
public Integer getCommentCountByThemeId(String themeId) {
return commentMapper.selectList((new LambdaQueryWrapper<CommentEntity>()
.eq(CommentEntity::getThemeId, themeId)))
.eq(CommentEntity::getThemeId, themeId))
.eq(CommentEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED))
.size();
}
......@@ -115,8 +117,9 @@ public class CommentService {
return commentMapper.selectList(queryWrapper);
}
//修改举报状态,可修改已删除
public void updateReportStatus(String commentId) {
CommentEntity commentEntity = queryByCommentId(commentId);
CommentEntity commentEntity = queryByIdIncludeDelete(commentId);
if (commentEntity == null) {
throw new BizException("评论未找到,id:" + commentId);
}
......@@ -128,7 +131,7 @@ public class CommentService {
//删除评论
@Transactional
public void delete(String commentId, String userId) {
CommentEntity commentEntity = this.queryByCommentId(commentId);
CommentEntity commentEntity = this.queryByIdIncludeDelete(commentId);
if (commentEntity==null || !commentEntity.getAuthorId().equals(userId)){
throw new BizException("删除评论与用户不匹配,commentId:"+commentId+",userId:"+userId);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment