Skip to content

Conversation

@Kimminu7
Copy link
Collaborator

@Kimminu7 Kimminu7 commented Jun 28, 2025

작업 내용

  • 문제 수정, 삭제시 이미지가 있다면, DB뿐만 아니라 AWS S3 버킷 내에서도 해당하는 파일이 수정되거나 삭제되게 구현

변경 사항


트러블 슈팅


해결해야 할 문제


참고 사항

image

  • 문제 수정, 삭제 API 호출시, 이미지가 있다면 AWS 내에서 해당하는 API에 맞게 파일 변화가 생김.

코드 리뷰 전 확인 체크리스트

  • 불필요한 콘솔 로그, 주석 제거
  • 커밋 메시지 컨벤션 준수 (type : )
  • 기능 정상 동작 확인

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • 문제 수정 시 이미지 파일을 함께 업로드할 수 있도록 지원합니다.
    • 문제에 등록된 이미지를 모두 삭제하는 기능이 추가되었습니다.
    • S3에서 이미지 삭제 기능이 추가되었습니다.
  • Bug Fixes

    • 문제 삭제 시 연관된 이미지가 S3에서 함께 삭제됩니다.
  • Documentation

    • 문제 생성 및 수정 요청의 카테고리 필드 사용법에 대한 주석이 추가되었습니다.

@Kimminu7 Kimminu7 self-assigned this Jun 28, 2025
@Kimminu7 Kimminu7 added the enhancement New feature or request label Jun 28, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jun 28, 2025

