Skip to content

[4주차] 김다인/[feat] 신고 API 구현#169

Open
kallin1 wants to merge 1 commit into김다인/mainfrom
김다인/4주차

Hidden character warning

The head ref may contain hidden characters: "\uae40\ub2e4\uc778/4\uc8fc\ucc28"
Open

[4주차] 김다인/[feat] 신고 API 구현#169
kallin1 wants to merge 1 commit into김다인/mainfrom
김다인/4주차

Conversation

@kallin1
Copy link
Copy Markdown

@kallin1 kallin1 commented Apr 28, 2026

1. 과제 요구사항 중 구현한 내용

  • 게시물 및 댓글 신고 API
  • 신고 목록 조회 API
  • 신고처리 API

2. 핵심 변경 사항

  • Controller/Service/Repository 계층 설계: 신고 기능을 위한 엔티티 및 DTO 설계 및 비즈니스 로직 구현
  • API 엔드포인트 추가: 신고 관련 기능을 위한 API 명세 작성

3. 실행 및 검증 결과

  1. 게시물/댓글 신고 API (POST /api/reports)
    요청
{
    "targetId": 105,
    "targetType": "POST",
    "reason": "부적절한 홍보성 게시글입니다."
}

응답

{
    "status": "SUCCESS",
    "message": "신고가 정상적으로 접수되었습니다.",
    "reportId": 1
}
  1. 신고 목록 조회 API (GET /api/reports)
    응답
{
    "content": [
        {
            "reportId": 1,
            "targetId": 105,
            "targetType": "POST",
            "reporter": "userA",
            "reason": "부적절한 홍보성 게시글입니다.",
            "createdAt": "2026-04-29T12:00:00"
        }
    ],
    "totalElements": 1,
    "totalPages": 1
}
  1. 신고 처리 API (PATCH /api/reports/{reportId})
    요청
{
    "status": "PROCESSED"
}

응답

{
    "reportId": 1,
    "status": "PROCESSED",
    "message": "신고 처리가 완료되었습니다."
}

4. 완료 사항

  1. API 요구사항 및 상태코드 검증
  2. 비즈니스 로직 테스트
  3. 계층 구조 분리

5. 추가 사항

  • 관련 이슈: closed #148

제출 체크리스트

  • PR 제목이 규칙에 맞다
  • base가 {이름}/main 브랜치다
  • compare가 {이름}/{숫자}주차 브랜치다
  • 프로젝트가 정상 실행된다
  • 본인을 Assignee로 지정했다
  • 파트 담당 Reviewer를 지정했다
  • 리뷰 피드백을 반영한 뒤 머지/PR close를 진행한다

Reviewer 참고

@kallin1 kallin1 requested a review from a team April 28, 2026 15:16
@kallin1 kallin1 self-assigned this Apr 28, 2026
@HandoA01
Copy link
Copy Markdown

4주차 개발도 수고 많으셨습니다 !


// 게시글 작성
@PostMapping
public ResponseEntity<Map<String, Object>> create(@Valid @RequestBody PostCreateRequest 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.

DTO 형태가 아닌 Map으로 반환하신 이유가 궁금합니다!

private final ReportService reportService;

@PostMapping
public ResponseEntity<Void> report(@RequestBody ReportRequest 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.

뭔가 void 말고 다른 응답 상태가 있으면 더 좋을 것 같아요!!

@MappedSuperclass
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
@SuperBuilder
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@builder는 단일 클래스에서 객체 생성을 편하게 해주는 용도로 알고 있었는데, 상속 구조에서는 @SuperBuilder를 사용할 수도 있었네요

Comment on lines +29 to +30
request.targetId(), request.targetType(), request.reporterId())) {
throw new RuntimeException("이미 신고한 항목입니다.");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

여기 부분 혹시 의도가 있으셨을까요? 저는 DuplicateReportException 같은 커스텀 예외 + GlobalExceptionHandler로 일관된 에러 응답을 보내는 식으로 처리해서, 클라이언트 입장에서 어떤 에러 형태로 오는지 궁금합니다!

Comment on lines +50 to +54
if (!approve) { // 반려(REJECT) 시 활성 상태로 복구
Reportable target = findTarget(report.getTargetId(), report.getTargetType());
target.updateStatus(ContentStatus.ACTIVE);
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

신고 처리에서 반려 시 콘텐츠를 다시 ACTIVE로 되돌리는 로직 좋은것 같습니다! 이부분은 저도 참고하도록 하겠습니다!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants