Administrator 1 gadu atpakaļ
vecāks
revīzija
fc8682a322

+ 16 - 0
src/main/java/com/xiesx/fastboot/base/pagination/PaginationHelper.java

@@ -62,4 +62,20 @@ public class PaginationHelper {
             return PaginationResult.builder().code(0).data(list).count(total).build();
         }
     }
+
+    /**
+     * 构造
+     *
+     * @param data
+     * @param total
+     * @return
+     */
+    public static PaginationResult create(@NonNull List<?> data, Integer total, Integer page) {
+        List<?> list = Lists.newArrayList(data);
+        if (list.isEmpty()) {
+            return PaginationResult.builder().code(1).msg("No data").data(Lists.newArrayList()).count(0).page(1).build();
+        } else {
+            return PaginationResult.builder().code(0).data(list).count(total).page(page).build();
+        }
+    }
 }

+ 3 - 0
src/main/java/com/xiesx/fastboot/base/pagination/PaginationResult.java

@@ -33,5 +33,8 @@ public class PaginationResult {
     public Integer count;
 
     @JSONField(ordinal = 5)
+    public Integer page;
+
+    @JSONField(ordinal = 6)
     public Map<String, Object> extData;
 }

+ 3 - 0
src/main/java/com/xiesx/fastboot/base/pagination/PaginationVo.java

@@ -29,6 +29,9 @@ public class PaginationVo {
     public Integer size = 25;
 
     public Integer getPage() {
+        if(page < 1){
+            page = 1;
+        }
         return page - 1;
     }
 }