Skip to content

[FEAT] 이미지 응답을 공통 응답으로 수정#30

Merged
LimdaeIl merged 2 commits intomainfrom
feat/image-response-format
Dec 7, 2025
Merged

[FEAT] 이미지 응답을 공통 응답으로 수정#30
LimdaeIl merged 2 commits intomainfrom
feat/image-response-format

Conversation

@LimdaeIl
Copy link
Collaborator

@LimdaeIl LimdaeIl commented Dec 7, 2025

📝 Pull Request

📌 PR 종류

해당하는 항목에 체크해주세요.

  • 기능 추가 (Feature)
  • 버그 수정 (Fix)
  • 문서 수정 (Docs)
  • 코드 리팩터링 (Refactor)
  • 테스트 추가 (Test)
  • 기타 변경 (Chore)

✨ 변경 내용

ResponseEntity로 감싸서 ApiResponse 공통 응답 클래스 형식으로 응답하도록 합니다. 정리하자면, HTTP의 의미(상태 코드, 헤더)는 ResponseEntity로, 본문의 구조(우리 서비스의 JSON 규칙)는 ApiResponse로 나눠서 맡기는 구조입니다.

둘을 분리해서 쓰기 때문에 HTTP 표준도 잘 지키고 프론트/도메인 입장에서도 일관된 응답 구조를 유지할 수 있어서 확장성과 유지보수가 훨씬 좋아집니다.나중에 Location 헤더나 Set-Cookie 같은 것도 한 번 붙여보면 ResponseEntity를 사용하고, ApiResponse 사용하는 메리트를 크게 느낄 수 있습니다.

🔍 관련 이슈

🧪 테스트

변경된 기능에 대한 테스트 범위 또는 테스트 결과를 작성해주세요.

  • 유닛 테스트 추가 / 수정
  • 통합 테스트 검증
  • 수동 테스트 완료

🚨 확인해야 할 사항 (Checklist)

PR을 제출하기 전에 아래 항목들을 확인해주세요.

  • 코드 포매팅 완료
  • 불필요한 파일/코드 제거
  • 로직 검증 완료
  • 프로젝트 빌드 성공
  • 린트/정적 분석 통과 (해당 시)

🙋 기타 참고 사항

리뷰어가 참고하면 좋을 만한 추가 설명이 있다면 적어주세요.

Summary by CodeRabbit

API 개선

  • API 개선
    • 이미지 업로드 및 삭제 엔드포인트가 표준화된 응답 형식 제공
    • 모든 API 응답이 명확한 HTTP 상태 코드와 메시지 포함
    • 이미지 삭제 작업에서 이제 명확한 확인 응답 반환
    • 응답 코드에 정수 값 직접 지정 가능

✏️ Tip: You can customize this high-level summary in your review settings.

@LimdaeIl LimdaeIl self-assigned this Dec 7, 2025
Copilot AI review requested due to automatic review settings December 7, 2025 04:58
@LimdaeIl LimdaeIl added the ✨enhancement New feature or request label Dec 7, 2025
@LimdaeIl LimdaeIl moved this from Backlog to In progress in WeGo-Together Backend Dec 7, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 7, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

공통 응답 형식으로 표준화하기 위해 ApiResponse에 정수형 코드를 받는 두 개의 오버로드 메서드를 추가하고, ImageController의 모든 이미지 업로드/삭제 엔드포인트를 ResponseEntity<ApiResponse<...>> 래퍼로 감싸는 형식으로 수정하여 일관된 응답 구조 제공.

Changes

Cohort / File(s) Summary
ApiResponse 메서드 확장
src/main/java/team/wego/wegobackend/common/response/ApiResponse.java
success(int code, String message, T data), success(int code, String message) 오버로드 메서드 추가로 정수형 코드 직접 수용 가능하도록 확장
ImageController 응답 형식 표준화
src/main/java/team/wego/wegobackend/image/presentation/ImageController.java
이미지 업로드/삭제 7개 엔드포인트 모두를 ResponseEntity<ApiResponse<...>> 반환 타입으로 수정하고 HttpStatus.CREATED(201), OK(200) 등 명시적 상태 코드 및 메시지 추가

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

  • ImageController의 반복적인 패턴 변경: 7개 메서드에서 동일한 리팩토링 패턴이 반복 적용되므로 첫 번째 메서드 검토 후 이후는 일관성 확인에 집중 가능
  • ApiResponse 오버로드의 위임 로직: 새로 추가된 메서드들이 기존 생성자로 올바르게 위임하는지 검증 필요
  • HTTP 상태 코드 할당의 적절성: 각 엔드포인트(생성 201 vs 삭제 200)에서 올바른 상태 코드가 할당되었는지 확인
  • null 데이터 처리: 삭제 엔드포인트에서 Void 타입으로 감싼 응답 구조의 일관성 검토

