- GET /board/my/posts, /board/my/comments (페이징) - PostSummary 에 category 추가, MyCommentResponse(글 제목·카테고리 포함) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
67 lines
2.8 KiB
XML
67 lines
2.8 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.sb.web.board.mapper.CommentMapper">
|
|
|
|
<resultMap id="commentResultMap" type="com.sb.web.board.domain.Comment">
|
|
<id property="id" column="id"/>
|
|
<result property="postId" column="post_id"/>
|
|
<result property="authorId" column="author_id"/>
|
|
<result property="authorName" column="author_name"/>
|
|
<result property="authorGooglePicture" column="author_google_picture"/>
|
|
<result property="authorProfileImage" column="author_profile_image"/>
|
|
<result property="content" column="content"/>
|
|
<result property="blocked" column="blocked"/>
|
|
<result property="createdAt" column="created_at"/>
|
|
</resultMap>
|
|
|
|
<select id="findByPostId" parameterType="long" resultMap="commentResultMap">
|
|
SELECT c.id, c.post_id, c.author_id, c.author_name, c.content, c.blocked, c.created_at,
|
|
m.google_picture AS author_google_picture, m.profile_image AS author_profile_image
|
|
FROM comment c
|
|
LEFT JOIN member m ON m.id = c.author_id
|
|
WHERE c.post_id = #{postId}
|
|
ORDER BY c.id ASC
|
|
</select>
|
|
|
|
<select id="findById" parameterType="long" resultMap="commentResultMap">
|
|
SELECT c.id, c.post_id, c.author_id, c.author_name, c.content, c.blocked, c.created_at,
|
|
m.google_picture AS author_google_picture, m.profile_image AS author_profile_image
|
|
FROM comment c
|
|
LEFT JOIN member m ON m.id = c.author_id
|
|
WHERE c.id = #{id}
|
|
</select>
|
|
|
|
<update id="updateBlocked">
|
|
UPDATE comment SET blocked = #{blocked} WHERE id = #{id}
|
|
</update>
|
|
|
|
<select id="findMyPage" resultType="com.sb.web.board.dto.MyCommentResponse">
|
|
SELECT c.id, c.content, c.created_at, p.id AS post_id, p.title AS post_title, p.category
|
|
FROM comment c
|
|
JOIN post p ON p.id = c.post_id
|
|
WHERE c.author_id = #{memberId}
|
|
ORDER BY c.id DESC
|
|
LIMIT #{size} OFFSET #{offset}
|
|
</select>
|
|
|
|
<select id="countMyComments" parameterType="long" resultType="long">
|
|
SELECT COUNT(*) FROM comment WHERE author_id = #{memberId}
|
|
</select>
|
|
|
|
<insert id="insert" parameterType="com.sb.web.board.domain.Comment"
|
|
useGeneratedKeys="true" keyProperty="id">
|
|
INSERT INTO comment (post_id, author_id, author_name, content, created_at)
|
|
VALUES (#{postId}, #{authorId}, #{authorName}, #{content}, NOW())
|
|
</insert>
|
|
|
|
<delete id="delete" parameterType="long">
|
|
DELETE FROM comment WHERE id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteByPostId" parameterType="long">
|
|
DELETE FROM comment WHERE post_id = #{postId}
|
|
</delete>
|
|
|
|
</mapper>
|