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(); } //리뷰 삭제