diff --git a/src/main/java/depth/jeonsilog/domain/user/application/UserService.java b/src/main/java/depth/jeonsilog/domain/user/application/UserService.java index 5a2e17f..851a9ea 100644 --- a/src/main/java/depth/jeonsilog/domain/user/application/UserService.java +++ b/src/main/java/depth/jeonsilog/domain/user/application/UserService.java @@ -33,6 +33,7 @@ import org.springframework.web.multipart.MultipartFile; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -153,7 +154,8 @@ public ResponseEntity deleteUser(UserPrincipal userPrincipal) { List replyByUser = replyRepository.findAllRepliesByUserId(userId); for (Reply reply : replyByUser) { Review review = reply.getReview(); - review.updateNumReply(review.getNumReply() - 1); + if (reviewRepository.findReviewByReviewId(review.getId()) != null) + review.updateNumReply(review.getNumReply() - 1); } replyRepository.deleteAll(replyByUser); @@ -164,6 +166,7 @@ public ResponseEntity deleteUser(UserPrincipal userPrincipal) { } reviewRepository.deleteAll(reviews); +// reviewRepository.deleteAllInBatch(reviews); interestRepository.deleteAll(interests); // s3에서 프로필 이미지 삭제