Skip to content

✨ Feat: 게시글 및 댓글 신고 기능 구현 - #171

Merged
limhb708 merged 14 commits into
DoDo-Project:developfrom
limhb708:feature/170
Jun 15, 2026
Merged

✨ Feat: 게시글 및 댓글 신고 기능 구현#171
limhb708 merged 14 commits into
DoDo-Project:developfrom
limhb708:feature/170

Conversation

@limhb708

@limhb708 limhb708 commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

📄 작업 내용 (Description)

이번 PR에서 변경되거나 추가된 주요 작업을 간단히 설명해주세요.

게시글 및 댓글 신고 기능 API를 구현합니다.


🔗 관련 이슈 (Related Issues)

작업한 이슈 번호를 아래 형식으로 PULL REQUEST BODY에 작성해주세요.
(PR 머지 시 해당 이슈가 자동으로 종료됩니다.)


✅ 체크리스트 (Checklist)

PR을 보내기 전 아래 항목들을 모두 확인해주세요.

  • PR 제목은 커밋 컨벤션을 따랐습니다.
  • 관련 이슈를 연결했습니다.
  • 스스로 코드를 검토하고 불필요한 코드를 제거했습니다.
  • 코드 스타일이 프로젝트 규칙과 일치합니다. (Style)
  • 새로운 기능에 대한 테스트 코드를 추가했거나, 기존 테스트가 모두 통과했습니다. (Test)

📸 스크린샷 (Screenshots)

작업 내용과 관련된 스크린샷이 있다면 첨부해주세요. (UI 변경이 있는 경우)

Before After

💬 기타 사항 (Etc)

리뷰어에게 전달하고 싶은 추가 정보가 있다면 자유롭게 작성해주세요.

limhb708 and others added 13 commits June 12, 2026 19:25
- 내가 쓴 게시글 목록 조회 API 추가

- 내가 쓴 댓글 목록 조회 API 추가

- Board/Comment Mapper 조회 쿼리 및 페이징 처리 구현

- 댓글 응답 DTO 및 MyBatis 매퍼 XML 추가

- Service/Controller 테스트 코드 작성
- BoardMapper.xml 내 중복 findBoardList 쿼리 제거

- 중복 countPublishedBoards 쿼리 제거

- 게시글 목록 조회 시 FREE 타입 조건 유지

- MyBatis 매퍼 중복 등록으로 인한 CI 실패 수정

Closes DoDo-Project#168
- develop 병합 후 재발생한 BoardMapper.xml 중복 쿼리 제거
- CommentServiceImpl Transactional 어노테이션 순서 정리

- CommentResponse Swagger 어노테이션 제거 및 Javadoc 정리

- comment 도메인 미사용 DTO 및 메서드 참조 확인

- BoardMapper.xml 중복 findBoardList/countPublishedBoards 쿼리 제거
# Conflicts:
#	src/main/java/com/dodo/backend/board/service/BoardServiceImpl.java
- ReportRequest DTO 추가 및 신고 사유 정의

- 게시글/댓글 신고 로직 및 대상 존재 검증 구현

- 중복 신고 방지 로직 적용

- POST /reports/boards/{boardId}, /reports/comments/{commentId} API 구현

- 신고 데이터 저장 처리

