From be830c508da4d9fa2c38063a8e6efb7f3178112d Mon Sep 17 00:00:00 2001 From: EunChanNam Date: Mon, 4 Dec 2023 13:34:53 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=A6=AC=EB=B7=B0=20=EC=BF=BC=EB=A6=AC?= =?UTF-8?q?=20=EC=84=B1=EB=8A=A5=20=ED=85=8C=EC=8A=A4=ED=8A=B8=EB=A5=BC=20?= =?UTF-8?q?=EC=9C=84=ED=95=9C=20=EC=84=B8=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 조인을 사용하는 쿼리와 사용하지 않는 쿼리 --- .../wesharewishhair/global/config/WebConfig.java | 3 ++- .../presentation/ReviewQueryTestController.java | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/inq/wishhair/wesharewishhair/global/config/WebConfig.java b/src/main/java/com/inq/wishhair/wesharewishhair/global/config/WebConfig.java index 67febb3..217c691 100644 --- a/src/main/java/com/inq/wishhair/wesharewishhair/global/config/WebConfig.java +++ b/src/main/java/com/inq/wishhair/wesharewishhair/global/config/WebConfig.java @@ -45,7 +45,8 @@ public void addInterceptors(final InterceptorRegistry registry) { .addExcludePathPattern("/api/users/refresh/*") .addExcludePathPattern("/api/like/test/clean") .addExcludePathPattern("/api/like/test/count/**") - .addExcludePathPattern("/api/email/*"); + .addExcludePathPattern("/api/email/*") + .addExcludePathPattern("/api/reviews/test/**"); registry .addInterceptor(pathMatcherInterceptor) diff --git a/src/main/java/com/inq/wishhair/wesharewishhair/review/presentation/ReviewQueryTestController.java b/src/main/java/com/inq/wishhair/wesharewishhair/review/presentation/ReviewQueryTestController.java index ba368af..b807851 100644 --- a/src/main/java/com/inq/wishhair/wesharewishhair/review/presentation/ReviewQueryTestController.java +++ b/src/main/java/com/inq/wishhair/wesharewishhair/review/presentation/ReviewQueryTestController.java @@ -3,10 +3,12 @@ import java.util.List; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.inq.wishhair.wesharewishhair.global.dto.response.ResponseWrapper; +import com.inq.wishhair.wesharewishhair.review.application.LikeReviewService; import com.inq.wishhair.wesharewishhair.review.application.dto.response.ReviewResponse; import com.inq.wishhair.wesharewishhair.review.application.dto.response.ReviewResponseAssembler; import com.inq.wishhair.wesharewishhair.review.domain.entity.Review; @@ -21,19 +23,26 @@ public class ReviewQueryTestController { private final ReviewQueryDslRepository reviewQueryDslRepository; + private final LikeReviewService likeReviewService; @Transactional(readOnly = true) + @GetMapping("/join") public ResponseWrapper withJoin() { List reviews = reviewQueryDslRepository.joinWithLikeQuery() .stream() .map(ReviewQueryResponse::getReview) .toList(); + return ReviewResponseAssembler.toWrappedReviewResponse(reviews); } @Transactional(readOnly = true) + @GetMapping("/no_join") public ResponseWrapper withoutJoin() { List reviews = reviewQueryDslRepository.noJoinQuery(); - return ReviewResponseAssembler.toWrappedReviewResponse(reviews); + List reviewIds = reviews.stream().map(Review::getId).toList(); + likeReviewService.getLikeCounts(reviewIds); + + return ReviewResponseAssembler.toWrappedReviewResponse(reviews, reviewIds); } }