Skip to content

Comments

[FEAT] 이미지 기능 재수정#40

Merged
LimdaeIl merged 6 commits intomainfrom
feat/image
Dec 8, 2025
Merged

[FEAT] 이미지 기능 재수정#40
LimdaeIl merged 6 commits intomainfrom
feat/image

Conversation

@LimdaeIl
Copy link
Collaborator

@LimdaeIl LimdaeIl commented Dec 8, 2025

📝 Pull Request

📌 PR 종류

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

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

✨ 변경 내용

단일 및 다중 WebP 변환에 대한 이미지 업로드 엔드포인트를 간소화하여 이미지 크기를 지정할 수 있습니다. 이미지 삭제 엔드포인트를 개선하여 삭제 성공 시 콘텐츠를 반환하지 않습니다. API 엔드포인트 디자인을 개선하여 명확성과 일관성을 높였습니다.

이미지 구성 및 S3 속성을 별도의 클래스로 이동하여 관리 및 테스트 편의성을 향상합니다. 동적 크기 조절을 위한 이미지 크기 구성을 도입합니다. 단일 WebP 업로드를 더욱 유연한 크기 기반 방식으로 대체하여 여러 크기를 한 번에 생성할 수 있습니다.

AWS S3 버킷 세부 정보 및 이미지 크기 제약 조건을 관리하기 위한 구성 클래스를 소개합니다. 이러한 속성은 외부 구성을 통해 관리되므로 코드를 수정하지 않고도 유연성과 조정 용이성을 제공합니다.

  • 한 개 이미지 원본 저장(dir)
  • 여러 개 이미지 원본 저장(dir)
  • 한 개 wepb 이미지 저장(dir, width, height, file)
  • 여러 개 wepb 이미지 저장(dir, width, height, file)
  • 한 개 이미지 삭제
  • 여러 개 이미지 삭제

🔍 관련 이슈

🧪 테스트

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

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

🚨 확인해야 할 사항 (Checklist)

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

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

🙋 기타 참고 사항

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

Summary by CodeRabbit

변경 사항

  • 새로운 기능

    • 이미지 업로드 시 가로/세로 크기를 지정할 수 있는 기능 추가
    • 단일 파일에서 여러 크기의 WebP 이미지를 동시에 생성 가능
  • API 개선

    • 이미지 삭제 응답이 HTTP 204 No Content로 변경
    • WebP 업로드 엔드포인트 업데이트로 차원 지정 지원

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

AWS S3 버킷 세부 정보 및 이미지 크기 제약 조건을 관리하기 위한 구성 클래스를 소개합니다. 이러한 속성은 외부 구성을 통해 관리되므로 코드를 수정하지 않고도 유연성과 조정 용이성을 제공합니다.
이미지 구성 및 S3 속성을 별도의 클래스로 이동하여 관리 및 테스트 편의성을 향상합니다. 동적 크기 조절을 위한 이미지 크기 구성을 도입합니다. 단일 WebP 업로드를 더욱 유연한 크기 기반 방식으로 대체하여 여러 크기를 한 번에 생성할 수 있습니다.
단일 및 다중 WebP 변환에 대한 이미지 업로드 엔드포인트를 간소화하여 이미지 크기를 지정할 수 있습니다. 이미지 삭제 엔드포인트를 개선하여 삭제 성공 시 콘텐츠를 반환하지 않습니다. API 엔드포인트 디자인을 개선하여 명확성과 일관성을 높였습니다.
@LimdaeIl LimdaeIl self-assigned this Dec 8, 2025
Copilot AI review requested due to automatic review settings December 8, 2025 10:20
@LimdaeIl LimdaeIl added the ✨enhancement New feature or request label Dec 8, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 8, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

이미지 업로드 서비스 리팩토링으로, 설정 주입 방식을 개선하고 WebP 이미지 크기 관련 메서드 시그니처를 확장했습니다. 새로운 설정 클래스(AwsS3Properties, ImageProperties)를 도입하고 컨트롤러 응답 처리를 정규화하며 이미지 크기를 매개변수로 전달하는 구조로 변경했습니다.

Changes

코호트 / 파일 변경 요약
설정 클래스 추가
src/main/java/team/wego/wegobackend/image/config/AwsS3Properties.java, src/main/java/team/wego/wegobackend/image/config/ImageProperties.java
S3 버킷, 퍼블릭 엔드포인트, 이미지 최대 크기 등의 설정을 외부화하기 위해 새 설정 클래스 두 개 추가(@ConfigurationProperties 기반)
도메인 모델 추가
src/main/java/team/wego/wegobackend/image/domain/ImageSize.java
이미지 너비와 높이를 담는 불변 레코드 추가
서비스 리팩토링
src/main/java/team/wego/wegobackend/image/application/service/ImageUploadService.java
@Value 필드 주입을 AwsS3Properties, ImageProperties 객체 주입으로 변경; WebP 업로드 메서드 확장(uploadAsWebpWithSize, uploadAsWebpWithSizes); 기존 uploadAllAsWebp 제거; URL 및 버킷 처리를 설정 객체로 통합
응답 처리 개선
src/main/java/team/wego/wegobackend/common/response/ApiResponse.java
Boolean.TRUE를 원시 boolean true로 변경
컨트롤러 엔드포인트 업데이트
src/main/java/team/wego/wegobackend/image/presentation/ImageController.java
WebP 업로드 메서드 시그니처 확장(width, height 파라미터 추가); 단일 및 다중 크기 업로드 지원; 삭제 엔드포인트 반환 타입을 ResponseEntity로 변경(204 No Content); 응답 페이로드 정규화
테스트 요청 업데이트
src/test/http/image/image-api.http
API 엔드포인트 및 파라미터 형식 업데이트(width/height 쿼리 파라미터 추가); 테스트 자산 및 요청 본문 조정; 오류 케이스 설명 정규화

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • ImageUploadService.java: 주입 방식 변경, 메서드 시그니처 확장, 설정 객체 기반 재구현 — 로직 이해 및 일관성 검증 필요
  • ImageController.java: 여러 엔드포인트의 파라미터 및 반환 타입 변경 — 각 엔드포인트별 검증 필요
  • 설정 클래스: 새로운 AwsS3Properties, ImageProperties 클래스의 올바른 바인딩 확인
  • 도메인 모델(ImageSize): 레코드 사용의 적절성 검증

