File tree 3 files changed +52
-0
lines changed
src/main/java/br/com/catalog/utils
3 files changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ package br .com .catalog .utils ;
2
+
3
+ import br .com .catalog .models .Brand ;
4
+ import br .com .catalog .services .impls .dtos .BrandDTO ;
5
+ import org .springframework .stereotype .Component ;
6
+
7
+ import java .util .function .Function ;
8
+
9
+ @ Component
10
+ public class BrandToResponse implements Function <Brand , BrandDTO > {
11
+ @ Override
12
+ public BrandDTO apply (Brand brand ) {
13
+ return new BrandDTO (brand .getName ());
14
+ }
15
+ }
16
+
Original file line number Diff line number Diff line change
1
+ package br .com .catalog .utils ;
2
+
3
+ import br .com .catalog .models .Product ;
4
+ import br .com .catalog .services .impls .dtos .ProductDTO ;
5
+ import org .springframework .stereotype .Component ;
6
+
7
+ import java .util .function .Function ;
8
+
9
+ @ Component
10
+ public class ProductToResponse implements Function <Product , ProductDTO > {
11
+ @ Override
12
+ public ProductDTO apply (Product product ) {
13
+ return ProductDTO .builder ()
14
+ .name (product .getName ())
15
+ .brand (product .getBrand ().getName ())
16
+ .description (product .getDescription ())
17
+ .price (product .getPrice ())
18
+ .stockQuanitity (product .getStockQuantity ())
19
+ .build ();
20
+ }
21
+ }
Original file line number Diff line number Diff line change
1
+ package br .com .catalog .utils ;
2
+
3
+ import br .com .catalog .models .User ;
4
+ import br .com .catalog .services .impls .dtos .UserResponseDTO ;
5
+ import org .springframework .stereotype .Component ;
6
+
7
+ import java .util .function .Function ;
8
+
9
+ @ Component
10
+ public class UserToResponse implements Function <User , UserResponseDTO > {
11
+ @ Override
12
+ public UserResponseDTO apply (User user ) {
13
+ return new UserResponseDTO (user .getUsername (), user .getRole ().toString ());
14
+ }
15
+ }
You can’t perform that action at this time.
0 commit comments