Possibly related PRs

  • [FEAT] 공통 예외 처리 구현 #26: ApiResponse 클래스의 같은 success 팩토리 메서드에 문자열 기반 오버로드를 먼저 추가했으며, 현재 PR에서 추가되는 정수 코드 오버로드가 이 메서드들을 위임하는 구조로 연결됨
  • [FEAT] S3 이미지 업로드 구현 #24: 현재 PR과 동일한 ImageController 클래스와 메서드들을 수정하며, 이전 PR에서 원본 엔드포인트 메서드들을 도입했고 현재 PR에서 응답 형식을 표준화하는 직접적인 후속 작업

Poem

🐰 숫자 코드도 쏙! ApiResponse에 담고,
이미지 엔드포인트는 하나의 옷을 입고
201, 200 상태 코드 반짝반짝,
공통 응답의 조화로운 춤사위—
표준화의 마법이 스며든다! ✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/image-response-format

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6ab1268 and f779adf.

📒 Files selected for processing (2)
  • src/main/java/team/wego/wegobackend/common/response/ApiResponse.java (1 hunks)
  • src/main/java/team/wego/wegobackend/image/presentation/ImageController.java (2 hunks)

Comment @coderabbitai help to get the list of available commands and usage tips.

@LimdaeIl LimdaeIl merged commit ea5bea9 into main Dec 7, 2025
4 of 5 checks passed
@LimdaeIl LimdaeIl deleted the feat/image-response-format branch December 7, 2025 04:58
@github-project-automation github-project-automation bot moved this from In progress to Done in WeGo-Together Backend Dec 7, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR standardizes image API responses by wrapping them with ResponseEntity and ApiResponse to provide consistent HTTP status codes, headers, and response body structure across all image endpoints.

Key Changes:

  • All image controller endpoints now return ResponseEntity<ApiResponse<T>> instead of direct DTOs
  • Added new ApiResponse.success() overloaded methods accepting int parameters for status codes
  • Updated all POST endpoints to return HTTP 201 CREATED and DELETE endpoints to return HTTP 200 OK

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
ImageController.java Wrapped all endpoint responses with ResponseEntity and ApiResponse, added appropriate HTTP status codes and descriptive messages
ApiResponse.java Added convenience methods accepting int status codes to simplify controller usage

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +24 to +32
public static <T> ApiResponse<T> success(int code, String message, T data) {
return new ApiResponse<>(String.valueOf(code), message, data);
}

public static <T> ApiResponse<T> success(int code, String message) {
return new ApiResponse<>(String.valueOf(code), message, null);
}


Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

There's a parameter type inconsistency in the new overloaded methods. The existing success methods accept String code parameter, but the new methods accept int code and convert it to String internally. This creates an inconsistent API where callers must remember which overload accepts which type. Consider making all methods consistently accept String or consistently accept int to improve the API design.

Suggested change
public static <T> ApiResponse<T> success(int code, String message, T data) {
return new ApiResponse<>(String.valueOf(code), message, data);
}
public static <T> ApiResponse<T> success(int code, String message) {
return new ApiResponse<>(String.valueOf(code), message, null);
}

Copilot uses AI. Check for mistakes.

return ResponseEntity
.ok(ApiResponse.success(
HttpStatus.CREATED.toString(),
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

The HTTP status code is incorrect. The deleteOne operation returns 200 OK (via ResponseEntity.ok()), but the message body incorrectly contains HttpStatus.CREATED (201). This should be HttpStatus.OK.value() to match the actual response status.

Suggested change
HttpStatus.CREATED.toString(),
HttpStatus.OK.value(),

Copilot uses AI. Check for mistakes.
return new ApiResponse<>(String.valueOf(code), message, null);
}


Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

[nitpick] Extra blank line should be removed for consistency with the rest of the file formatting.

Suggested change

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[FEAT] 이미지 응답을 공통 응답으로 수정

1 participant