Skip to content

[DABOM-498] 상태코드 개선 작업 - #128

Merged
swthewhite merged 9 commits into
developfrom
refactor/DABOM-498
Mar 18, 2026
Merged

swthewhite merged 9 commits into
developfrom
refactor/DABOM-498

Conversation

@swthewhite

Copy link
Copy Markdown
Contributor

🍀 이슈 & 티켓 넘버


🎯 목적

프로젝트의 공통 ApiResponse 계약과 HTTP 상태 코드가 어긋난 API를 정리합니다.

  • 리소스 생성 API는 201 Created를 반환하도록 통일
  • 204 No Content와 JSON 래퍼를 동시에 사용하는 모순된 계약 수정
  • 스타일 가이드 Section 5에 따라 생성 API는 ApiResponse.created() 사용으로 통일

📝 변경 사항

  • POST /customers/signup: @ResponseStatus(HttpStatus.CREATED) 추가, ApiResponse.created() 적용
  • POST /admin/signup: @ResponseStatus(HttpStatus.CREATED) 추가, ApiResponse.created() 적용
  • POST /policies: @ResponseStatus(HttpStatus.CREATED) 추가, ApiResponse.created() 적용
  • POST /appeals: @ResponseStatus(HttpStatus.CREATED) 추가
  • POST /appeals/{appealId}/comments: @ResponseStatus(HttpStatus.CREATED) 추가
  • POST /appeals/emergency: @ResponseStatus(HttpStatus.CREATED) 추가
  • POST /missions: @ResponseStatus(HttpStatus.CREATED) 추가
  • POST /missions/{missionId}/request: @ResponseStatus(HttpStatus.CREATED) 추가, ApiResponse.created() 적용
  • DELETE /admin/rewards/templates/{id}: @ResponseStatus(HttpStatus.NO_CONTENT) 제거 → 200 OK 반환

📂 변경 범위

도메인 controller service repository entity infra global
customer [x]
admin [x]
policy [x]
appeal [x]
mission [x]
reward [x]

🖥️ 주요 코드 설명

// 생성 API에 @ResponseStatus(HttpStatus.CREATED) 추가 (Option A 방식)
@PostMapping("/signup")
@ResponseStatus(HttpStatus.CREATED)
@Operation(summary = "사용자 회원가입")
public ApiResponse<SignUpResponse> signUp(...) {
    return ApiResponse.created(customerService.signUp(requestDto));
}
// 삭제 API에서 204 선언 제거 — ApiResponse.success(null) 반환 시 200 OK가 올바른 상태 코드
@DeleteMapping("/{id}")
@AdminOnly
// @ResponseStatus(HttpStatus.NO_CONTENT) ← 제거
@Operation(summary = "보상 템플릿 삭제")
public ApiResponse<Void> deleteTemplate(...) {
    rewardTemplateService.deleteTemplate(id);
    return ApiResponse.success(null);
}

💬 리뷰어에게

  • ApiResponse.created()는 래퍼의 message 필드만 변경하고 HTTP 상태 코드는 바꾸지 않으므로, @ResponseStatus 어노테이션으로 실제 상태 코드를 제어합니다.
  • controller 레이어만 변경하며, service/repository/entity 변경은 없습니다.
  • Spotless / Checkstyle 검증 통과 확인 완료.

📋 체크리스트

기본

  • Merge 대상 브랜치가 올바른가?
  • ./gradlew build가 정상적으로 통과하는가?
  • Spotless / Checkstyle을 통과하는가? (./gradlew spotlessApply checkstyleMain)
  • 전체 변경사항이 500줄을 넘지 않는가?

코드 품질

  • 의존성 방향을 준수하는가? (Controller → Service → Repository → Entity)
  • Setter 없이 비즈니스 메서드로 상태를 변경하는가?
  • @Transactional은 Service에만 선언했는가?

테스트

  • 신규 비즈니스 로직에 대한 단위 테스트를 작성했는가?

📌 참고 사항

  • 변경 파일 6개, 변경사항 총 27줄 (추가 22줄, 삭제 5줄)
  • 비즈니스 로직 변경 없이 상태 코드와 응답 래퍼 메서드만 수정
  • 프런트엔드가 200 + success=true에 의존하는 경우 배포 전 클라이언트 영향 확인 필요

