1
1
package com .univ .sohwakhaeng .product .api ;
2
2
3
3
import com .univ .sohwakhaeng .enterprise .Category ;
4
+ import com .univ .sohwakhaeng .enterprise .Enterprise ;
4
5
import com .univ .sohwakhaeng .enterprise .api .dto .EnterpriseDetailDto ;
5
6
import com .univ .sohwakhaeng .enterprise .api .dto .EnterpriseOverviewDto ;
6
7
import com .univ .sohwakhaeng .enterprise .api .dto .EnterpriseRequestDto ;
9
10
import com .univ .sohwakhaeng .global .common .dto .BaseResponse ;
10
11
import com .univ .sohwakhaeng .global .common .dto .PagedResponseDto ;
11
12
import com .univ .sohwakhaeng .global .common .exception .SuccessCode ;
13
+ import com .univ .sohwakhaeng .product .Product ;
12
14
import com .univ .sohwakhaeng .product .api .dto .ProductRequestDto ;
13
15
import com .univ .sohwakhaeng .product .service .ProductService ;
14
16
import java .util .List ;
28
30
public class ProductController {
29
31
30
32
private final ProductService productService ;
33
+ private final EnterpriseService enterpriseService ;
31
34
32
35
@ PostMapping ("/public/products" )
33
36
public BaseResponse <Void > postProducts (@ RequestBody List <ProductRequestDto > dtos ) throws EnterpriseNotFoundException {
37
+
38
+ for (ProductRequestDto dto : dtos ) {
39
+ Enterprise enterprise = enterpriseService .getEnterpriseEntityById (dto .enterpriseId ());
40
+ productService .saveProduct (Product .createProduct (dto , enterprise ));
41
+ }
42
+
34
43
return BaseResponse .success (
35
- SuccessCode .GET_ENTERPRISE_DETAILS , productService . postProducts ( dtos ) );
44
+ SuccessCode .GET_ENTERPRISE_DETAILS , null );
36
45
}
37
46
38
47
}
0 commit comments