From 42b371981b16f9130efac14188c904088d6dbbe4 Mon Sep 17 00:00:00 2001 From: K Date: Wed, 21 Apr 2021 17:00:06 +0900 Subject: [PATCH] feat: Get ItemSummary from Item MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Item에서 ItemSummary를 가져올 수 있습니다. issue: #8 --- .../java/com/team10/banchan/model/Item.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/BE/src/main/java/com/team10/banchan/model/Item.java b/BE/src/main/java/com/team10/banchan/model/Item.java index 634df1740..e7e60613c 100644 --- a/BE/src/main/java/com/team10/banchan/model/Item.java +++ b/BE/src/main/java/com/team10/banchan/model/Item.java @@ -1,6 +1,7 @@ package com.team10.banchan.model; import com.team10.banchan.dto.ItemDetail; +import com.team10.banchan.dto.ItemSummary; import org.springframework.data.annotation.Id; import org.springframework.data.relational.core.mapping.Embedded; @@ -94,6 +95,20 @@ public ItemDetail itemDetail() { ); } + public ItemSummary itemSummary() { + return ItemSummary.of( + id, + topImage.getTopImage(), + topImage.getAlt(), + deliveryType(), + description.getTitle(), + description.getDescription(), + prices.getnPrice(), + prices.getsPrice(), + badge() + ); + } + private List thumbImagesUrl() { return thumbImages.stream() .map(ThumbImage::getUrl) @@ -117,6 +132,12 @@ private List detailSection() { .collect(Collectors.toList()); } + private List deliveryType() { + return deliveryTypes.stream() + .map(DeliveryType::getName) + .collect(Collectors.toList()); + } + private List badge() { return badges.stream() .map(Badge::name)