From 0d88915385b0107561100825df8e7a5400e723d0 Mon Sep 17 00:00:00 2001 From: 05AM Date: Wed, 13 Dec 2023 02:16:50 +0900 Subject: [PATCH] =?UTF-8?q?#140=20[FEAT]=20=EC=8A=A4=ED=8B=B0=EC=BB=A4=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=20=EC=A0=95=EB=B3=B4=20=EA=B0=80=EC=A0=B8?= =?UTF-8?q?=EC=98=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - mainImage 속성 추가 - images -> detailImages: 상세 이미지 url --- .../sticker/controller/StickerController.java | 2 +- .../dto/response/GetStickerForUserRes.java | 96 +++++++-------- .../dto/response/ReadStickerForUserRes.java | 111 +++++++++--------- 3 files changed, 108 insertions(+), 101 deletions(-) diff --git a/server/src/main/java/org/tattour/server/domain/sticker/controller/StickerController.java b/server/src/main/java/org/tattour/server/domain/sticker/controller/StickerController.java index e7b50fd3..671b7cde 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/controller/StickerController.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/controller/StickerController.java @@ -54,7 +54,7 @@ public ResponseEntity getHotCustomStickerList() { } @GetMapping("/{stickerId}") - @Operation(summary = "커스텀 스티커 상세 정보 조회", description = "스티커 아이디 받음") + @Operation(summary = "스티커 상세 정보 조회", description = "스티커 아이디 받음") @ApiResponses(value = { @ApiResponse( responseCode = "200", diff --git a/server/src/main/java/org/tattour/server/domain/sticker/controller/dto/response/GetStickerForUserRes.java b/server/src/main/java/org/tattour/server/domain/sticker/controller/dto/response/GetStickerForUserRes.java index a48c92ad..a70a81a4 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/controller/dto/response/GetStickerForUserRes.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/controller/dto/response/GetStickerForUserRes.java @@ -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 stickerThemes; + @Schema(description = "스티커 테마") + private List stickerThemes; - @Schema(description = "스티커 스타일") - private List stickerStyles; + @Schema(description = "스티커 스타일") + private List stickerStyles; - @Schema(description = "스티커 이미지") - private List images; + @Schema(description = "메인 이미지 url") + private String mainImage; - @Schema(description = "상품 좋아요 여부") - private Boolean productLiked; + @Schema(description = "상세 이미지 url 목록") + private List 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(); + } } diff --git a/server/src/main/java/org/tattour/server/domain/sticker/facade/dto/response/ReadStickerForUserRes.java b/server/src/main/java/org/tattour/server/domain/sticker/facade/dto/response/ReadStickerForUserRes.java index 8ac70681..0cb195a4 100644 --- a/server/src/main/java/org/tattour/server/domain/sticker/facade/dto/response/ReadStickerForUserRes.java +++ b/server/src/main/java/org/tattour/server/domain/sticker/facade/dto/response/ReadStickerForUserRes.java @@ -1,6 +1,5 @@ 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; @@ -8,65 +7,69 @@ 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 stickerThemes; - private List stickerStyles; - private List 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 stickerThemes; + private List stickerStyles; + private String mainImage; + private List detailImages; + private Boolean productLiked; - public static ReadStickerForUserRes of(Sticker sticker, Boolean productLiked) { - List stickerImages = new ArrayList<>(); - List stickerThemes = new ArrayList<>(); - List 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 stickerImages = sticker.getStickerImages() + .stream() + .map(StickerImage::getImageUrl) + .collect(Collectors.toList()); + + List stickerThemes = sticker.getStickerThemes() + .stream() + .map(theme -> theme.getTheme().getName()) + .collect(Collectors.toList()); + + List 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(); + } }