@@ -10,10 +10,10 @@ public class PageRequest extends org.springframework.data.domain.PageRequest {
10
10
private int current ;
11
11
private int pageSize ;
12
12
13
- private final org .springframework .data .domain .PageRequest pageRequest ;
13
+ private org .springframework .data .domain .PageRequest pageRequest ;
14
14
15
15
public PageRequest (int current , int pageSize , Sort sort ) {
16
- super (current > 0 ? current --: 0 , pageSize , sort );
16
+ super (current > 0 ? current -- : 0 , pageSize , sort );
17
17
this .current = current ;
18
18
this .pageSize = pageSize ;
19
19
this .pageRequest = PageRequest .of (current , pageSize , sort );
@@ -28,7 +28,7 @@ public int getCurrent() {
28
28
}
29
29
30
30
public void setCurrent (int current ) {
31
- this .current = current > 0 ? current - 1 : 0 ;
31
+ this .current = current > 0 ? current - 1 : 0 ;
32
32
}
33
33
34
34
@ Override
@@ -52,7 +52,7 @@ public org.springframework.data.domain.PageRequest next() {
52
52
53
53
@ Override
54
54
public org .springframework .data .domain .PageRequest previous () {
55
- return current == 0 ? this : new PageRequest (current - 1 , getPageSize (),getSort ());
55
+ return current == 0 ? this : new PageRequest (current - 1 , getPageSize (), getSort ());
56
56
}
57
57
58
58
@ Override
@@ -99,5 +99,14 @@ public Sort getSortOr(Sort sort) {
99
99
public Optional <Pageable > toOptional () {
100
100
return pageRequest .toOptional ();
101
101
}
102
+
103
+ public void addSort (Sort sort ) {
104
+ Sort nowSort = pageRequest .getSort ();
105
+ if (nowSort == Sort .unsorted ()) {
106
+ this .pageRequest = new PageRequest (getCurrent (), getPageSize (), sort );
107
+ }else {
108
+ pageRequest .getSort ().and (sort );
109
+ }
110
+ }
102
111
}
103
112
0 commit comments