- Service/Controller 테스트 코드 작성
@limhb708 limhb708 self-assigned this Jun 15, 2026
@limhb708 limhb708 added ✨ Feature 새 기능 혹은 요구 사항 🦥 임현빈 임현빈 파트 labels Jun 15, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new reporting feature allowing users to report boards, users, and comments, complete with controller endpoints, service logic, exception handling, and unit tests. The review feedback is highly constructive, highlighting opportunities to enhance database integrity with additional unique constraints for user and comment reports, prevent self-reporting, generalize shared error messages, fix copy-paste errors in Swagger documentation, and align API endpoint naming conventions for better consistency.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +40 to +45
@Table(
name = "report",
uniqueConstraints = {
@UniqueConstraint(name = "uk_report_reporter_board", columnNames = {"reporter_id", "board_id"})
}
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

현재 Report 엔티티에는 게시글 신고에 대한 유니크 제약 조건(uk_report_reporter_board)만 설정되어 있습니다.

유저 신고(reported_user_id) 및 댓글 신고(comment_id)에 대해서도 동일한 유저가 중복으로 신고하는 것을 데이터베이스 레벨에서 방지하기 위해 유니크 제약 조건을 추가하는 것이 안전합니다. 동시성 요청이 발생할 경우 애플리케이션 레벨의 existsBy... 검증을 우회하여 중복 데이터가 삽입될 수 있습니다.

@Table(
        name = "report",
        uniqueConstraints = {
                @UniqueConstraint(name = "uk_report_reporter_board", columnNames = {"reporter_id", "board_id"}),
                @UniqueConstraint(name = "uk_report_reporter_reported_user", columnNames = {"reporter_id", "reported_user_id"}),
                @UniqueConstraint(name = "uk_report_reporter_comment", columnNames = {"reporter_id", "comment_id"})
        }
)

Comment on lines +100 to +102
if (userId == null) {
throw new ReportException(INVALID_REQUEST);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

유저가 자기 자신을 신고하는 비정상적인 요청을 방지하기 위해, 신고자 ID(reporterId)와 피신고자 ID(userId)가 동일한지 검증하는 로직을 추가하는 것이 좋습니다.

Suggested change
if (userId == null) {
throw new ReportException(INVALID_REQUEST);
}
if (userId == null || reporterId.equals(userId)) {
throw new ReportException(INVALID_REQUEST);
}

Comment on lines +35 to +38
/**
* 이미 신고한 대상인 경우 사용합니다.
*/
REPORT_ALREADY_EXISTS(HttpStatus.CONFLICT, "이미 신고한 게시글입니다."),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

REPORT_ALREADY_EXISTS 에러 코드는 게시글뿐만 아니라 유저 및 댓글 신고 시에도 공통으로 사용되고 있습니다. 하지만 에러 메시지가 "이미 신고한 게시글입니다."로 고정되어 있어, 유저나 댓글을 중복 신고할 때 어색한 메시지가 반환됩니다.

메시지를 "이미 신고한 대상입니다."와 같이 범용적인 표현으로 수정하거나, 대상별로 에러 코드를 분리하는 것을 권장합니다. 여기서는 범용적인 메시지로 수정하는 방향을 제안합니다.

Suggested change
/**
* 이미 신고한 대상인 경우 사용합니다.
*/
REPORT_ALREADY_EXISTS(HttpStatus.CONFLICT, "이미 신고한 게시글입니다."),
/**
* 이미 신고한 대상인 경우 사용합니다.
*/
REPORT_ALREADY_EXISTS(HttpStatus.CONFLICT, "이미 신고한 대상입니다."),

content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "404", description = "신고할 유저를 찾을 수 없습니다.",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "409", description = "이미 신고한 게시글입니다.",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

유저 신고 API의 409 응답 설명(description)이 "이미 신고한 게시글입니다."로 잘못 작성되어 있습니다. 이를 "이미 신고한 유저입니다."로 수정하여 API 문서의 정확성을 높여주세요.

Suggested change
@ApiResponse(responseCode = "409", description = "이미 신고한 게시글입니다.",
@ApiResponse(responseCode = "409", description = "이미 신고한 유저입니다.",

content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "404", description = "신고할 댓글을 찾을 수 없습니다.",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "409", description = "이미 신고한 게시글입니다.",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

댓글 신고 API의 409 응답 설명(description)이 "이미 신고한 게시글입니다."로 잘못 작성되어 있습니다. 이를 "이미 신고한 댓글입니다."로 수정하여 API 문서의 정확성을 높여주세요.

Suggested change
@ApiResponse(responseCode = "409", description = "이미 신고한 게시글입니다.",
@ApiResponse(responseCode = "409", description = "이미 신고한 댓글입니다.",

@ApiResponse(responseCode = "500", description = "서버 내부 오류가 발생했습니다.",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
@PostMapping("/comments/{commentId}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

다른 신고 API 경로인 /board/{boardId}/user/{userId}는 단수형을 사용하고 있는 반면, 댓글 신고 API 경로는 /comments/{commentId}로 복수형을 사용하고 있어 일관성이 떨어집니다.

API 경로의 일관성을 위해 /comment/{commentId}로 수정하는 것을 권장합니다. (수정 시 관련 테스트 코드의 경로도 함께 업데이트해야 합니다.)

Suggested change
@PostMapping("/comments/{commentId}")
@PostMapping("/comment/{commentId}")

- 신고 중복 방지를 위한 유니크 제약 추가
- 자기 자신 신고 방지 검증 추가
- 중복 신고 에러 메시지 및 Swagger 설명 수정
- 댓글 신고 API 경로 단수형으로 변경
- 최신 원본 코드 병합 및 MainService 테스트 보정
- Service/Controller 테스트 코드 수정
@limhb708
limhb708 merged commit 1aae948 into DoDo-Project:develop Jun 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ Feature 새 기능 혹은 요구 사항 🦥 임현빈 임현빈 파트

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat] 게시글 및 댓글 신고 기능 구현

2 participants