diff --git a/usecase/src/main/java/org/depromeet/spot/usecase/service/review/ReadReviewService.java b/usecase/src/main/java/org/depromeet/spot/usecase/service/review/ReadReviewService.java index 5dc439df..49ecdb3a 100644 --- a/usecase/src/main/java/org/depromeet/spot/usecase/service/review/ReadReviewService.java +++ b/usecase/src/main/java/org/depromeet/spot/usecase/service/review/ReadReviewService.java @@ -318,20 +318,4 @@ public Review mapKeywordsToReview(Review review) { return mappedReview; } - - private void setLikedAndScrappedStatus(List reviews, Long memberId) { - List reviewIds = reviews.stream().map(Review::getId).collect(Collectors.toList()); - - Map likedMap = - reviewLikeRepository.existsByMemberIdAndReviewIds(memberId, reviewIds); - Map scrappedMap = - reviewScrapRepository.existsByMemberIdAndReviewIds(memberId, reviewIds); - - reviews.forEach( - review -> { - boolean isLiked = likedMap.getOrDefault(review.getId(), false); - boolean isScrapped = scrappedMap.getOrDefault(review.getId(), false); - review.setLikedAndScrapped(isLiked, isScrapped); - }); - } } diff --git a/usecase/src/main/java/org/depromeet/spot/usecase/service/review/UpdateReviewService.java b/usecase/src/main/java/org/depromeet/spot/usecase/service/review/UpdateReviewService.java index 7948040b..d4a51644 100644 --- a/usecase/src/main/java/org/depromeet/spot/usecase/service/review/UpdateReviewService.java +++ b/usecase/src/main/java/org/depromeet/spot/usecase/service/review/UpdateReviewService.java @@ -7,6 +7,7 @@ import org.depromeet.spot.domain.review.keyword.Keyword; import org.depromeet.spot.usecase.port.in.review.UpdateReviewUsecase; import org.depromeet.spot.usecase.port.out.review.ReviewRepository; +import org.depromeet.spot.usecase.service.review.processor.ReadReviewProcessor; import org.depromeet.spot.usecase.service.review.processor.ReviewCreationProcessor; import org.depromeet.spot.usecase.service.review.processor.ReviewDataProcessor; import org.depromeet.spot.usecase.service.review.processor.ReviewKeywordProcessor; @@ -28,6 +29,7 @@ public class UpdateReviewService implements UpdateReviewUsecase { private final ReviewDataProcessor reviewDataProcessor; private final ReviewKeywordProcessor reviewKeywordProcessor; private final ReviewCreationProcessor reviewCreationProcessor; + private final ReadReviewProcessor readReviewProcessor; public UpdateReviewResult updateReview( Long memberId, Long reviewId, UpdateReviewCommand command) { @@ -49,6 +51,9 @@ public UpdateReviewResult updateReview( reviewKeywordProcessor.updateBlockTopKeywords(existingReview, savedReview); savedReview.setKeywordMap(keywordMap); + // 유저의 리뷰 좋아요, 스크랩 여부 + readReviewProcessor.setLikedAndScrappedStatus(savedReview, memberId); + return new UpdateReviewResult(savedReview); } diff --git a/usecase/src/main/java/org/depromeet/spot/usecase/service/review/processor/ReadReviewProcessor.java b/usecase/src/main/java/org/depromeet/spot/usecase/service/review/processor/ReadReviewProcessor.java index 0ff738b3..998904c7 100644 --- a/usecase/src/main/java/org/depromeet/spot/usecase/service/review/processor/ReadReviewProcessor.java +++ b/usecase/src/main/java/org/depromeet/spot/usecase/service/review/processor/ReadReviewProcessor.java @@ -7,4 +7,6 @@ public interface ReadReviewProcessor { void setLikedAndScrappedStatus(List reviews, Long memberId); + + void setLikedAndScrappedStatus(Review review, Long memberId); } diff --git a/usecase/src/main/java/org/depromeet/spot/usecase/service/review/processor/ReadReviewProcessorImpl.java b/usecase/src/main/java/org/depromeet/spot/usecase/service/review/processor/ReadReviewProcessorImpl.java index 94a5fc81..4bb50364 100644 --- a/usecase/src/main/java/org/depromeet/spot/usecase/service/review/processor/ReadReviewProcessorImpl.java +++ b/usecase/src/main/java/org/depromeet/spot/usecase/service/review/processor/ReadReviewProcessorImpl.java @@ -33,4 +33,11 @@ public void setLikedAndScrappedStatus(List reviews, Long memberId) { review.setLikedAndScrapped(isLiked, isScrapped); }); } + + @Override + public void setLikedAndScrappedStatus(Review review, Long memberId) { + boolean isLiked = reviewLikeRepository.existsBy(memberId, review.getId()); + boolean isScrapped = reviewScrapRepository.existsBy(memberId, review.getId()); + review.setLikedAndScrapped(isLiked, isScrapped); + } }