Skip to content

Conversation

@joyewon0705
Copy link
Collaborator

@joyewon0705 joyewon0705 commented Oct 4, 2025

📌 개요

  • 게시글의 댓글에 대댓글(1 depth)을 작성할 수 있는 기능을 추가했습니다.
  • 서비스, 컨트롤러, 테스트, Swagger 문서까지 통합 구현했습니다.

🔨 작업 내용

1. 기능 구현

  • POST /api/posts/{postId}/comments/{commentId}/replies

    • 로그인한 사용자가 특정 게시글의 댓글에 대댓글을 작성할 수 있도록 구현
    • 대댓글은 1단계까지만 허용 (대댓글의 대댓글 작성 불가)
  • CommentService#createReply()

    • 사용자, 게시글, 부모 댓글 조회
    • 부모 댓글의 게시글 일치 및 depth 검증 로직 추가
    • 검증 통과 시 Comment 엔티티 생성 후 저장

2. DTO 추가

  • ReplyResponse
    • commentId, postId, parentId, author, content, createdAt, updatedAt 포함
    • ReplyResponse.from(Comment comment) 팩토리 메서드 추가

3. 예외 코드 추가

  • COMMENT_PARENT_MISMATCH: 부모 댓글이 해당 게시글에 속하지 않습니다.
  • COMMENT_DEPTH_EXCEEDED: 대댓글은 한 단계까지만 작성할 수 있습니다.

4. 테스트 코드 작성

Service 테스트 (CommentServiceTest)

  • 대댓글 생성 성공 및 예외 케이스 테스트
  • 대댓글 수정 성공 (updateComment)
  • 대댓글 삭제 성공 (deleteComment)

Controller 테스트 (CommentControllerTest)

  • 대댓글 생성 성공/실패 케이스 테스트
  • 기존 댓글 수정/삭제 API를 통한 대댓글 수정·삭제 테스트 추가

5. Swagger 문서 작성 (CommentControllerDocs)

  • 대댓글 생성 API 명세 추가
  • 성공 및 예외 응답 예시 포함 (201, 400, 401, 404, 500)

🔗 관련 이슈

Closes #177

📝 참고 사항

  • 대댓글 수정/삭제는 기존 댓글 수정/삭제 API를 통해 가능합니다.

✅ 체크리스트

  • 기능 동작 확인
  • 테스트 코드 작성
  • 문서/주석 추가 및 최신화

@github-actions github-actions bot changed the title Feat: 대댓글 생성 API 구현 Feat: 대댓글 생성 API 구현 (#177) Oct 4, 2025
@joyewon0705 joyewon0705 merged commit 37729d2 into dev Oct 4, 2025
2 checks passed
@github-actions github-actions bot deleted the Feat/177 branch October 4, 2025 13:45
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