✨ Feat: 게시글 및 댓글 신고 기능 구현 - #171
Conversation
- 내가 쓴 게시글 목록 조회 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 테스트 코드 작성
There was a problem hiding this comment.
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.
| @Table( | ||
| name = "report", | ||
| uniqueConstraints = { | ||
| @UniqueConstraint(name = "uk_report_reporter_board", columnNames = {"reporter_id", "board_id"}) | ||
| } | ||
| ) |
There was a problem hiding this comment.
현재 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"})
}
)| if (userId == null) { | ||
| throw new ReportException(INVALID_REQUEST); | ||
| } |
There was a problem hiding this comment.
| /** | ||
| * 이미 신고한 대상인 경우 사용합니다. | ||
| */ | ||
| REPORT_ALREADY_EXISTS(HttpStatus.CONFLICT, "이미 신고한 게시글입니다."), |
There was a problem hiding this comment.
REPORT_ALREADY_EXISTS 에러 코드는 게시글뿐만 아니라 유저 및 댓글 신고 시에도 공통으로 사용되고 있습니다. 하지만 에러 메시지가 "이미 신고한 게시글입니다."로 고정되어 있어, 유저나 댓글을 중복 신고할 때 어색한 메시지가 반환됩니다.
메시지를 "이미 신고한 대상입니다."와 같이 범용적인 표현으로 수정하거나, 대상별로 에러 코드를 분리하는 것을 권장합니다. 여기서는 범용적인 메시지로 수정하는 방향을 제안합니다.
| /** | |
| * 이미 신고한 대상인 경우 사용합니다. | |
| */ | |
| 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 = "이미 신고한 게시글입니다.", |
There was a problem hiding this comment.
| content = @Content(schema = @Schema(implementation = ErrorResponse.class))), | ||
| @ApiResponse(responseCode = "404", description = "신고할 댓글을 찾을 수 없습니다.", | ||
| content = @Content(schema = @Schema(implementation = ErrorResponse.class))), | ||
| @ApiResponse(responseCode = "409", description = "이미 신고한 게시글입니다.", |
There was a problem hiding this comment.
| @ApiResponse(responseCode = "500", description = "서버 내부 오류가 발생했습니다.", | ||
| content = @Content(schema = @Schema(implementation = ErrorResponse.class))) | ||
| }) | ||
| @PostMapping("/comments/{commentId}") |
There was a problem hiding this comment.
다른 신고 API 경로인 /board/{boardId} 및 /user/{userId}는 단수형을 사용하고 있는 반면, 댓글 신고 API 경로는 /comments/{commentId}로 복수형을 사용하고 있어 일관성이 떨어집니다.
API 경로의 일관성을 위해 /comment/{commentId}로 수정하는 것을 권장합니다. (수정 시 관련 테스트 코드의 경로도 함께 업데이트해야 합니다.)
| @PostMapping("/comments/{commentId}") | |
| @PostMapping("/comment/{commentId}") |
- 신고 중복 방지를 위한 유니크 제약 추가 - 자기 자신 신고 방지 검증 추가 - 중복 신고 에러 메시지 및 Swagger 설명 수정 - 댓글 신고 API 경로 단수형으로 변경 - 최신 원본 코드 병합 및 MainService 테스트 보정 - Service/Controller 테스트 코드 수정
📄 작업 내용 (Description)
게시글 및 댓글 신고 기능 API를 구현합니다.
🔗 관련 이슈 (Related Issues)
✅ 체크리스트 (Checklist)
Style)Test)📸 스크린샷 (Screenshots)
💬 기타 사항 (Etc)