diff --git a/src/main/java/com/lovenav/controller/CommentController.java b/src/main/java/com/lovenav/controller/CommentController.java index e4e84b1..b41e663 100644 --- a/src/main/java/com/lovenav/controller/CommentController.java +++ b/src/main/java/com/lovenav/controller/CommentController.java @@ -39,13 +39,6 @@ public class CommentController { return commentService.AddLikeCount(id); } -// 显示评论 -@RequestMapping(method = RequestMethod.GET, value = "/view_comment") -public ResponseEntity> queryObserveByBlogId ( - @ApiParam(name = "url_id", value = "id", required = true) @PathVariable Integer url_id - ) { - return ResponseEntity.ok(commentService.queryCommentByUrlId(url_id)); -} // 显示回复 @RequestMapping(method = RequestMethod.GET, value = "/view_reply") @@ -59,10 +52,8 @@ public ResponseEntity> queryObserveByBlogId ( * @param UrlId 博客id * @return 博客的评论信息 */ -@GetMapping("/UrlId") - public ResponseEntity> queryCommentByUrlId ( - @ApiParam(name = "UrlId", value = "urlid", required = true) @PathVariable Integer UrlId - ) { +@RequestMapping(method = RequestMethod.GET, value = "/UrlId") + public ResponseEntity> queryCommentByUrlId (Integer UrlId) { return ResponseEntity.ok(commentService.queryCommentByUrlId(UrlId)); } @@ -71,10 +62,8 @@ public ResponseEntity> queryObserveByBlogId ( * @param Id 评论id * @return 评论信息,携带用户信息 */ -@GetMapping("/Id") - public ResponseEntity queryObserveUserById ( - @ApiParam(name = "Id", value = "评论id", required = true)@PathVariable Integer Id - ) { +@RequestMapping(method = RequestMethod.GET, value = "/Id") + public ResponseEntity queryObserveUserById (Integer Id) { return ResponseEntity.ok(commentService.queryCommentUserById(Id)); } } diff --git a/src/main/java/com/lovenav/dao/CommentDao.java b/src/main/java/com/lovenav/dao/CommentDao.java index 2dc0179..e779469 100644 --- a/src/main/java/com/lovenav/dao/CommentDao.java +++ b/src/main/java/com/lovenav/dao/CommentDao.java @@ -29,26 +29,8 @@ public interface CommentDao { List selectByAllReply(int id); - @Select("SELECT * FROM ln_comment o LEFT JOIN ln_user u"+ - "ON o.user_id=u.id"+ - "WHERE o.user_id = #{userId,jdbcType=INTEGER} AND o.root_comment_id = 0") - @Results({ - @Result(id = true, column = "id", property = "id"), - @Result(column = "url_id", property = "urlId"), - @Result(column = "user_id", property = "userId"), - @Result(column = "content", property = "content"), - @Result(column = "content", property = "user", - one = @One(select = "com.lovenav.dao.UserDao.queryUserForComment", - fetchType = FetchType.EAGER)), - @Result(column = "root_comment_id", property = "rootCommentId"), - @Result(column = "comment_status", property = "commentStatus"), - @Result(column = "comment_time", property = "commentTime"), - @Result(column = "update_time", property = "updateTime"), - @Result(column = "like_count", property = "likeCount"), - @Result(column = "rating", property = "rating") - }) - List queryFirstCommentList (@Param("urlId") Integer UrlId); + List queryFirstCommentList (Integer UrlId); @@ -59,24 +41,6 @@ public interface CommentDao { * @author RenShiWei * Date: 2020/4/16 10:37 */ - @Select("SELECT * FROM ln_comment o LEFT JOIN ln_user u " + - "ON o.user_id=u.id " + - "WHERE o.user_id = #{userId,jdbcType=INTEGER} AND o.last_id != 0 ") - @Results({ - @Result(id = true, column = "id", property = "id"), - @Result(column = "url_id", property = "urlId"), - @Result(column = "user_id", property = "userId"), - @Result(column = "content", property = "content"), - @Result(column = "content", property = "user", - one = @One(select = "com.lovenav.dao.UserDao.queryUserForComment", - fetchType = FetchType.EAGER)), - @Result(column = "root_comment_id", property = "rootCommentId"), - @Result(column = "comment_status", property = "commentStatus"), - @Result(column = "comment_time", property = "commentTime"), - @Result(column = "update_time", property = "updateTime"), - @Result(column = "like_count", property = "likeCount"), - @Result(column = "rating", property = "rating") - }) - List querySecondCommentList(@Param("urlId")Integer UrlId); + List querySecondCommentList(Integer UrlId); } \ No newline at end of file diff --git a/src/main/java/com/lovenav/entity/Comment.java b/src/main/java/com/lovenav/entity/Comment.java index 0134a73..56d5331 100644 --- a/src/main/java/com/lovenav/entity/Comment.java +++ b/src/main/java/com/lovenav/entity/Comment.java @@ -143,7 +143,14 @@ public class Comment implements Serializable { */ private Integer rating; - public interface UpdateGroup { + private User user; + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; } private static final long serialVersionUID = 1L; diff --git a/src/main/java/com/lovenav/entity/CommentNode.java b/src/main/java/com/lovenav/entity/CommentNode.java index ff7d1bb..08a4e3d 100644 --- a/src/main/java/com/lovenav/entity/CommentNode.java +++ b/src/main/java/com/lovenav/entity/CommentNode.java @@ -3,7 +3,7 @@ package com.lovenav.entity; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; -import org.springframework.beans.factory.annotation.Autowired; + import java.util.ArrayList; import java.util.List; diff --git a/src/main/resources/mybatis/CommentDao.xml b/src/main/resources/mybatis/CommentDao.xml index d8dcbe0..812795a 100644 --- a/src/main/resources/mybatis/CommentDao.xml +++ b/src/main/resources/mybatis/CommentDao.xml @@ -13,6 +13,9 @@ + + + id, url_id, user_id, content, root_comment_id, like_count, comment_time, comment_status, update_time, rating @@ -164,34 +167,18 @@ + - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/src/main/resources/mybatis/mybatis.xml b/src/main/resources/mybatis/mybatis.xml new file mode 100644 index 0000000..df58021 --- /dev/null +++ b/src/main/resources/mybatis/mybatis.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file