Possibly related PRs

Poem

🐰 설정을 꺼내 정갈하게 정리하고,
이미지 크기는 이제 매개변수로 춤을 춘다네!
WebP로 변신하는 사진들, ImageSize 친구 손을 잡고,
응답은 깔끔하게, 응답은 선명하게! ✨📸

✨ 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

📜 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 5a113f5 and eb922b2.

📒 Files selected for processing (7)
  • src/main/java/team/wego/wegobackend/common/response/ApiResponse.java (1 hunks)
  • src/main/java/team/wego/wegobackend/image/application/service/ImageUploadService.java (7 hunks)
  • src/main/java/team/wego/wegobackend/image/config/AwsS3Properties.java (1 hunks)
  • src/main/java/team/wego/wegobackend/image/config/ImageProperties.java (1 hunks)
  • src/main/java/team/wego/wegobackend/image/domain/ImageSize.java (1 hunks)
  • src/main/java/team/wego/wegobackend/image/presentation/ImageController.java (4 hunks)
  • src/test/http/image/image-api.http (7 hunks)

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

@LimdaeIl LimdaeIl moved this from Backlog to In progress in WeGo-Together Backend Dec 8, 2025
@LimdaeIl LimdaeIl merged commit 3b6baef into main Dec 8, 2025
2 of 5 checks passed
@LimdaeIl LimdaeIl deleted the feat/image branch December 8, 2025 10:20
@github-project-automation github-project-automation bot moved this from In progress to Done in WeGo-Together Backend Dec 8, 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 refactors the image upload functionality by simplifying endpoints and introducing dynamic image sizing for WebP conversions. The main goal is to improve API design clarity, maintainability, and flexibility in handling various image dimensions.

Key Changes:

  • Replaced fixed-size WebP conversion with configurable size-based endpoints that accept width and height parameters
  • Introduced configuration classes (AwsS3Properties, ImageProperties) to externalize S3 and image constraints instead of using @value annotations
  • Simplified API responses by removing redundant success messages and using 204 No Content for deletions

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
ImageController.java Refactored endpoints to support dynamic sizing; replaced message-based responses with cleaner API design; removed thumbnail endpoint
ImageUploadService.java Replaced @value injections with Properties classes; consolidated WebP conversion methods to support multiple sizes; removed deprecated thumbnail upload
ImageSize.java New record to encapsulate width and height for image dimensions
ImageProperties.java Configuration class for image constraints (max size, dimensions)
AwsS3Properties.java Configuration class for AWS S3 bucket details
ApiResponse.java Changed Boolean.TRUE to primitive true for consistency
image-api.http Updated test cases to reflect new endpoint signatures and parameter requirements

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

Comment on lines +95 to +98
if (widths.size() != heights.size()) {
// 여기서 어떻게 에러를 내려줄지는 프로젝트의 공통 에러 응답 정책에 맞춰서 조정해도 됨
throw new IllegalArgumentException("widths와 heights의 길이가 일치해야 합니다.");
}
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

The error message is in Korean while other parts of the codebase may be in English. Consider internationalizing error messages or maintaining consistency with the project's language standard. Also, IllegalArgumentException should be replaced with a custom ImageException to maintain consistency with the existing error handling pattern (e.g., ImageExceptionCode).

Copilot uses AI. Check for mistakes.
Comment on lines +3 to +7
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Data
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

Using Lombok's @DaTa on a configuration properties class can expose setters unnecessarily. Consider using @Getter instead, or the more specific @ConfigurationProperties annotations pattern. Configuration properties should typically be immutable after binding.

Suggested change
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Data
import lombok.Getter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Getter

Copilot uses AI. Check for mistakes.
Comment on lines +3 to +7
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Data
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

Using Lombok's @DaTa on a configuration properties class can expose setters unnecessarily. Consider using @Getter instead to make the configuration immutable after initial binding.

Suggested change
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Data
import lombok.Getter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Getter

Copilot uses AI. Check for mistakes.
Comment on lines +136 to +141
private byte[] convertToWebpWithSize(MultipartFile file, ImageSize size) {
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
Thumbnails.of(file.getInputStream())
.size(size.width(), size.height())
.outputFormat("webp")
.toOutputStream(byteArrayOutputStream);
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

The convertToWebpWithSize method lacks documentation explaining its behavior. Specifically, it should document that Thumbnails.size() maintains aspect ratio by default, which may not produce exact dimensions if the source image has a different aspect ratio. This could lead to unexpected results when precise dimensions are required.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,4 @@
package team.wego.wegobackend.image.domain;

public record ImageSize(int width, int height) {
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

The ImageSize record lacks validation for width and height parameters. Consider adding a compact constructor to validate that width and height are positive values to prevent invalid image dimensions.

Suggested change
public record ImageSize(int width, int height) {
public record ImageSize(int width, int height) {
public ImageSize {
if (width <= 0) {
throw new IllegalArgumentException("Width must be positive, got: " + width);
}
if (height <= 0) {
throw new IllegalArgumentException("Height must be positive, got: " + height);
}
}

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