From 8627b8aa90c8108d74b9fc606f9e5449dd5b2e9d Mon Sep 17 00:00:00 2001 From: hanueleee Date: Thu, 19 Oct 2023 16:37:26 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=A6=AC=EB=B7=B0=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=EC=8B=9C=20=EC=8D=B8=EB=84=A4=EC=9D=BC=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8=20=EB=A1=9C=EC=A7=81=20=EC=88=9C=EC=84=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../funeat/review/application/ReviewService.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/backend/src/main/java/com/funeat/review/application/ReviewService.java b/backend/src/main/java/com/funeat/review/application/ReviewService.java index 142a8e6b..f492e90b 100644 --- a/backend/src/main/java/com/funeat/review/application/ReviewService.java +++ b/backend/src/main/java/com/funeat/review/application/ReviewService.java @@ -247,19 +247,13 @@ public void deleteReview(final Long reviewId, final Long memberId) { if (review.checkAuthor(member)) { eventPublisher.publishEvent(new ReviewDeleteEvent(image)); - updateProduct(product, review.getRating()); deleteThingsRelatedToReview(review); + updateProduct(product, review.getRating()); return; } throw new NotAuthorOfReviewException(NOT_AUTHOR_OF_REVIEW, memberId); } - private void updateProduct(final Product product, final Long deletedRating) { - updateProductImage(product.getId()); - product.updateAverageRatingForDelete(deletedRating); - product.minusReviewCount(); - } - private void deleteThingsRelatedToReview(final Review review) { deleteReviewTags(review); deleteReviewFavorites(review); @@ -282,6 +276,12 @@ private void deleteReviewFavorites(final Review review) { reviewFavoriteRepository.deleteAllByIdInBatch(ids); } + private void updateProduct(final Product product, final Long deletedRating) { + product.updateAverageRatingForDelete(deletedRating); + product.minusReviewCount(); + updateProductImage(product.getId()); + } + public Optional getMostFavoriteReview(final Long productId) { final Product findProduct = productRepository.findById(productId) .orElseThrow(() -> new ProductNotFoundException(PRODUCT_NOT_FOUND, productId));