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.mapper.CommentMapper">
|
2017-08-15 15:36:07 +07:00
|
|
|
<insert id="insert">
|
|
|
|
insert into comments(id, body, user_id, article_id, created_at, updated_at)
|
|
|
|
values (
|
|
|
|
#{comment.id},
|
|
|
|
#{comment.body},
|
|
|
|
#{comment.userId},
|
|
|
|
#{comment.articleId},
|
|
|
|
#{comment.createdAt},
|
|
|
|
#{comment.createdAt}
|
|
|
|
)
|
|
|
|
</insert>
|
2017-08-15 17:16:06 +07:00
|
|
|
<delete id="delete">
|
|
|
|
delete from comments where id = #{id}
|
|
|
|
</delete>
|
2017-08-15 15:36:07 +07:00
|
|
|
<select id="findById" resultMap="comment">
|
|
|
|
select
|
|
|
|
id commentId,
|
|
|
|
body commentBody,
|
|
|
|
user_id commentUserId,
|
|
|
|
article_id commentArticleId,
|
|
|
|
created_at commentCreatedAt
|
|
|
|
from comments
|
2017-08-15 17:16:06 +07:00
|
|
|
where id = #{id} and article_id = #{articleId}
|
2017-08-15 15:36:07 +07:00
|
|
|
</select>
|
|
|
|
<resultMap id="comment" type="io.spring.core.comment.Comment">
|
|
|
|
<id column="commentId" property="id"/>
|
|
|
|
<result column="commentBody" property="body"/>
|
|
|
|
<result column="commentUserId" property="userId"/>
|
|
|
|
<result column="commentArticleId" property="articleId"/>
|
|
|
|
<result column="commentCreatedAt" property="createdAt"/>
|
|
|
|
</resultMap>
|
|
|
|
</mapper>
|