评论
This commit is contained in:
parent
eda0e41b53
commit
8b6b6a6b7a
@ -39,13 +39,6 @@ public class CommentController {
|
|||||||
return commentService.AddLikeCount(id);
|
return commentService.AddLikeCount(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 显示评论
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "/view_comment")
|
|
||||||
public ResponseEntity<List<CommentNode>> 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")
|
@RequestMapping(method = RequestMethod.GET, value = "/view_reply")
|
||||||
@ -59,10 +52,8 @@ public ResponseEntity<List<CommentNode>> queryObserveByBlogId (
|
|||||||
* @param UrlId 博客id
|
* @param UrlId 博客id
|
||||||
* @return 博客的评论信息
|
* @return 博客的评论信息
|
||||||
*/
|
*/
|
||||||
@GetMapping("/UrlId")
|
@RequestMapping(method = RequestMethod.GET, value = "/UrlId")
|
||||||
public ResponseEntity<List<CommentNode>> queryCommentByUrlId (
|
public ResponseEntity<List<CommentNode>> queryCommentByUrlId (Integer UrlId) {
|
||||||
@ApiParam(name = "UrlId", value = "urlid", required = true) @PathVariable Integer UrlId
|
|
||||||
) {
|
|
||||||
return ResponseEntity.ok(commentService.queryCommentByUrlId(UrlId));
|
return ResponseEntity.ok(commentService.queryCommentByUrlId(UrlId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,10 +62,8 @@ public ResponseEntity<List<CommentNode>> queryObserveByBlogId (
|
|||||||
* @param Id 评论id
|
* @param Id 评论id
|
||||||
* @return 评论信息,携带用户信息
|
* @return 评论信息,携带用户信息
|
||||||
*/
|
*/
|
||||||
@GetMapping("/Id")
|
@RequestMapping(method = RequestMethod.GET, value = "/Id")
|
||||||
public ResponseEntity<CommentUser> queryObserveUserById (
|
public ResponseEntity<CommentUser> queryObserveUserById (Integer Id) {
|
||||||
@ApiParam(name = "Id", value = "评论id", required = true)@PathVariable Integer Id
|
|
||||||
) {
|
|
||||||
return ResponseEntity.ok(commentService.queryCommentUserById(Id));
|
return ResponseEntity.ok(commentService.queryCommentUserById(Id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,26 +29,8 @@ public interface CommentDao {
|
|||||||
|
|
||||||
List<Comment> selectByAllReply(int id);
|
List<Comment> 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<CommentNode> queryFirstCommentList (Integer UrlId);
|
||||||
List<CommentNode> queryFirstCommentList (@Param("urlId") Integer UrlId);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -59,24 +41,6 @@ public interface CommentDao {
|
|||||||
* @author RenShiWei
|
* @author RenShiWei
|
||||||
* Date: 2020/4/16 10:37
|
* 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<CommentNode> querySecondCommentList(Integer UrlId);
|
||||||
List<CommentNode> querySecondCommentList(@Param("urlId")Integer UrlId);
|
|
||||||
}
|
}
|
@ -143,7 +143,14 @@ public class Comment implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Integer rating;
|
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;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@ -3,7 +3,7 @@ package com.lovenav.entity;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -13,6 +13,9 @@
|
|||||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||||
<result column="rating" jdbcType="INTEGER" property="rating" />
|
<result column="rating" jdbcType="INTEGER" property="rating" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, url_id, user_id, content, root_comment_id, like_count, comment_time, comment_status,
|
id, url_id, user_id, content, root_comment_id, like_count, comment_time, comment_status,
|
||||||
update_time, rating
|
update_time, rating
|
||||||
@ -164,34 +167,18 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<select id="queryFirstCommentList" parameterType="java.lang.Integer" resultMap="com.lovenav.dao.mybaits.Map">
|
||||||
|
SELECT * FROM ln_comment o LEFT JOIN ln_user u
|
||||||
|
ON o.user_id=u.id
|
||||||
|
WHERE o.url_id = #{urlId,jdbcType=INTEGER} AND o.root_comment_id = 0
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="querySecondCommentList" parameterType="java.lang.Integer" resultMap="com.lovenav.dao.mybaits.Map">
|
||||||
|
SELECT * FROM ln_comment o LEFT JOIN ln_user u
|
||||||
|
ON o.user_id=u.id
|
||||||
<!-- <select id="queryFirstCommentList" parameterType="java.lang.Integer" resultMap="ResultMap">-->
|
WHERE o.url_id = #{urlId,jdbcType=INTEGER} AND o.root_comment_id != 0
|
||||||
<!-- SELECT * FROM ln_comment o LEFT JOIN ln_user u-->
|
</select>
|
||||||
<!-- ON o.user_id=u.id-->
|
|
||||||
<!-- WHERE o.url_id=#{urlId,jdbcType=INTEGER} AND o.root_comment_id is null-->
|
|
||||||
<!-- </select>-->
|
|
||||||
<!-- <resultMap id="ResultMap" type="com.lovenav.entity.Comment">-->
|
|
||||||
<!-- <id column="id" jdbcType="INTEGER" property="id" />-->
|
|
||||||
<!-- <result column="url_id" jdbcType="INTEGER" property="urlId" />-->
|
|
||||||
<!-- <result column="user_id" jdbcType="INTEGER" property="userId" />-->
|
|
||||||
<!-- <result column="content" jdbcType="VARCHAR" property="content" />-->
|
|
||||||
<!-- <result column="root_comment_id" jdbcType="INTEGER" property="rootCommentId" />-->
|
|
||||||
<!-- <result column="like_count" jdbcType="BIGINT" property="likeCount" />-->
|
|
||||||
<!-- <result column="comment_time" jdbcType="TIMESTAMP" property="commentTime" />-->
|
|
||||||
<!-- <result column="comment_status" jdbcType="TINYINT" property="commentStatus" />-->
|
|
||||||
<!-- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />-->
|
|
||||||
<!-- <result column="rating" jdbcType="INTEGER" property="rating" />-->
|
|
||||||
<!-- </resultMap>-->
|
|
||||||
|
|
||||||
<!-- <select id="querySecondCommentList" parameterType="java.lang.Integer" resultMap="ResultMap">-->
|
|
||||||
<!-- SELECT * FROM ln_comment o LEFT JOIN ln_user u-->
|
|
||||||
<!-- ON o.user_id=u.id-->
|
|
||||||
<!-- WHERE o.url_id=#{urlId,jdbcType=INTEGER} AND o.root_comment_id is not null-->
|
|
||||||
<!-- </select>-->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
29
src/main/resources/mybatis/mybatis.xml
Normal file
29
src/main/resources/mybatis/mybatis.xml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.lovenav.dao.mybaits">
|
||||||
|
<resultMap id="Map" type="com.lovenav.entity.Comment">
|
||||||
|
<id column="id" jdbcType="INTEGER" property="id" />
|
||||||
|
<result column="url_id" jdbcType="INTEGER" property="urlId" />
|
||||||
|
<result column="user_id" jdbcType="INTEGER" property="userId" />
|
||||||
|
<result column="content" jdbcType="VARCHAR" property="content" />
|
||||||
|
<result column="root_comment_id" jdbcType="INTEGER" property="rootCommentId" />
|
||||||
|
<result column="like_count" jdbcType="BIGINT" property="likeCount" />
|
||||||
|
<result column="comment_time" jdbcType="TIMESTAMP" property="commentTime" />
|
||||||
|
<result column="comment_status" jdbcType="TINYINT" property="commentStatus" />
|
||||||
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||||
|
<result column="rating" jdbcType="INTEGER" property="rating" />
|
||||||
|
|
||||||
|
<association property="user" javaType="com.lovenav.entity.User">
|
||||||
|
<id column="id" jdbcType="INTEGER" property="id" />
|
||||||
|
<result column="user_login" jdbcType="VARCHAR" property="userLogin" />
|
||||||
|
<result column="user_password" jdbcType="VARCHAR" property="userPassword" />
|
||||||
|
<result column="phone" jdbcType="BIGINT" property="phone" />
|
||||||
|
<result column="avatar" jdbcType="VARCHAR" property="avatar" />
|
||||||
|
<result column="nickname" jdbcType="VARCHAR" property="nickname" />
|
||||||
|
<result column="user_email" jdbcType="VARCHAR" property="userEmail" />
|
||||||
|
<result column="user_status" jdbcType="TINYINT" property="userStatus" />
|
||||||
|
<result column="user_registered" jdbcType="TIMESTAMP" property="userRegistered" />
|
||||||
|
<result column="role_id" jdbcType="TINYINT" property="roleId" />
|
||||||
|
</association>
|
||||||
|
</resultMap>
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue
Block a user