diff --git a/.gitignore b/.gitignore index f2ff365..bfd386a 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,6 @@ out/ ### QueryDsl /src/main/generated/ /iter_docker/.env + +### Database ### +*.csv diff --git a/src/main/java/com/example/betteriter/fo_domain/review/service/ReviewService.java b/src/main/java/com/example/betteriter/fo_domain/review/service/ReviewService.java index a3a5c76..7adc150 100644 --- a/src/main/java/com/example/betteriter/fo_domain/review/service/ReviewService.java +++ b/src/main/java/com/example/betteriter/fo_domain/review/service/ReviewService.java @@ -421,18 +421,16 @@ public void updateReview(Long reviewId, UpdateReviewRequestDto request) { this.updateReviewData(request, review); // 2. 리뷰 이미지 업데이트 + this.clearReviewImages(review); this.updateReviewImages(review, request.getImageList()); - // 3. 리뷰 스펙 데이터 삭제 + // 3. 리뷰 스펙 데이터 업데이트 this.clearReviewSpecData(review); - // 4. 리뷰 스펙 데이터 업데이트 List newSpecDataList = this.specConnector.findAllSpecDataByIds(request.getSpecData()); this.updateReviewSpecData(review, newSpecDataList); - reviewRepository.save(review); - - // 5. 필요없는 리뷰 이미지 삭제 + // 4. 필요없는 리뷰 이미지 삭제 // this.clearS3ReviewImage(review); } @@ -454,12 +452,11 @@ private void updateReviewData(UpdateReviewRequestDto request, Review review) { } review.updateReview(request, manufacturer); + + reviewRepository.save(review); } private void updateReviewImages(Review review, List imageList) { - List nowReviewImages = review.getReviewImages(); - reviewImageRepository.deleteAll(nowReviewImages); - for (int i = 0; i < imageList.size(); i++) { reviewImageRepository.save(ReviewImage.builder() .review(review) @@ -469,6 +466,11 @@ private void updateReviewImages(Review review, List imageList) { } } + private void clearReviewImages(Review review) { + List nowReviewImages = review.getReviewImages(); + reviewImageRepository.deleteAll(nowReviewImages); + } + private void updateReviewSpecData(Review review, List newSpecDataList) { List newReviewSpecDataList = newSpecDataList.stream() .map(specData -> ReviewSpecData.createReviewSpecData(review, specData))