File tree Expand file tree Collapse file tree
src/main/java/com/example/store/product
repository/implementation Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .example .store .product .application ;
2+
3+ import com .example .store .product .domain .Product ;
4+ import com .example .store .product .infrastructure .repository .implementation .ProductRepositoryImplV2 ;
5+ import lombok .RequiredArgsConstructor ;
6+ import org .springframework .data .domain .Page ;
7+ import org .springframework .data .domain .Pageable ;
8+ import org .springframework .stereotype .Service ;
9+
10+ @ Service
11+ @ RequiredArgsConstructor
12+ public class ProductServiceImplV2 {
13+
14+ private final ProductRepositoryImplV2 productRepositoryImplV2 ;
15+
16+ public Page <Product > findAll (Pageable pageable ) {
17+ return productRepositoryImplV2 .findAll (pageable );
18+ }
19+ }
Original file line number Diff line number Diff line change 1+ package com .example .store .product .infrastructure ;
2+
3+ import com .example .store .product .application .ProductServiceImplV2 ;
4+ import com .example .store .product .domain .Product ;
5+ import io .swagger .v3 .oas .annotations .Operation ;
6+ import lombok .RequiredArgsConstructor ;
7+ import org .springframework .data .domain .Page ;
8+ import org .springframework .data .domain .Pageable ;
9+ import org .springframework .data .web .PageableDefault ;
10+ import org .springframework .http .HttpStatus ;
11+ import org .springframework .http .ResponseEntity ;
12+ import org .springframework .web .bind .annotation .GetMapping ;
13+ import org .springframework .web .bind .annotation .RequestMapping ;
14+ import org .springframework .web .bind .annotation .RestController ;
15+
16+ @ RestController
17+ @ RequestMapping ("/api/v2/products" )
18+ @ RequiredArgsConstructor
19+ public class ProductControllerImplV2 {
20+
21+ private final ProductServiceImplV2 productService ;
22+
23+ @ GetMapping
24+ @ Operation (summary = "Returns a paginated list of products" )
25+ public ResponseEntity <Page <Product >> findAll (@ PageableDefault Pageable pageable ) {
26+ return ResponseEntity .status (HttpStatus .OK ).body (productService .findAll (pageable ));
27+ }
28+ }
Original file line number Diff line number Diff line change 1+ package com .example .store .product .infrastructure .repository .implementation ;
2+
3+ import com .example .store .product .domain .Product ;
4+ import com .example .store .product .infrastructure .mapper .ProductMapper ;
5+ import com .example .store .product .infrastructure .repository .QueryProductRepository ;
6+ import lombok .RequiredArgsConstructor ;
7+ import org .springframework .data .domain .Page ;
8+ import org .springframework .data .domain .Pageable ;
9+ import org .springframework .stereotype .Repository ;
10+
11+ @ Repository
12+ @ RequiredArgsConstructor
13+ public class ProductRepositoryImplV2 {
14+
15+ private final QueryProductRepository queryProductRepository ;
16+ private final ProductMapper productMapper ;
17+
18+
19+ public Page <Product > findAll (Pageable pageable ) {
20+ return queryProductRepository .findAll (pageable ).map (productMapper ::productEntityToProduct );
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments