File tree Expand file tree Collapse file tree
apps/commerce-api/src/main/java/com/loopers/application/product Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package com .loopers .application .product ;
22
3+ import com .loopers .domain .brand .BrandRepository ;
34import com .loopers .domain .like .LikeRepository ;
45import com .loopers .domain .product .Product ;
56import com .loopers .domain .product .ProductRepository ;
1718public class ProductFacade {
1819 private final ProductRepository productRepository ;
1920 private final LikeRepository likeRepository ;
21+ private final BrandRepository brandRepository ;
2022
2123
2224 @ Transactional
2325 public ProductInfo registerProduct (ProductV1Dto .ProductRequest request ) {
26+ Long brandId = request .brandId ();
27+
28+ brandRepository .findById (brandId ).orElseThrow (
29+ () -> new CoreException (ErrorType .NOT_FOUND , "등록하고자 하는 상품의 브랜드가 존재하지 않습니다." )
30+ );
31+
2432 Product product = request .toEntity ();
2533 productRepository .save (product );
2634
@@ -52,6 +60,7 @@ public ProductInfo findProductById(Long id) {
5260
5361 @ Transactional (readOnly = true )
5462 public List <ProductInfo > searchProductsByCondition (ProductV1Dto .SearchProductRequest request ) {
63+ request .filterCondition ().conditionValidate ();
5564 request .sortCondition ().conditionValidate ();
5665
5766 List <Product > products = productRepository .searchProductsByCondition (request );
You can’t perform that action at this time.
0 commit comments