2017-08-15 15:36:07 +07:00
|
|
|
<?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" >
|
2017-08-18 16:08:27 +07:00
|
|
|
<mapper namespace="io.spring.infrastructure.mybatis.readservice.CommentReadService">
|
2017-08-18 11:09:07 +07:00
|
|
|
<sql id="selectCommentData">
|
2017-08-15 15:36:07 +07:00
|
|
|
SELECT
|
2017-08-18 11:09:07 +07:00
|
|
|
C.id commentId,
|
|
|
|
C.body commentBody,
|
|
|
|
C.created_at commentCreatedAt,
|
2021-03-16 16:16:20 +07:00
|
|
|
C.article_id commentArticleId,
|
2017-08-18 16:08:27 +07:00
|
|
|
<include refid="io.spring.infrastructure.mybatis.readservice.ArticleReadService.profileColumns"/>
|
2017-08-15 15:36:07 +07:00
|
|
|
from comments C
|
|
|
|
left join users U
|
|
|
|
on C.user_id = U.id
|
2017-08-18 11:09:07 +07:00
|
|
|
</sql>
|
|
|
|
|
2017-08-21 16:25:00 +07:00
|
|
|
<select id="findById" resultMap="transfer.data.commentData">
|
2017-08-18 11:09:07 +07:00
|
|
|
<include refid="selectCommentData"/>
|
2017-08-15 15:36:07 +07:00
|
|
|
where C.id = #{id}
|
|
|
|
</select>
|
2017-08-21 16:25:00 +07:00
|
|
|
<select id="findByArticleId" resultMap="transfer.data.commentData">
|
2017-08-18 11:09:07 +07:00
|
|
|
<include refid="selectCommentData"/>
|
|
|
|
where C.article_id = #{articleId}
|
|
|
|
</select>
|
2021-03-19 14:23:37 +07:00
|
|
|
<select id="findByArticleIdWithCursor" resultMap="transfer.data.commentData">
|
|
|
|
<include refid="selectCommentData"/>
|
|
|
|
<where>
|
|
|
|
C.article_id = #{articleId}
|
|
|
|
<if test='page.cursor != "" and page.direction.name() == "NEXT"'>
|
|
|
|
AND C.created_at < #{page.cursor}
|
|
|
|
</if>
|
|
|
|
<if test='page.cursor != "" and page.direction.name() == "PREV"'>
|
|
|
|
AND C.created_at > #{page.cursor}
|
|
|
|
</if>
|
|
|
|
</where>
|
|
|
|
<if test='page.direction.name() == "NEXT"'>
|
|
|
|
order by C.created_at desc
|
|
|
|
</if>
|
|
|
|
<if test='page.direction.name() == "PREV"'>
|
|
|
|
order by C.created_at asc
|
|
|
|
</if>
|
|
|
|
</select>
|
2017-08-15 15:36:07 +07:00
|
|
|
</mapper>
|