-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#140 [FEAT] 스티커 상세 정보 가져오기
- Loading branch information
Showing
3 changed files
with
108 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 57 additions & 54 deletions
111
...ain/java/org/tattour/server/domain/sticker/facade/dto/response/ReadStickerForUserRes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,75 @@ | ||
package org.tattour.server.domain.sticker.facade.dto.response; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.stream.Collectors; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import org.tattour.server.domain.sticker.model.Sticker; | ||
import org.tattour.server.domain.sticker.model.StickerImage; | ||
|
||
@Getter | ||
@Builder(access = AccessLevel.PRIVATE) | ||
public class ReadStickerForUserRes { | ||
|
||
private Integer id; | ||
private String name; | ||
private String description; | ||
private Integer price; | ||
private Integer discountRate; | ||
private Integer discountPrice; | ||
private String composition; | ||
private String size; | ||
private Boolean isCustom; | ||
private Integer shippingCost; | ||
private List<String> stickerThemes; | ||
private List<String> stickerStyles; | ||
private List<String> images; | ||
private Boolean productLiked; | ||
private Integer id; | ||
private String name; | ||
private String description; | ||
private Integer price; | ||
private Integer discountRate; | ||
private Integer discountPrice; | ||
private String composition; | ||
private String size; | ||
private Boolean isCustom; | ||
private Integer shippingCost; | ||
private List<String> stickerThemes; | ||
private List<String> stickerStyles; | ||
private String mainImage; | ||
private List<String> detailImages; | ||
private Boolean productLiked; | ||
|
||
|
||
public static ReadStickerForUserRes of(Sticker sticker, Boolean productLiked) { | ||
List<String> stickerImages = new ArrayList<>(); | ||
List<String> stickerThemes = new ArrayList<>(); | ||
List<String> stickerStyles = new ArrayList<>(); | ||
Integer discountRate = null; | ||
Integer discountPrice = null; | ||
public static ReadStickerForUserRes of(Sticker sticker, Boolean productLiked) { | ||
Integer discountRate = null; | ||
Integer discountPrice = null; | ||
|
||
if (!Objects.isNull(sticker.getDiscount())) { | ||
discountRate = sticker.getDiscount().getDiscountRate(); | ||
discountPrice = sticker.getDiscountPrice(); | ||
} | ||
stickerImages.add(sticker.getMainImageUrl()); | ||
sticker.getStickerImages().stream() | ||
.map(image -> stickerImages.add(image.getImageUrl())) | ||
.collect(Collectors.toList()); | ||
sticker.getStickerThemes() | ||
.stream() | ||
.map(theme -> stickerThemes.add(theme.getTheme().getName())) | ||
.collect(Collectors.toList()); | ||
sticker.getStickerStyles() | ||
.stream() | ||
.map(style -> stickerStyles.add(style.getStyle().getName())) | ||
.collect(Collectors.toList()); | ||
return ReadStickerForUserRes.builder() | ||
.id(sticker.getId()) | ||
.name(sticker.getName()) | ||
.description(sticker.getDescription()) | ||
.price(sticker.getPrice()) | ||
.discountRate(discountRate) | ||
.discountPrice(discountPrice) | ||
.composition(sticker.getComposition()) | ||
.size(sticker.getSize()) | ||
.isCustom(sticker.getIsCustom()) | ||
.shippingCost(sticker.getShippingFee()) | ||
.stickerThemes(stickerThemes) | ||
.stickerStyles(stickerStyles) | ||
.images(stickerImages) | ||
.productLiked(productLiked) | ||
.build(); | ||
} | ||
if (!Objects.isNull(sticker.getDiscount())) { | ||
discountRate = sticker.getDiscount().getDiscountRate(); | ||
discountPrice = sticker.getDiscountPrice(); | ||
} | ||
|
||
List<String> stickerImages = sticker.getStickerImages() | ||
.stream() | ||
.map(StickerImage::getImageUrl) | ||
.collect(Collectors.toList()); | ||
|
||
List<String> stickerThemes = sticker.getStickerThemes() | ||
.stream() | ||
.map(theme -> theme.getTheme().getName()) | ||
.collect(Collectors.toList()); | ||
|
||
List<String> stickerStyles = sticker.getStickerStyles() | ||
.stream() | ||
.map(style -> style.getStyle().getName()) | ||
.collect(Collectors.toList()); | ||
|
||
return ReadStickerForUserRes.builder() | ||
.id(sticker.getId()) | ||
.name(sticker.getName()) | ||
.description(sticker.getDescription()) | ||
.price(sticker.getPrice()) | ||
.discountRate(discountRate) | ||
.discountPrice(discountPrice) | ||
.composition(sticker.getComposition()) | ||
.size(sticker.getSize()) | ||
.isCustom(sticker.getIsCustom()) | ||
.shippingCost(3000) | ||
.stickerThemes(stickerThemes) | ||
.stickerStyles(stickerStyles) | ||
.mainImage(sticker.getMainImageUrl()) | ||
.detailImages(stickerImages) | ||
.productLiked(productLiked) | ||
.build(); | ||
} | ||
} |