Skip to content

Commit

Permalink
feat: Get ItemSummary from Item
Browse files Browse the repository at this point in the history
- Item에서 ItemSummary를 가져올 수 있습니다.

issue: #8
  • Loading branch information
kihyuk-sung committed Apr 21, 2021
1 parent 6e8cb9d commit 42b3719
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions BE/src/main/java/com/team10/banchan/model/Item.java
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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<String> thumbImagesUrl() {
return thumbImages.stream()
.map(ThumbImage::getUrl)
Expand All @@ -117,6 +132,12 @@ private List<String> detailSection() {
.collect(Collectors.toList());
}

private List<String> deliveryType() {
return deliveryTypes.stream()
.map(DeliveryType::getName)
.collect(Collectors.toList());
}

private List<String> badge() {
return badges.stream()
.map(Badge::name)
Expand Down

0 comments on commit 42b3719

Please sign in to comment.