2f376e6f77
Deploy / deploy (push) Failing after 11m22s
- GET /api/board/reports — 글/댓글 신고 대상별 집계(UNION, 신고 많은 순) - POST /api/board/reports/dismiss — 블라인드 없이 신고 기록만 초기화 - 관리자 신고 관리 화면 백엔드 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
47 lines
2.0 KiB
XML
47 lines
2.0 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.ReportMapper">
|
|
|
|
<insert id="insertIgnore">
|
|
INSERT IGNORE INTO report (target_type, target_id, member_id, reason, created_at)
|
|
VALUES (#{targetType}, #{targetId}, #{memberId}, #{reason}, NOW())
|
|
</insert>
|
|
|
|
<select id="countByTarget" resultType="int">
|
|
SELECT COUNT(*) FROM report WHERE target_type = #{targetType} AND target_id = #{targetId}
|
|
</select>
|
|
|
|
<!-- 신고된 글/댓글 목록 (대상별 집계). 신고 많은 순 → 최근 신고 순. -->
|
|
<select id="listReported" resultType="com.sb.web.board.dto.ReportedItem">
|
|
SELECT 'POST' AS targetType, r.target_id AS targetId, p.id AS postId,
|
|
p.category AS category, p.title AS title, LEFT(p.content, 120) AS content,
|
|
p.author_id AS authorId, p.author_name AS authorName, p.blocked AS blocked,
|
|
COUNT(*) AS reportCount, MAX(r.created_at) AS lastReportedAt
|
|
FROM report r
|
|
JOIN post p ON p.id = r.target_id
|
|
WHERE r.target_type = 'POST'
|
|
GROUP BY p.id
|
|
UNION ALL
|
|
SELECT 'COMMENT' AS targetType, r.target_id AS targetId, c.post_id AS postId,
|
|
pp.category AS category, pp.title AS title, LEFT(c.content, 120) AS content,
|
|
c.author_id AS authorId, c.author_name AS authorName, c.blocked AS blocked,
|
|
COUNT(*) AS reportCount, MAX(r.created_at) AS lastReportedAt
|
|
FROM report r
|
|
JOIN comment c ON c.id = r.target_id
|
|
JOIN post pp ON pp.id = c.post_id
|
|
WHERE r.target_type = 'COMMENT'
|
|
GROUP BY c.id
|
|
ORDER BY reportCount DESC, lastReportedAt DESC
|
|
</select>
|
|
|
|
<delete id="deleteByTarget">
|
|
DELETE FROM report WHERE target_type = #{targetType} AND target_id = #{targetId}
|
|
</delete>
|
|
|
|
<delete id="deleteByMember">
|
|
DELETE FROM report WHERE member_id = #{memberId}
|
|
</delete>
|
|
|
|
</mapper>
|