|
|
@@ -1,5 +1,7 @@
|
|
|
package com.xunmei.common.core.web.page;
|
|
|
|
|
|
+import cn.hutool.http.HttpStatus;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
@@ -10,7 +12,7 @@ import java.util.List;
|
|
|
*
|
|
|
* @author xunmei
|
|
|
*/
|
|
|
-public class TableDataInfo implements Serializable {
|
|
|
+public class TableDataInfo<T> implements Serializable {
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
|
/**
|
|
|
@@ -60,6 +62,31 @@ public class TableDataInfo implements Serializable {
|
|
|
return tableDataInfo;
|
|
|
}
|
|
|
|
|
|
+ public static <T> TableDataInfo<T> build(IPage<T> page) {
|
|
|
+ TableDataInfo<T> rspData = new TableDataInfo<>();
|
|
|
+ rspData.setCode(HttpStatus.HTTP_OK);
|
|
|
+ rspData.setMsg("查询成功");
|
|
|
+ rspData.setRows(page.getRecords());
|
|
|
+ rspData.setTotal(page.getTotal());
|
|
|
+ return rspData;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static <T> TableDataInfo<T> build(List<T> list) {
|
|
|
+ TableDataInfo<T> rspData = new TableDataInfo<>();
|
|
|
+ rspData.setCode(HttpStatus.HTTP_OK);
|
|
|
+ rspData.setMsg("查询成功");
|
|
|
+ rspData.setRows(list);
|
|
|
+ rspData.setTotal(list.size());
|
|
|
+ return rspData;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static <T> TableDataInfo<T> build() {
|
|
|
+ TableDataInfo<T> rspData = new TableDataInfo<>();
|
|
|
+ rspData.setCode(HttpStatus.HTTP_OK);
|
|
|
+ rspData.setMsg("查询成功");
|
|
|
+ return rspData;
|
|
|
+ }
|
|
|
+
|
|
|
public long getTotal() {
|
|
|
return total;
|
|
|
}
|
|
|
@@ -91,4 +118,4 @@ public class TableDataInfo implements Serializable {
|
|
|
public void setMsg(String msg) {
|
|
|
this.msg = msg;
|
|
|
}
|
|
|
-}
|
|
|
+}
|