Skip to content

Commit

Permalink
merge #140 [FEAT] 스티커 상세 정보 가져오기
Browse files Browse the repository at this point in the history
#140 [FEAT] 스티커 상세 정보 가져오기
  • Loading branch information
05AM authored Dec 12, 2023
2 parents 9890e73 + 0d88915 commit 53cc3c3
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public ResponseEntity<?> getHotCustomStickerList() {
}

@GetMapping("/{stickerId}")
@Operation(summary = "커스텀 스티커 상세 정보 조회", description = "스티커 아이디 받음")
@Operation(summary = "스티커 상세 정보 조회", description = "스티커 아이디 받음")
@ApiResponses(value = {
@ApiResponse(
responseCode = "200",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,65 +11,69 @@
@Builder(access = AccessLevel.PRIVATE)
public class GetStickerForUserRes {

@Schema(description = "스티커 아이디")
private Integer id;
@Schema(description = "스티커 아이디")
private Integer id;

@Schema(description = "스티커 이름")
private String name;
@Schema(description = "스티커 이름")
private String name;

@Schema(description = "스티커 설명")
private String description;
@Schema(description = "스티커 설명")
private String description;

@Schema(description = "스티커 가격")
private Integer price;
@Schema(description = "스티커 가격")
private Integer price;

@Schema(description = "할인률", nullable = true)
private Integer discountRate;
@Schema(description = "할인률", nullable = true)
private Integer discountRate;

@Schema(description = "할인된 가격", nullable = true)
private Integer discountPrice;
@Schema(description = "할인된 가격", nullable = true)
private Integer discountPrice;

@Schema(description = "스티커 구성")
private String composition;
@Schema(description = "스티커 구성")
private String composition;

@Schema(description = "스티커 크기")
private String size;
@Schema(description = "스티커 크기")
private String size;

@Schema(description = "커스텀 스티커 여부")
private Boolean isCustom;
@Schema(description = "커스텀 스티커 여부")
private Boolean isCustom;

@Schema(description = "배송비")
private Integer shippingCost;
@Schema(description = "배송비")
private Integer shippingCost;

@Schema(description = "스티커 테마")
private List<String> stickerThemes;
@Schema(description = "스티커 테마")
private List<String> stickerThemes;

@Schema(description = "스티커 스타일")
private List<String> stickerStyles;
@Schema(description = "스티커 스타일")
private List<String> stickerStyles;

@Schema(description = "스티커 이미지")
private List<String> images;
@Schema(description = "메인 이미지 url")
private String mainImage;

@Schema(description = "상품 좋아요 여부")
private Boolean productLiked;
@Schema(description = "상세 이미지 url 목록")
private List<String> detailImages;

@Schema(description = "상품 좋아요 여부")
private Boolean productLiked;

public static GetStickerForUserRes from(ReadStickerForUserRes readStickerForUserRes) {
return GetStickerForUserRes.builder()
.id(readStickerForUserRes.getId())
.name(readStickerForUserRes.getName())
.description(readStickerForUserRes.getDescription())
.price(readStickerForUserRes.getPrice())
.discountRate(readStickerForUserRes.getDiscountRate())
.discountPrice(readStickerForUserRes.getDiscountPrice())
.composition(readStickerForUserRes.getComposition())
.size(readStickerForUserRes.getSize())
.isCustom(readStickerForUserRes.getIsCustom())
.shippingCost(readStickerForUserRes.getShippingCost())
.stickerThemes(readStickerForUserRes.getStickerThemes())
.stickerStyles(readStickerForUserRes.getStickerStyles())
.images(readStickerForUserRes.getImages())
.productLiked(readStickerForUserRes.getProductLiked())
.build();
}

public static GetStickerForUserRes from(ReadStickerForUserRes readStickerForUserRes) {
return GetStickerForUserRes.builder()
.id(readStickerForUserRes.getId())
.name(readStickerForUserRes.getName())
.description(readStickerForUserRes.getDescription())
.price(readStickerForUserRes.getPrice())
.discountRate(readStickerForUserRes.getDiscountRate())
.discountPrice(readStickerForUserRes.getDiscountPrice())
.composition(readStickerForUserRes.getComposition())
.size(readStickerForUserRes.getSize())
.isCustom(readStickerForUserRes.getIsCustom())
.shippingCost(readStickerForUserRes.getShippingCost())
.stickerThemes(readStickerForUserRes.getStickerThemes())
.stickerStyles(readStickerForUserRes.getStickerStyles())
.mainImage(readStickerForUserRes.getMainImage())
.detailImages(readStickerForUserRes.getDetailImages())
.productLiked(readStickerForUserRes.getProductLiked())
.build();
}
}
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();
}
}

0 comments on commit 53cc3c3

Please sign in to comment.