123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?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.sumbytes.helloblog.posts.dao.PostsCommentsDao">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.sumbytes.helloblog.posts.domain.po.PostsComments">
- <id column="id" property="id"/>
- <result column="create_time" property="createTime"/>
- <result column="author_id" property="authorId"/>
- <result column="content" property="content"/>
- <result column="parent_id" property="parentId"/>
- <result column="status" property="status"/>
- <result column="posts_id" property="postsId"/>
- <result column="tree_path" property="treePath"/>
- </resultMap>
- <select id="selectPostsCommentsByPostsIdList" resultType="com.sumbytes.helloblog.posts.domain.vo.PostsCommentsVO">
- SELECT
- postsComments.id,
- postsComments.content,
- postsComments.create_time createTime,
- authUser.name authorName,
- authUser.avatar authorAvatar,
- parentAuthUser.name parentUserName
- FROM
- hello_blog_posts_comments postsComments
- LEFT JOIN hello_blog_auth_user authUser ON postsComments.author_id = authUser.id
- LEFT JOIN hello_blog_posts_comments parentPostsComments ON postsComments.parent_id = parentPostsComments.id
- LEFT JOIN hello_blog_auth_user parentAuthUser ON parentPostsComments.author_id = parentAuthUser.id
- <where>
- postsComments.posts_id = #{postsId}
- </where>
- ORDER BY postsComments.id DESC
- </select>
- <select id="selectPostsCommentsList" resultType="com.sumbytes.helloblog.posts.domain.vo.PostsCommentsVO">
- SELECT
- postsComments.id as id,
- postsComments.content,
- authUser.name as authorName,
- authUser.avatar as authorAvatar,
- parentAuthUser.name as parentUserName,
- posts.title as postTitle
- FROM
- hello_blog_posts_comments postsComments
- LEFT JOIN hello_blog_auth_user authUser ON postsComments.author_id = authUser.id
- LEFT JOIN hello_blog_posts_comments parentPostsComments ON postsComments.id = parentPostsComments.parent_id
- LEFT JOIN hello_blog_auth_user parentAuthUser ON parentPostsComments.author_id = parentAuthUser.id
- LEFT JOIN hello_blog_posts posts ON posts.id = postsComments.posts_id
- <where>
- <if test="postsComments.keywords != null and postsComments.keywords != ''">
- ( postsComments.content LIKE #{postsComments.keywords} OR posts.title LIKE #{postsComments.keywords} )
- </if>
- <if test="postsComments.id!=null">
- and postsComments.id=#{postsComments.id}
- </if>
- </where>
- </select>
- </mapper>
|