From 9385c9f41a0f097144578c80bffd0ce482f42808 Mon Sep 17 00:00:00 2001 From: daeun084 <030804jk@naver.com> Date: Mon, 29 Jan 2024 19:00:45 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=B3=84=EC=A0=90=20=ED=98=84=ED=99=A9?= =?UTF-8?q?=20map=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/ReviewListResponseDto.java | 19 ++++++++++++++++++ .../domain/review/service/ReviewService.java | 20 +++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 src/main/java/umc/meme/shop/domain/review/dto/response/ReviewListResponseDto.java diff --git a/src/main/java/umc/meme/shop/domain/review/dto/response/ReviewListResponseDto.java b/src/main/java/umc/meme/shop/domain/review/dto/response/ReviewListResponseDto.java new file mode 100644 index 0000000..35d0356 --- /dev/null +++ b/src/main/java/umc/meme/shop/domain/review/dto/response/ReviewListResponseDto.java @@ -0,0 +1,19 @@ +package umc.meme.shop.domain.review.dto.response; + + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ReviewListResponseDto { + private List reviewResponseDtoList; + private Map starStatus; +} diff --git a/src/main/java/umc/meme/shop/domain/review/service/ReviewService.java b/src/main/java/umc/meme/shop/domain/review/service/ReviewService.java index 0a81c0b..74d55ed 100644 --- a/src/main/java/umc/meme/shop/domain/review/service/ReviewService.java +++ b/src/main/java/umc/meme/shop/domain/review/service/ReviewService.java @@ -12,13 +12,16 @@ import umc.meme.shop.domain.reservation.repository.ReservationRepository; import umc.meme.shop.domain.review.dto.request.DeleteReviewDto; import umc.meme.shop.domain.review.dto.request.ReviewDto; +import umc.meme.shop.domain.review.dto.response.ReviewListResponseDto; import umc.meme.shop.domain.review.dto.response.ReviewResponseDto; import umc.meme.shop.domain.review.entity.Review; import umc.meme.shop.domain.review.repository.ReviewRepository; import umc.meme.shop.global.ErrorStatus; import umc.meme.shop.global.exception.GlobalException; +import java.util.HashMap; import java.util.List; +import java.util.Map; @Service @RequiredArgsConstructor @@ -72,13 +75,26 @@ public List getMyReview(Long modelId){ } //리뷰 리스트 조회 - public List getReviewList(Long portfolioId){ + public ReviewListResponseDto getReviewList(Long portfolioId){ Portfolio portfolio = portfolioRepository.findById(portfolioId) .orElseThrow(() -> new GlobalException(ErrorStatus.NOT_EXIST_PORTFOLIO)); + + //review List List reviewList = portfolio.getReviewList(); - return reviewList.stream() + List responseDtoList = reviewList.stream() .map(ReviewResponseDto::from) .toList(); + + //별점 현황 + Map starStatus = new HashMap<>(Map.of(5, 0, 4, 0, 3, 0, 2, 0, 1, 0)); + for(ReviewResponseDto review : responseDtoList){ + starStatus.put(review.getStar(), starStatus.get(review.getStar())+1 ); + } + + return ReviewListResponseDto.builder() + .reviewResponseDtoList(responseDtoList) + .starStatus(starStatus) + .build(); } //리뷰 삭제