"""

Walkthrough

문제 수정 시 이미지 파일을 교체하거나 삭제할 수 있도록 S3 이미지 삭제 기능이 추가되었습니다. 컨트롤러, 서비스, S3 업로더, 예외 코드, 엔티티에 필요한 메서드 및 파라미터가 도입되었으며, 일부 DTO 주석이 보완되었습니다.

Changes

파일/경로 변경 요약
.../dto/request/ProblemCreateRequest.java
.../dto/request/ProblemUpdateRequest.java
categories 필드에 타입에 맞는 괄호 사용법을 명시하는 주석 추가
.../service/ProblemService.java modifyProblem 메서드에 이미지 파일 파라미터 및 이미지 교체/삭제 로직 추가, removeProblem에 이미지 삭제 로직 추가, createCategory 공백 수정
.../entity/Problem.java 이미지 URL 리스트를 비우는 clearImages() 메서드 추가, 기존 메서드 포맷 수정
.../infrastructure/s3/S3Uploader.java 이미지 URL을 받아 S3에서 삭제하는 delete(String imageUrl) 메서드 및 키 추출 헬퍼 추가
.../exception/code/S3ExceptionCode.java S3_DELETE_FAILED 예외 코드 추가, 기존 메시지 공백 수정
.../presentation/problemmanagement/problem/ProblemAdminController.java 문제 수정 엔드포인트가 multipart/form-data를 지원하도록 변경, 이미지 파일 파라미터 추가

Sequence Diagram(s)

sequenceDiagram
    participant Admin as Admin Client
    participant Controller as ProblemAdminController
    participant Service as ProblemService
    participant S3 as S3Uploader
    participant Problem as Problem Entity

    Admin->>Controller: PUT /problems/{id} (multipart/form-data: request + image)
    Controller->>Service: modifyProblem(problemId, request, image)
    alt 이미지가 첨부됨
        Service->>S3: delete(oldImageUrl)
        S3-->>Service: 삭제 성공/실패
        Service->>S3: upload(newImage)
        S3-->>Service: newImageUrl
        Service->>Problem: clearImages()
        Service->>Problem: addImage(newImageUrl)
    end
    Service-->>Controller: 완료
    Controller-->>Admin: 200 OK
Loading

Possibly related PRs

Suggested reviewers

  • NCookies
  • pokerbearkr
  • minjee2758
  • chat26666

Poem

🐇
새 이미지를 첨부하면,
오래된 사진은 안녕!
S3에서 깔끔하게 삭제,
문제엔 새 옷 입히기.
코드도 주석도 한층 더,
토끼는 오늘도 즐겁게 hop!

"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6788dfd and 72ad63f.

📒 Files selected for processing (2)
  • src/main/java/org/ezcode/codetest/application/problem/service/ProblemService.java (5 hunks)
  • src/main/java/org/ezcode/codetest/infrastructure/s3/S3Uploader.java (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/java/org/ezcode/codetest/infrastructure/s3/S3Uploader.java
  • src/main/java/org/ezcode/codetest/application/problem/service/ProblemService.java
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 68905d3 and 6447157.

📒 Files selected for processing (7)
  • src/main/java/org/ezcode/codetest/application/problem/dto/request/ProblemCreateRequest.java (1 hunks)
  • src/main/java/org/ezcode/codetest/application/problem/dto/request/ProblemUpdateRequest.java (1 hunks)
  • src/main/java/org/ezcode/codetest/application/problem/service/ProblemService.java (5 hunks)
  • src/main/java/org/ezcode/codetest/domain/problem/model/entity/Problem.java (1 hunks)
  • src/main/java/org/ezcode/codetest/infrastructure/s3/S3Uploader.java (2 hunks)
  • src/main/java/org/ezcode/codetest/infrastructure/s3/exception/code/S3ExceptionCode.java (1 hunks)
  • src/main/java/org/ezcode/codetest/presentation/problemmanagement/problem/ProblemAdminController.java (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: chat26666
PR: ezcode-my/backend#37
File: src/main/java/org/ezcode/codetest/infrastructure/elasticsearch/repository/ProblemElasticsearchRepositoryDsl.java:10-10
Timestamp: 2025-06-06T19:56:27.759Z
Learning: When user chat26666 mentions that code was implemented in a previous PR but explanation was missing, they may submit a follow-up PR just to add documentation/explanation without the actual implementation code.
src/main/java/org/ezcode/codetest/application/problem/dto/request/ProblemCreateRequest.java (1)
Learnt from: Kimminu7
PR: ezcode-my/backend#63
File: src/main/java/org/ezcode/codetest/infrastructure/persistence/repository/problem/ProblemQueryRepositoryImpl.java:24-40
Timestamp: 2025-06-14T14:33:58.372Z
Learning: ProblemController에서 ProblemSearchCondition 객체는 항상 new ProblemSearchCondition(category, difficulty)로 유효한 인스턴스를 생성해서 전달하므로, ProblemQueryRepositoryImpl의 searchByCondition 메서드에서 searchCondition 파라미터 자체에 대한 null 체크는 불필요하다. category와 difficulty 필드만 각각 null일 수 있다.
src/main/java/org/ezcode/codetest/application/problem/service/ProblemService.java (3)
Learnt from: Kimminu7
PR: ezcode-my/backend#63
File: src/main/java/org/ezcode/codetest/infrastructure/persistence/repository/problem/ProblemQueryRepositoryImpl.java:24-40
Timestamp: 2025-06-14T14:33:58.372Z
Learning: ProblemController에서 ProblemSearchCondition 객체는 항상 new ProblemSearchCondition(category, difficulty)로 유효한 인스턴스를 생성해서 전달하므로, ProblemQueryRepositoryImpl의 searchByCondition 메서드에서 searchCondition 파라미터 자체에 대한 null 체크는 불필요하다. category와 difficulty 필드만 각각 null일 수 있다.
Learnt from: chat26666
PR: ezcode-my/backend#31
File: src/main/java/org/ezcode/codetest/domain/problem/model/entity/ProblemSearchDocument.java:49-56
Timestamp: 2025-06-05T00:52:54.460Z
Learning: ProblemSearchDocument.from() 메서드는 트랜잭션 내에서 DB에서 실제로 조회한 Problem 엔티티만 사용하므로 null 체크가 불필요함. 이 컨텍스트에서는 null Problem이 있을 경우 이미 이전 단계에서 예외가 발생함.
Learnt from: chat26666
PR: ezcode-my/backend#31
File: src/main/java/org/ezcode/codetest/domain/problem/service/ProblemDomainService.java:25-27
Timestamp: 2025-06-04T15:11:19.343Z
Learning: In ProblemDomainService, when saving problems to both database and Elasticsearch, maintain transactional consistency by allowing rollback if either save operation fails. Data integrity between DB and ES is prioritized over availability - if Elasticsearch save fails, the entire transaction should roll back to prevent data inconsistency.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (11)
src/main/java/org/ezcode/codetest/infrastructure/s3/S3Uploader.java (1)

29-29: 주석 추가 확인됨

이미지 업로드 메소드에 주석이 추가되어 코드 가독성이 향상되었습니다.

src/main/java/org/ezcode/codetest/application/problem/dto/request/ProblemUpdateRequest.java (1)

14-14: API 문서화 개선

categories 필드가 리스트라는 것을 명확히 하는 주석이 추가되어 API 사용성이 향상되었습니다.

src/main/java/org/ezcode/codetest/application/problem/dto/request/ProblemCreateRequest.java (1)

16-16: 일관된 API 문서화

categories 필드가 Map이라는 것을 명확히 하는 주석이 추가되어 ProblemUpdateRequest와 일관된 문서화가 이루어졌습니다.

src/main/java/org/ezcode/codetest/infrastructure/s3/exception/code/S3ExceptionCode.java (1)

15-15: S3 삭제 실패 예외 코드 추가

이미지 삭제 기능을 위한 새로운 예외 코드가 적절한 HTTP 상태코드와 메시지로 추가되었습니다.

src/main/java/org/ezcode/codetest/domain/problem/model/entity/Problem.java (1)

162-162: 포맷팅 개선

incrementCorrectSubmissions() 메소드의 닫는 중괄호 위치가 정리되어 코드 일관성이 향상되었습니다.

src/main/java/org/ezcode/codetest/application/problem/service/ProblemService.java (3)

49-49: 포맷팅 개선이 적절합니다.

불필요한 공백이 제거되어 코드 가독성이 향상되었습니다.


105-105: 메서드 시그니처 업데이트가 적절합니다.

새로운 이미지 처리를 위한 MultipartFile newImage 파라미터 추가가 올바르며, 컨트롤러 변경사항과 일치합니다.


119-122: 이미지 수정 로직이 안전하게 구현되었습니다.

null 체크와 isEmpty 체크를 통해 안전성을 확보했고, 별도 메서드로 로직을 분리하여 코드 가독성이 향상되었습니다.

src/main/java/org/ezcode/codetest/presentation/problemmanagement/problem/ProblemAdminController.java (3)

50-50: 멀티파트 폼 데이터 지원이 적절히 추가되었습니다.

이미지 업로드를 위한 멀티파트 폼 데이터 지원이 올바르게 구현되었습니다.


55-56: 파라미터 어노테이션 변경이 올바릅니다.

@RequestBody에서 @RequestPart로 변경하고 선택적 이미지 파라미터를 추가한 것이 멀티파트 요청 처리에 적합합니다.


58-58: 서비스 호출이 업데이트된 시그니처와 일치합니다.

새로운 이미지 파라미터를 포함한 서비스 메서드 호출이 올바르게 수정되었습니다.

@Kimminu7 Kimminu7 closed this Jun 28, 2025
@Kimminu7 Kimminu7 reopened this Jun 28, 2025
@pokerbearkr pokerbearkr merged commit 1360305 into dev Jun 28, 2025
2 checks passed
@pokerbearkr pokerbearkr deleted the feature/problemS3 branch June 28, 2025 15:17
@coderabbitai coderabbitai bot mentioned this pull request Jan 3, 2026
3 tasks
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

None yet

Development

Successfully merging this pull request may close these issues.

4 participants