|
@@ -78,15 +78,20 @@ public class PostsCommentsServiceImpl extends BaseServiceImpl<PostsCommentsDao,
|
|
|
|
|
|
@Override
|
|
|
public Result replyComments(PostsCommentsVO postsCommentsVO) {
|
|
|
+ // 由于是使用后台管理系统直接评论,所以此处直接将评论对象设置为管理员
|
|
|
AuthUser authUser=authUserDao.selectAdmin();
|
|
|
- PostsComments postsComments=postsCommentsDao.selectById(postsCommentsVO.getParentId())
|
|
|
- .setParentId(postsCommentsVO.getParentId())
|
|
|
+ PostsComments postsComments=postsCommentsDao.selectById(postsCommentsVO.getParentId());
|
|
|
+ // 准备更新前的参数内容
|
|
|
+ postsComments.setParentId(postsCommentsVO.getParentId())
|
|
|
.setContent(postsCommentsVO.getContent())
|
|
|
.setAuthorId(authUser.getId())
|
|
|
- .setCreateTime(LocalDateTime.now());
|
|
|
+ .setCreateTime(LocalDateTime.now())
|
|
|
+ .setId(null);
|
|
|
+ // 添加评论
|
|
|
this.postsCommentsDao.insert(postsComments);
|
|
|
- String treePath = postsComments.getTreePath() + postsComments.getId() + Constants.TREE_PATH;
|
|
|
- this.postsCommentsDao.updateById(postsComments.setTreePath(treePath));
|
|
|
+ // 增加完成后会默认获取id,此时需要将id,增加到层级结构当中
|
|
|
+ this.postsCommentsDao.updateById(postsComments.setTreePath(postsComments.getTreePath() + postsComments.getId() + Constants.TREE_PATH));
|
|
|
+ // 为文章添加评论数
|
|
|
this.postsDao.incrementComments( postsCommentsVO.getPostsId());
|
|
|
return Result.createWithSuccessMessage();
|
|
|
}
|