Skip to content

[4주차] 이예서/[feat] 추가 API 구현#164

Open
HandoA01 wants to merge 2 commits intoLeets-Official:이예서/mainfrom
HandoA01:이예서/4주차

Hidden character warning

The head ref may contain hidden characters: "\uc774\uc608\uc11c/4\uc8fc\ucc28"
Open

[4주차] 이예서/[feat] 추가 API 구현#164
HandoA01 wants to merge 2 commits intoLeets-Official:이예서/mainfrom
HandoA01:이예서/4주차

Conversation

@HandoA01
Copy link
Copy Markdown

@HandoA01 HandoA01 commented Apr 28, 2026

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

  • 게시물 신고 (POST /posts/{postId}/reports)
  • 신고 처리 완료 (PATCH /reports/{reportId}/resolve) — PENDING → RESOLVED
  • 게시물 숨김 (PATCH /posts/{postId}/hide) — ACTIVE → HIDDEN
  • 도메인 상태 변화 반영 + 중복 처리 방지 로직 포함

2. 핵심 변경 사항

  • PostStatus (ACTIVE/HIDDEN) enum 및 Post 엔티티 상태 필드 추가
  • Report 도메인 신규 생성 (entity, repository, service, controller, dto, converter)
  • (user_id, post_id) 복합 유니크로 중복 신고 차단
  • 신규 예외 4종 + GlobalExceptionHandler 핸들러 추가

3. 실행 및 검증 결과

Postman으로 9개 시나리오 모두 정상 동작 확인 완료

  • 정상 케이스: 신고/처리/숨김
  • 중복 처리 방지: 중복 신고/중복 처리/중복 숨김 → 409 Conflict
  • 권한 검증: 작성자 아닌 사용자의 숨김 시도 → 403 Forbidden
  • 목록 조회 시 HIDDEN 게시글 제외 확인

기본 헬스체크 정상 동작 확인
스크린샷 2026-03-31 오후 10 39 39

빈 배열 응답
스크린샷 2026-04-07 오후 9 48 57

스크린샷 2026-04-28 오후 11 33 12 스크린샷 2026-04-28 오후 11 34 15 스크린샷 2026-04-28 오후 11 35 18

중복 신고 차단
스크린샷 2026-04-28 오후 11 36 22

신고 처리 완료
스크린샷 2026-04-28 오후 11 36 45
중복 처리 차단

4. 완료 사항

  • 신규 API 3개 구현
  • 도메인 상태 enum 및 상태 전이 로직
  • 중복 처리 방지 (DB 유니크 제약 + 서비스 레벨 검증)
  • 예외 처리 통합
  • Postman 동작 테스트

5. 추가 사항

  • 관련 이슈: closed #이슈번호
  • 기존 BaseEntity / 소프트 딜리트 패턴 유지
  • 3주차 X-USER-ID 헤더 인증 방식 동일 적용
  • API 경로는 RESTful + 액션형 혼합 (자원 생성은 RESTful, 상태 전이는 /hide, /resolve)

제출 체크리스트

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

Reviewer 참고

@HandoA01 HandoA01 requested a review from a team April 28, 2026 14:49
@HandoA01 HandoA01 self-assigned this Apr 28, 2026
@HandoA01 HandoA01 changed the title 이예서/4주차 [4주차] 이예서/[feat] 추가 API 구현 Apr 30, 2026
@@ -0,0 +1,6 @@
package com.example.blog.domain.post.entity;

public enum PostStatus {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

상태 변환 ENUM 사용하신 거 좋습니다!

}

// 게시글 삭제 (soft delete)
// 게시글 삭제
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

주석에 soft delete를 지우셨는데 그렇다면 이제 soft delete가 아닌건가요??

DUPLICATE_REPORT(HttpStatus.CONFLICT, "409_001", "이미 신고한 게시글입니다."),
ALREADY_RESOLVED(HttpStatus.CONFLICT, "409_002", "이미 처리 완료된 신고입니다."),
ALREADY_HIDDEN(HttpStatus.CONFLICT, "409_003", "이미 숨김 처리된 게시글입니다."),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

이넘에서 에러케이스를 꼼꼼하게 작성해서 관리하신점이 좋은것 같아요!

// PATCH /posts/{postId}/hide - 게시글 숨김
@PatchMapping("/{postId}/hide")
public ApiResponse<Void> hidePost(
@RequestHeader("X-USER-ID") Long userId,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

사용자가 자신의 게시물을 숨기게 할 수 있는 로직 같은데 관리자가 아닌 사용자를 헤더로 체크하신 이유가 있나요? 그리고 게시물 숨김 후에 다시 활성화 하는 부분을 구현할 예정이 있으신지 궁금합니다!

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