Commit 231a22cd by 段启岩

博客评论添加用户的昵称和头像

parent 8da61f2b
...@@ -2,14 +2,15 @@ package cn.meteor.beyondclouds.modules.blog.entity; ...@@ -2,14 +2,15 @@ package cn.meteor.beyondclouds.modules.blog.entity;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.io.Serializable;
import java.time.LocalDateTime;
/** /**
* <p> * <p>
* 博客评论表 * 博客评论表
...@@ -35,6 +36,12 @@ public class BlogComment implements Serializable { ...@@ -35,6 +36,12 @@ public class BlogComment implements Serializable {
@ApiModelProperty(value = "评论者ID") @ApiModelProperty(value = "评论者ID")
private String userId; private String userId;
@ApiModelProperty(value = "用户昵称")
private String userNick;
@ApiModelProperty(value = "用户头像")
private String userAvatar;
@ApiModelProperty(value = "上一级评论ID") @ApiModelProperty(value = "上一级评论ID")
private Integer parentId; private Integer parentId;
......
...@@ -9,6 +9,8 @@ import cn.meteor.beyondclouds.modules.blog.exception.BlogServiceException; ...@@ -9,6 +9,8 @@ import cn.meteor.beyondclouds.modules.blog.exception.BlogServiceException;
import cn.meteor.beyondclouds.modules.blog.mapper.BlogCommentMapper; import cn.meteor.beyondclouds.modules.blog.mapper.BlogCommentMapper;
import cn.meteor.beyondclouds.modules.blog.service.IBlogCommentService; import cn.meteor.beyondclouds.modules.blog.service.IBlogCommentService;
import cn.meteor.beyondclouds.modules.blog.service.IBlogService; import cn.meteor.beyondclouds.modules.blog.service.IBlogService;
import cn.meteor.beyondclouds.modules.user.entity.User;
import cn.meteor.beyondclouds.modules.user.service.IUserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...@@ -30,11 +32,18 @@ public class BlogCommentServiceImpl extends ServiceImpl<BlogCommentMapper, BlogC ...@@ -30,11 +32,18 @@ public class BlogCommentServiceImpl extends ServiceImpl<BlogCommentMapper, BlogC
private IBlogService blogService; private IBlogService blogService;
private IUserService userService;
@Autowired @Autowired
public void setBlogService(IBlogService blogService) { public void setBlogService(IBlogService blogService) {
this.blogService = blogService; this.blogService = blogService;
} }
@Autowired
public void setUserService(IUserService userService) {
this.userService = userService;
}
/** /**
* 发布评论 * 发布评论
* @param blogId * @param blogId
...@@ -77,12 +86,17 @@ public class BlogCommentServiceImpl extends ServiceImpl<BlogCommentMapper, BlogC ...@@ -77,12 +86,17 @@ public class BlogCommentServiceImpl extends ServiceImpl<BlogCommentMapper, BlogC
} }
//2.创建评论 //2.创建评论
// 查找用户
User user = userService.getById(userId);
BlogComment blogComment = new BlogComment(); BlogComment blogComment = new BlogComment();
blogComment.setBlogId(blogId); blogComment.setBlogId(blogId);
blogComment.setComment(comment); blogComment.setComment(comment);
blogComment.setDepth(depth); blogComment.setDepth(depth);
blogComment.setParentId(parentId); blogComment.setParentId(parentId);
blogComment.setUserId(userId); blogComment.setUserId(userId);
blogComment.setUserNick(user.getNickName());
blogComment.setUserAvatar(user.getUserAvatar());
save(blogComment); save(blogComment);
//3.查找上一层目录 //3.查找上一层目录
if (blogComment.getParentId() == null) { if (blogComment.getParentId() == null) {
......
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