From cb2933d5b2deea8a91e131bf7435c6482a8c687e Mon Sep 17 00:00:00 2001 From: Minseong Park Date: Mon, 9 Sep 2024 17:50:41 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20isLiked,=20isScrapped=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/review/processor/ReadReviewProcessor.java | 2 ++ .../service/review/processor/ReadReviewProcessorImpl.java | 7 +++++++ 2 files changed, 9 insertions(+) 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); + } } From a93839ef857ee20bfcf242bbd6cdaa08fa02d5e2 Mon Sep 17 00:00:00 2001 From: Minseong Park Date: Mon, 9 Sep 2024 17:51:15 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8=20=EC=8B=9C=20isLiked,=20isScrapped=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../spot/usecase/service/review/UpdateReviewService.java | 5 +++++ 1 file changed, 5 insertions(+) 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); } From b649c4a15098a5407afbf9aca864cd6b2c73a0d1 Mon Sep 17 00:00:00 2001 From: Minseong Park Date: Mon, 9 Sep 2024 17:54:41 +0900 Subject: [PATCH 3/3] =?UTF-8?q?chore:=20ReadReviewService=20=EC=A3=BC?= =?UTF-8?q?=EC=84=9D=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/review/ReadReviewService.java | 16 ---------------- 1 file changed, 16 deletions(-) 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); - }); - } }