-
Notifications
You must be signed in to change notification settings - Fork 2
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 #70 from Try-AngIe/feat/product
feat: 상품 목록을 조회할 수 있다.
- Loading branch information
Showing
9 changed files
with
233 additions
and
68 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
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
36 changes: 0 additions & 36 deletions
36
server/src/main/java/kr/or/kosa/cmsplusmain/domain/product/dto/ProductDetail.java
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
server/src/main/java/kr/or/kosa/cmsplusmain/domain/product/dto/ProductQRes.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package kr.or.kosa.cmsplusmain.domain.product.dto; | ||
|
||
import com.querydsl.core.annotations.QueryProjection; | ||
import kr.or.kosa.cmsplusmain.domain.product.entity.Product; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
public class ProductQRes { | ||
|
||
private final Product product; | ||
private final int contractNumber; | ||
|
||
// 쿼리프로젝션을 이용해서 repository->service용 DTO | ||
@QueryProjection | ||
public ProductQRes(Product product, int contractNumber) { | ||
this.product = product; | ||
this.contractNumber = contractNumber; | ||
} | ||
|
||
public ProductRes toProductRes() { | ||
return ProductRes.builder() | ||
.productId(product.getId()) | ||
.productName(product.getName()) | ||
.productPrice(product.getPrice()) | ||
.productMemo(product.getMemo()) | ||
.contractNumber(contractNumber) | ||
.createdDateTime(product.getCreatedDateTime()) // 엔티티에서 가져옴 | ||
.build(); | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
server/src/main/java/kr/or/kosa/cmsplusmain/domain/product/dto/ProductRes.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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package kr.or.kosa.cmsplusmain.domain.product.dto; | ||
|
||
import kr.or.kosa.cmsplusmain.domain.product.entity.Product; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import java.time.LocalDateTime; | ||
|
||
@Getter | ||
@Builder | ||
public class ProductRes { | ||
|
||
private final Long productId; | ||
private final String productName; | ||
private final LocalDateTime createdDateTime; | ||
private final int productPrice; | ||
private final String productMemo; | ||
|
||
private final int contractNumber; // 계약 건수 | ||
|
||
public static ProductRes fromEntity(Product product, int contractNumber) { | ||
return ProductRes.builder() | ||
.productId(product.getId()) | ||
.productName(product.getName()) | ||
.createdDateTime(product.getCreatedDateTime()) | ||
.productPrice(product.getPrice()) | ||
.productMemo(product.getMemo()) | ||
.contractNumber(contractNumber) | ||
.build(); | ||
} | ||
|
||
} |
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.