package com.mingzuozhibi.commons.base;

import com.mingzuozhibi.commons.domain.ResultPage;
import org.springframework.data.domain.*;

public abstract class PageController extends BaseController {

    protected <T> String pageResult(Page<T> page) {
        var p = page.getPageable();
        var pageSize = p.getPageSize();
        var currentPage = p.getPageNumber() + 1;
        var totalElements = page.getTotalElements();
        return pageResult(page.getContent(), new ResultPage(pageSize, currentPage, totalElements));
    }

    protected PageRequest pageRequest(Pageable pageable, Sort defaultSort) {
        var pageNumber = pageable.previousOrFirst().getPageNumber();
        var pageSize = pageable.getPageSize();
        var sort = pageable.getSortOr(defaultSort);
        return PageRequest.of(pageNumber, pageSize, sort);
    }

}

@@ -255,16 +255,23 @@
    var p
+ageable
  = page.
@@ -297,28 +297,65 @@
     var 
-pageSize = p
+resultPage = new ResultPage(%0A            pageable
 .getPage
@@ -352,33 +352,33 @@
 le.getPageSize()
-;
+,
 %0A        var cur
@@ -374,27 +374,20 @@
     
-var currentPage = p
+    pageable
 .get
@@ -402,17 +402,17 @@
 er() + 1
-;
+,
 %0A       
@@ -416,27 +416,11 @@
     
-var totalElements =
+   
  pag
@@ -439,16 +439,17 @@
 ements()
+)
 ;%0A      
@@ -487,21 +487,17 @@
 tent(), 
-new R
+r
 esultPag
@@ -501,46 +501,8 @@
 Page
-(pageSize, currentPage, totalElements)
 );%0A 

Update commons page controller