-
Notifications
You must be signed in to change notification settings - Fork 3
이미지 수정 반영 안됨 해결 #207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
이미지 수정 반영 안됨 해결 #207
Conversation
개요이 PR은 ProblemDetailResponse DTO에 이미지 파일명을 추출하는 필드와 헬퍼 메서드를 추가하고, ProblemService의 이미지 업데이트 로직을 재정렬하여 새 이미지 업로드 전에 기존 이미지를 먼저 삭제하도록 수정합니다. 변경사항
예상 코드 리뷰 노력🎯 2 (Simple) | ⏱️ ~12분 관련 가능 PR
제안 레이블
제안 검토자
토끼의 축시
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/main/java/org/ezcode/codetest/application/problem/service/ProblemService.java (1)
176-189:addImageToExistingProblem과의 일관성을 위해 명시적 저장을 추가하세요.
addImageToExistingProblem메서드(Line 214)와 달리, 이 메서드는 새 이미지를 추가한 후(Line 188) 명시적으로 저장하지 않습니다.@Transactional경계에서 자동으로 반영되더라도, 명시적 저장을 추가하면 코드의 의도가 명확해지고 두 메서드 간의 일관성이 유지됩니다.🔎 제안하는 수정사항
private void updateProblemImage(Problem problem, MultipartFile newImage) { // 기존 이미지가 있다면 삭제 처리 if (!problem.getImageUrl().isEmpty()) { for(String fileUrl : problem.getImageUrl()) { s3Uploader.delete(fileUrl, "problem"); } problem.clearImages(); problemDomainService.saveProblem(problem); } String newImageUrl = uploadImageAfterTransaction(newImage, problem.getId()); problem.addImage(newImageUrl); + problemDomainService.saveProblem(problem); }
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/main/java/org/ezcode/codetest/application/problem/dto/response/ProblemDetailResponse.javasrc/main/java/org/ezcode/codetest/application/problem/service/ProblemService.java
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-07-02T12:05:54.917Z
Learnt from: Kimminu7
Repo: ezcode-my/backend PR: 133
File: src/test/java/org/ezcode/codetest/domain/problem/service/ProblemDomainServiceTest.java:92-99
Timestamp: 2025-07-02T12:05:54.917Z
Learning: ProblemDomainService의 removeProblem 메서드는 DB에서 Problem을 삭제한 후 Elasticsearch에서도 해당 ProblemSearchDocument를 찾아서 삭제합니다. 만약 Elasticsearch에서 문서를 찾지 못하면 ProblemException(PROBLEM_NOT_FOUND)을 던지므로, 테스트에서는 problem.getId()와 searchRepository.findById() 모두 적절하게 mock해야 합니다.
Applied to files:
src/main/java/org/ezcode/codetest/application/problem/service/ProblemService.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (3)
src/main/java/org/ezcode/codetest/application/problem/service/ProblemService.java (1)
199-214: 이미지 수정 로직이 올바르게 구현되었습니다.기존 이미지 삭제 → 새 이미지 업로드 → 문제에 연결 → 저장의 흐름이 명확하게 구현되어 있으며, 마지막에 명시적으로
saveProblem을 호출하여 변경사항이 DB에 반영되도록 보장합니다.src/main/java/org/ezcode/codetest/application/problem/dto/response/ProblemDetailResponse.java (2)
56-57: 새로운imageName필드가 적절하게 추가되었습니다.클라이언트에서 파일명을 직접 사용할 수 있도록 하는 유용한 필드입니다.
84-90: 이 주석은 이 프로젝트에 적용되지 않습니다.
S3Uploader.upload()메서드는amazonS3.getUrl(bucket, fileName).toString()을 사용하여 표준 S3 URL을 반환합니다. 이는 서명된 URL이 아니며 쿼리 파라미터를 포함하지 않습니다. 따라서extractFileName메서드는 현재 프로젝트에서 사용되는 URL 형식을 올바르게 처리합니다.
작업 내용
변경 사항
UserService.createUser()메서드 추가@Email유효성 검증 적용트러블 슈팅
@Transactional이 적용되지 않음this.→AopProxyUtils.사용)해결해야 할 문제
UserController에서 비즈니스 로직 일부 처리 → 서비스로 이전 고려 필요참고 사항
코드 리뷰 전 확인 체크리스트
type :)Summary by CodeRabbit
릴리스 노트
새로운 기능
개선사항
✏️ Tip: You can customize this high-level summary in your review settings.