- report 테이블(회원당 대상별 1회), comment.blocked 컬럼
- POST /board/posts|comments/{id}/report, 본인 글/댓글 신고 불가
- 글: 5건이면 blocked(기존 열람제한 재사용) / 댓글: blocked → 비관리자 본문 숨김
- 삭제·탈퇴 시 신고 정리
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -95,6 +95,22 @@ CREATE TABLE IF NOT EXISTS comment (
|
||||
KEY idx_comment_post (post_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- 댓글 신고 누적 블라인드 플래그 (멱등)
|
||||
ALTER TABLE comment ADD COLUMN IF NOT EXISTS blocked TINYINT(1) NOT NULL DEFAULT 0 COMMENT '신고 누적 블라인드';
|
||||
|
||||
-- 신고 (글/댓글). 회원당 대상별 1회. 5건 누적 시 블라인드(관리자만 열람).
|
||||
CREATE TABLE IF NOT EXISTS report (
|
||||
id BIGINT NOT NULL AUTO_INCREMENT,
|
||||
target_type VARCHAR(10) NOT NULL COMMENT 'POST / COMMENT',
|
||||
target_id BIGINT NOT NULL,
|
||||
member_id BIGINT NOT NULL COMMENT '신고자',
|
||||
reason VARCHAR(255) NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uk_report (target_type, target_id, member_id),
|
||||
KEY idx_report_target (target_type, target_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- 게시글 추천/비추천 (회원당 1표, UP/DOWN). 같은 표 재요청 시 취소, 반대면 전환.
|
||||
CREATE TABLE IF NOT EXISTS post_vote (
|
||||
post_id BIGINT NOT NULL,
|
||||
|
||||
@@ -11,11 +11,12 @@
|
||||
<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.created_at,
|
||||
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
|
||||
@@ -24,13 +25,17 @@
|
||||
</select>
|
||||
|
||||
<select id="findById" parameterType="long" resultMap="commentResultMap">
|
||||
SELECT c.id, c.post_id, c.author_id, c.author_name, c.content, c.created_at,
|
||||
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>
|
||||
|
||||
<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)
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?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>
|
||||
|
||||
<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>
|
||||
@@ -52,7 +52,10 @@
|
||||
DELETE FROM board_image WHERE member_id = #{memberId}
|
||||
</delete>
|
||||
|
||||
<!-- 포인트 / 결제 / 세션 -->
|
||||
<!-- 신고 / 포인트 / 결제 / 세션 -->
|
||||
<delete id="deleteReportsByMember">
|
||||
DELETE FROM report WHERE member_id = #{memberId}
|
||||
</delete>
|
||||
<delete id="deletePointHistory">
|
||||
DELETE FROM point_history WHERE member_id = #{memberId}
|
||||
</delete>
|
||||
|
||||
Reference in New Issue
Block a user