- POST /customers/signup: @ResponseStatus(HttpStatus.CREATED) 추가
- POST /admin/signup: @ResponseStatus(HttpStatus.CREATED) 추가
- 리소스 생성 API는 201 Created를 반환하도록 통일
- POST /policies: @ResponseStatus(HttpStatus.CREATED) 추가
- POST /appeals: @ResponseStatus(HttpStatus.CREATED) 추가
- POST /appeals/{appealId}/comments: @ResponseStatus(HttpStatus.CREATED) 추가
- POST /appeals/emergency: @ResponseStatus(HttpStatus.CREATED) 추가
- POST /missions: @ResponseStatus(HttpStatus.CREATED) 추가
- POST /missions/{missionId}/request: @ResponseStatus(HttpStatus.CREATED) 추가
- DELETE /admin/rewards/templates/{id}: @ResponseStatus(HttpStatus.NO_CONTENT) 제거
- ApiResponse.success(null) 반환 시 200 OK가 올바른 상태 코드
- 204 No Content와 JSON 래퍼 동시 사용은 계약 모순
- POST /customers/signup: ApiResponse.success() → ApiResponse.created()
- POST /admin/signup: ApiResponse.success() → ApiResponse.created()
- 스타일 가이드 Section 5 생성 API 응답 규칙 준수
- POST /policies: ApiResponse.success() → ApiResponse.created()
- 스타일 가이드 Section 5 생성 API 응답 규칙 준수
- POST /missions/{missionId}/request: ApiResponse.success() → ApiResponse.created()
- 스타일 가이드 Section 5 생성 API 응답 규칙 준수
@github-actions
github-actions Bot requested a review from ChoiSeungeon March 18, 2026 12:38
@github-actions github-actions Bot added fix 버그 수정 refactor 리팩토링 size/S PR size: S labels Mar 18, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 프로젝트의 API 응답 상태 코드 일관성을 강화하기 위해 진행되었습니다. 기존에 ApiResponse 계약과 HTTP 상태 코드가 불일치했던 부분을 개선하여, 리소스 생성 시에는 201 Created를, 특정 삭제 작업 후에는 200 OK를 명확하게 반환하도록 수정했습니다. 이를 통해 API의 예측 가능성을 높이고 클라이언트와의 계약을 더욱 견고하게 만들었습니다.

Highlights

  • API 응답 일관성 개선: 리소스 생성 API가 201 Created를 반환하도록 통일하고, 204 No Content와 JSON 래퍼의 모순된 사용을 수정했습니다.
  • HTTP 상태 코드 명확화: 생성 API에 ApiResponse.created()를 적용하고 @ResponseStatus(HttpStatus.CREATED) 어노테이션을 추가하여 실제 HTTP 상태 코드를 명시적으로 제어합니다.
  • 삭제 API 응답 변경: ApiResponse.success(null)을 반환하는 삭제 API에서 204 No Content 어노테이션을 제거하여 200 OK가 반환되도록 변경했습니다.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

이 PR은 API 응답의 일관성을 높이기 위해 HTTP 상태 코드를 개선하는 좋은 변경입니다. 리소스 생성을 위한 POST 엔드포인트들에 201 Created 상태 코드를 일관되게 적용하고, 응답 본문이 있는 DELETE 요청에서 204 No Content를 제거한 점이 인상적입니다. 이러한 변경은 RESTful API 설계 원칙에 더 잘 부합하며 프로젝트의 코드 품질을 향상시킵니다.

다만, 한 가지 아쉬운 점은 컨트롤러의 상태 코드 변경에 따른 통합 테스트 코드의 수정이 누락된 것으로 보입니다. 예를 들어, MissionControllerIntegrationTest에서 POST /missionsPOST /missions/{missionId}/request API의 상태 코드 기댓값이 여전히 200 OK로 되어 있어 테스트가 실패할 가능성이 있습니다. PR을 머지하기 전에 관련 테스트 코드를 201 Created를 기대하도록 수정하는 것을 강력히 권장합니다.

- MissionControllerIntegrationTest: POST /missions, POST /missions/{id}/request 기댓값 isCreated()로 변경
- RewardControllerIntegrationTest: POST /missions/{id}/request 기댓값 isCreated()로 변경
- 컨트롤러 @ResponseStatus(HttpStatus.CREATED) 추가에 따른 테스트 동기화
@github-actions

Copy link
Copy Markdown

SonarQube Quality Summary (Community)

Quality Gate PASSED

Branch: refactor/DABOM-498
Compared to: default branch

Issues

  • 🐞 Bugs: 7
  • 🔐 Vulnerabilities: 0
  • 📎 Code Smells: 93

Measures

  • Coverage: 0%
  • Duplication: 0%

🔗 Dashboard: https://sonarqube.swthewhite.store/dashboard?id=dabom-api-core&branch=refactor/DABOM-498

Generated automatically by GitHub Actions.

@ChoiSeungeon ChoiSeungeon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

확인했습니다.

@swthewhite
swthewhite merged commit 35a7232 into develop Mar 18, 2026
10 checks passed
@swthewhite
swthewhite deleted the refactor/DABOM-498 branch March 18, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix 버그 수정 refactor 리팩토링 size/S PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DABOM-498] 상태코드 개선 작업

2 participants