- BoardService: create/addComment에서 isSpam 감지 시 자동 블라인드 처리, 포인트 미지급 - ReportMapper: listReported 쿼리 확장 — 신고 누적 OR 스팸 감지 블라인드 항목 모두 포함 - ReportedItem: blockReason 필드 추가 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -12,25 +12,29 @@
|
||||
SELECT COUNT(*) FROM report WHERE target_type = #{targetType} AND target_id = #{targetId}
|
||||
</select>
|
||||
|
||||
<!-- 신고된 글/댓글 목록 (대상별 집계). 신고 많은 순 → 최근 신고 순. -->
|
||||
<!-- 신고/스팸 글·댓글 목록. 신고 1건 이상 OR 스팸 감지 블라인드 항목을 모두 포함. -->
|
||||
<select id="listReported" resultType="com.sb.web.board.dto.ReportedItem">
|
||||
SELECT 'POST' AS targetType, r.target_id AS targetId, p.id AS postId,
|
||||
SELECT 'POST' AS targetType, p.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'
|
||||
p.block_reason AS blockReason,
|
||||
COUNT(r.id) AS reportCount, MAX(r.created_at) AS lastReportedAt
|
||||
FROM post p
|
||||
LEFT JOIN report r ON r.target_id = p.id AND r.target_type = 'POST'
|
||||
WHERE EXISTS (SELECT 1 FROM report WHERE target_type = 'POST' AND target_id = p.id)
|
||||
OR p.block_reason = '스팸 키워드 감지'
|
||||
GROUP BY p.id
|
||||
UNION ALL
|
||||
SELECT 'COMMENT' AS targetType, r.target_id AS targetId, c.post_id AS postId,
|
||||
SELECT 'COMMENT' AS targetType, c.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
|
||||
NULL AS blockReason,
|
||||
COUNT(r.id) AS reportCount, MAX(r.created_at) AS lastReportedAt
|
||||
FROM comment c
|
||||
JOIN post pp ON pp.id = c.post_id
|
||||
WHERE r.target_type = 'COMMENT'
|
||||
LEFT JOIN report r ON r.target_id = c.id AND r.target_type = 'COMMENT'
|
||||
WHERE EXISTS (SELECT 1 FROM report WHERE target_type = 'COMMENT' AND target_id = c.id)
|
||||
OR c.blocked = 1
|
||||
GROUP BY c.id
|
||||
ORDER BY reportCount DESC, lastReportedAt DESC
|
||||
</select>
|
||||
|
||||
Reference in New Issue
Block a user