Skip to content

Conversation

@ckdals4600
Copy link
Contributor

@ckdals4600 ckdals4600 commented Dec 19, 2025

관련 이슈

PR 설명

  • 사용자가 AI의 답변(메시지)에 대해 좋아요/싫어요 및 의견을 남길 수 있는 피드백 등록 API(POST) 구현
  • 유지보수성을 위해 Controller를 분리하고

작업 내용

1. API 구현 (FeedbackController)

  • Endpoint: POST /v1/messages/{messageId}/feedback
  • Request: AddFeedbackReq (감정 sentiment, 의견 text).
    • textnull 입력을 허용함.
  • Response: 생성된 feedbackId 반환.
         {
           "success": true,
           "status": "OK",
           "message": "피드백이 등록되었습니다.",
           "data": {
             "id": 15
           }
         }
  • Swagger: FeedbackApi 인터페이스를 통해 API 명세를 정의함.

2. 아키텍처 및 로직 (FeedbackFacade)

  • Facade 패턴 적용:
    • FeedbackFacade가 트랜잭션을 관리하며 MessageServiceFeedbackService를 조율함.
    • 흐름: 메시지 조회(존재 확인) -> 피드백 엔티티 생성 및 저장 -> 결과 반환.
  • Controller 분리:
    • 기존 ChatController의 비대화를 방지하기 위해 domain.chat.controller 패키지 내에 FeedbackController를 별도로 생성함.

3. Service 로직 (CQS)

  • MessageService:
    • MessageQueryService를 통해 messageId로 메시지를 조회하고, 존재하지 않을 경우 CHAT_NOT_FOUND 예외를 발생시킴.
  • FeedbackService:
    • FeedbackCommandService를 통해 피드백 데이터를 DB에 저장함.

4. 에러 처리 (MessageErrorCode)

  • 예외 정의: 메시지가 존재하지 않을 경우를 대비해 MessageErrorCode.CHAT_NOT_FOUND 에러 코드를 정의

5. 테스트 작성 (Test Coverage)

  • Integration Test (FeedbackIntegrationTest):
    • 정상 흐름: 유효한 요청 시 200 OK 응답 및 DB 저장 여부를 검증함.
    • 유효성 검사: 필수 값(sentiment) 누락 시 400 Bad Request 반환을 확인함.
    • 예외 처리: 존재하지 않는 메시지 ID로 요청 시 404 Not Found(MessageErrorCode.CHAT_NOT_FOUND) 반환을 확인함.
  • Unit Test:
    • FeedbackFacadeTest: Mocking을 통해 메시지 조회 후 피드백 저장으로 이어지는 호출 순서를 검증함.
    • FeedbackServiceTest: 요청 데이터가 올바르게 엔티티로 변환되어 저장되는지 테스트함.

@ckdals4600 ckdals4600 linked an issue Dec 19, 2025 that may be closed by this pull request
@github-actions
Copy link

github-actions bot commented Dec 19, 2025

📊 코드 커버리지 리포트

Overall Project 88.96% 🍏
Files changed 100% 🍏

File Coverage
FeedbackCommandService.java 100% 🍏
FeedbackService.java 100% 🍏
MessageQueryService.java 100% 🍏
FeedbackFacade.java 100% 🍏
FeedbackController.java 100% 🍏
MessageErrorCode.java 100% 🍏
MessageService.java 75% 🍏

@ckdals4600 ckdals4600 force-pushed the feature/#151-feedback-add-api branch from fa41066 to 5b7287f Compare December 19, 2025 12:46
@ckdals4600 ckdals4600 requested review from Goder-0 and minibr December 19, 2025 12:46
@ckdals4600 ckdals4600 self-assigned this Dec 19, 2025
@ckdals4600 ckdals4600 changed the title 메시지 피드백 등록 API 구현 (#151) 메시지 피드백 등록 API 구현 Dec 19, 2025
@ckdals4600 ckdals4600 force-pushed the feature/#151-feedback-add-api branch from 5b7287f to 11072eb Compare December 19, 2025 15:12
@ckdals4600 ckdals4600 requested a review from minibr December 19, 2025 15:22
@ckdals4600 ckdals4600 force-pushed the feature/#151-feedback-add-api branch 4 times, most recently from 02dfb6c to 2361359 Compare December 31, 2025 03:50
@ckdals4600 ckdals4600 requested a review from Goder-0 January 1, 2026 03:57
@ckdals4600 ckdals4600 force-pushed the feature/#151-feedback-add-api branch 2 times, most recently from 88317fd to 38fc9a9 Compare January 6, 2026 08:14
@ckdals4600 ckdals4600 force-pushed the feature/#151-feedback-add-api branch from 38fc9a9 to c1761bd Compare January 6, 2026 08:23
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.

메시지 피드백 등록 API 개발

4 participants