File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ dependencies {
1818 implementation ' org.apache.commons:commons-lang3:3.8.1'
1919 testImplementation(' org.junit.jupiter:junit-jupiter:5.4.0' )
2020 testImplementation(' org.springframework.boot:spring-boot-starter-test' ){
21- exclude group : ' org. junit' , module : ' junit'
21+ exclude group : ' junit' , module : ' junit'
2222 }
2323}
2424
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ dependencies {
2222 annotationProcessor ' org.springframework.boot:spring-boot-configuration-processor'
2323 testImplementation(' org.junit.jupiter:junit-jupiter:5.4.0' )
2424 testImplementation(' org.springframework.boot:spring-boot-starter-test' ){
25- exclude group : ' org. junit' , module : ' junit'
25+ exclude group : ' junit' , module : ' junit'
2626 }
2727}
2828
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ dependencies {
2121 runtimeOnly ' com.h2database:h2'
2222 testImplementation(' org.junit.jupiter:junit-jupiter:5.4.0' )
2323 testImplementation(' org.springframework.boot:spring-boot-starter-test' ){
24- exclude group : ' org. junit' , module : ' junit'
24+ exclude group : ' junit' , module : ' junit'
2525 }
2626}
2727
Original file line number Diff line number Diff line change 1+ distributionBase =GRADLE_USER_HOME
2+ distributionPath =wrapper/dists
3+ distributionUrl =https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
4+ zipStoreBase =GRADLE_USER_HOME
5+ zipStorePath =wrapper/dists
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 88
99@ Entity
1010@ Data
11- class Character {
11+ class MovieCharacter {
1212
1313 @ Id
1414 @ GeneratedValue
Original file line number Diff line number Diff line change 1+ package io .reflectoring .pagination ;
2+
3+ import java .util .List ;
4+
5+ import org .springframework .data .domain .Page ;
6+ import org .springframework .data .domain .Pageable ;
7+ import org .springframework .data .domain .Slice ;
8+ import org .springframework .data .domain .Sort ;
9+ import org .springframework .data .repository .CrudRepository ;
10+
11+ interface MovieCharacterRepository extends CrudRepository <MovieCharacter , Long > {
12+
13+ Page <MovieCharacter > findAllPage (Pageable pageable );
14+
15+ Slice <MovieCharacter > findAllSlice (Pageable pageable );
16+
17+ List <MovieCharacter > findAllSorted (Sort sort );
18+
19+ }
Original file line number Diff line number Diff line change 11package io .reflectoring .pagination ;
22
3+ import java .util .List ;
4+
35import lombok .RequiredArgsConstructor ;
6+ import org .springframework .data .domain .Page ;
47import org .springframework .data .domain .Pageable ;
8+ import org .springframework .data .domain .Slice ;
9+ import org .springframework .data .domain .Sort ;
510import org .springframework .web .bind .annotation .GetMapping ;
611import org .springframework .web .bind .annotation .RestController ;
712
8- import java .util .List ;
9-
1013@ RestController
1114@ RequiredArgsConstructor
1215class PaginatedController {
1316
14- private final CharacterRepository characterRepository ;
17+ private final MovieCharacterRepository characterRepository ;
18+
19+ @ GetMapping (path = "/characters/page" )
20+ Page <MovieCharacter > loadCharactersPage (Pageable pageable ) {
21+ return characterRepository .findAllPage (pageable );
22+ }
23+
24+ @ GetMapping (path = "/characters/sorted" )
25+ List <MovieCharacter > loadCharactersSorted (Sort sort ) {
26+ return characterRepository .findAllSorted (sort );
27+ }
1528
16- @ GetMapping (path = "/characters" )
17- List < Character > loadCharacters (Pageable pageable ) {
18- return characterRepository .findAll (pageable );
29+ @ GetMapping (path = "/characters/slice " )
30+ Slice < MovieCharacter > loadCharactersSlice (Pageable pageable ) {
31+ return characterRepository .findAllSlice (pageable );
1932 }
2033}
Original file line number Diff line number Diff line change 1+ package io .reflectoring .pagination ;
2+
3+ import org .springframework .context .annotation .Configuration ;
4+ import org .springframework .data .web .config .EnableSpringDataWebSupport ;
5+
6+ @ Configuration
7+ @ EnableSpringDataWebSupport
8+ class PaginationConfiguration {
9+ }
You can’t perform that action at this time.
0 commit comments