-
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.
Merge pull request #94 from ClothingStoreService/refactor/pagination-…
…response Refactor/pagination response
- Loading branch information
Showing
10 changed files
with
139 additions
and
246 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
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
86 changes: 59 additions & 27 deletions
86
src/main/java/org/store/clothstar/productLine/dto/response/ProductLineDetailResponse.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,42 +1,74 @@ | ||
package org.store.clothstar.productLine.dto.response; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import org.store.clothstar.productLine.domain.ProductLine; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; | ||
import com.querydsl.core.annotations.QueryProjection; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.*; | ||
import org.store.clothstar.member.dto.response.SellerSimpleResponse; | ||
import org.store.clothstar.product.dto.response.ProductResponse; | ||
import org.store.clothstar.product.entity.ProductEntity; | ||
import org.store.clothstar.productLine.domain.type.ProductLineStatus; | ||
import org.store.clothstar.productLine.entity.ProductLineEntity; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Getter | ||
@Builder | ||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class ProductLineDetailResponse { | ||
private Long productId; | ||
|
||
@Schema(description = "상품 id", example = "1") | ||
private Long productLineId; | ||
|
||
@Schema(description = "상품 이름", example = "우유 모자") | ||
private String name; | ||
private String brandName; | ||
|
||
@Schema(description = "상품 설명", example = "우유 모자입니다.") | ||
private String content; | ||
|
||
@Schema(description = "상품 가격", example = "10000") | ||
private int price; | ||
|
||
@Schema(description = "상품 전체 재고", example = "100") | ||
private Long totalStock; | ||
private Long saleCount; | ||
private ProductLineStatus productLineStatus; | ||
private String biz_no; | ||
|
||
@Schema(description = "상품 상태", example = "FOR_SALE") | ||
private ProductLineStatus status; | ||
|
||
@Schema(description = "상품 판매량", example = "10") | ||
private Long saleCount; // ~개 판매중 | ||
|
||
@Schema(description = "상품 옵션") | ||
private List<ProductResponse> productList; | ||
|
||
@Schema(description = "판매자 정보") | ||
private SellerSimpleResponse seller; | ||
|
||
@Schema(description = "생성일시") | ||
private LocalDateTime createdAt; | ||
|
||
@Schema(description = "수정일시") | ||
private LocalDateTime modifiedAt; | ||
private LocalDateTime deletedAt; | ||
|
||
public static ProductLineDetailResponse from(ProductLine productLine) { | ||
return ProductLineDetailResponse.builder() | ||
.productId(productLine.getProductLineId()) | ||
.name(productLine.getName()) | ||
.content(productLine.getContent()) | ||
.brandName(productLine.getBrandName()) | ||
.price(productLine.getPrice()) | ||
.totalStock(productLine.getTotalStock()) | ||
.saleCount(productLine.getSaleCount()) | ||
.productLineStatus(productLine.getStatus()) | ||
.biz_no(productLine.getBiz_no()) | ||
.createdAt(productLine.getCreatedAt()) | ||
.modifiedAt(productLine.getModifiedAt()) | ||
.deletedAt(productLine.getDeletedAt()) | ||
.build(); | ||
|
||
public ProductLineDetailResponse(ProductLineEntity productLine) { | ||
this.productLineId = productLine.getProductLineId(); | ||
this.name = productLine.getName(); | ||
this.content = productLine.getContent(); | ||
this.price = productLine.getPrice(); | ||
this.totalStock = productLine.getProducts().stream().mapToLong(ProductEntity::getStock).sum(); | ||
this.status = productLine.getStatus(); | ||
this.saleCount = productLine.getSaleCount(); | ||
this.createdAt = productLine.getCreatedAt(); | ||
this.modifiedAt = productLine.getModifiedAt(); | ||
this.seller = SellerSimpleResponse.from(productLine.getSeller()); | ||
this.productList = productLine.getProducts().stream() | ||
.map(ProductResponse::from) | ||
.collect(Collectors.toList()); | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.