@@ -10,10 +10,10 @@ public class PageRequest extends org.springframework.data.domain.PageRequest {
1010 private int current ;
1111 private int pageSize ;
1212
13- private final org .springframework .data .domain .PageRequest pageRequest ;
13+ private org .springframework .data .domain .PageRequest pageRequest ;
1414
1515 public PageRequest (int current , int pageSize , Sort sort ) {
16- super (current > 0 ? current --: 0 , pageSize , sort );
16+ super (current > 0 ? current -- : 0 , pageSize , sort );
1717 this .current = current ;
1818 this .pageSize = pageSize ;
1919 this .pageRequest = PageRequest .of (current , pageSize , sort );
@@ -28,7 +28,7 @@ public int getCurrent() {
2828 }
2929
3030 public void setCurrent (int current ) {
31- this .current = current > 0 ? current - 1 : 0 ;
31+ this .current = current > 0 ? current - 1 : 0 ;
3232 }
3333
3434 @ Override
@@ -52,7 +52,7 @@ public org.springframework.data.domain.PageRequest next() {
5252
5353 @ Override
5454 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 ());
5656 }
5757
5858 @ Override
@@ -99,5 +99,14 @@ public Sort getSortOr(Sort sort) {
9999 public Optional <Pageable > toOptional () {
100100 return pageRequest .toOptional ();
101101 }
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+ }
102111}
103112
0 commit comments