- GET /api/board/reports — 글/댓글 신고 대상별 집계(UNION, 신고 많은 순) - POST /api/board/reports/dismiss — 블라인드 없이 신고 기록만 초기화 - 관리자 신고 관리 화면 백엔드 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,29 @@
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user