Browse Source

refactor:修改接口分页参数

liuchuanwei 3 months ago
parent
commit
363da6865b

+ 5 - 0
src/main/java/com/anyway/util/Page.java

@@ -28,4 +28,9 @@ public class Page {
     private long total;
     /** 总页数 */
     private int totalPage;
+
+    public Page(int pageNo, int pageSize) {
+        this.pageNo = pageNo;
+        this.pageSize = pageSize;
+    }
 }

+ 17 - 8
src/main/java/com/anyway/util/PageQuery.java

@@ -13,7 +13,12 @@ import lombok.Setter;
  */
 @Setter
 @Getter
-public class PageQuery<T> extends Page{
+public class PageQuery<T> {
+    /**
+     * 分页信息
+     */
+    private Page page;
+
     /**
      * 查询条件
      */
@@ -21,13 +26,17 @@ public class PageQuery<T> extends Page{
     @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
     private T terms;
 
-    /**
-     * 返回分页对象
-     *
-     * @return
-     */
-    public Page getPage() {
-        return new Page(this.getPageNo(), this.getPageSize(), this.getSortName(), this.getSortOrder(), this.getTotal(), this.getTotalPage());
+    public T getTerms(T t) {
+        if (terms == null) {
+            terms = t;
+        }
+        return terms;
     }
 
+    public Page getPage() {
+        if (page == null) {
+            page = new Page(0, 10);
+        }
+        return this.page;
+    }
 }