|
|
@@ -0,0 +1,100 @@
|
|
|
+package com.uas.platform.b2b.manage.controller.support;
|
|
|
+
|
|
|
+import com.fasterxml.jackson.annotation.JsonInclude;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+
|
|
|
+import java.io.*;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 分页返回结果集
|
|
|
+ *
|
|
|
+ * @author hejq
|
|
|
+ * @date 2018-09-07 11:44
|
|
|
+ */
|
|
|
+@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
|
|
+public class PageResultBean<T> implements Serializable {
|
|
|
+
|
|
|
+ private static final long serialVersionUID = 1L;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 定义返回成功标识
|
|
|
+ */
|
|
|
+ private static final String SUCCESS = "success";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 成功状态码
|
|
|
+ */
|
|
|
+ private static final int SUCCESS_CODE = 0;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 失败状态码
|
|
|
+ */
|
|
|
+ public static final int FAIL_CODE = 1;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 消息
|
|
|
+ */
|
|
|
+ private String msg = SUCCESS;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 状态码
|
|
|
+ */
|
|
|
+ private int code = SUCCESS_CODE;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 总页数
|
|
|
+ */
|
|
|
+ private int totalPages;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 总条数
|
|
|
+ */
|
|
|
+ private long totalElements;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页码
|
|
|
+ */
|
|
|
+ private int page;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页大小
|
|
|
+ */
|
|
|
+ private int size;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 首页
|
|
|
+ */
|
|
|
+ private boolean first;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 尾页
|
|
|
+ */
|
|
|
+ private boolean last;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 内容
|
|
|
+ */
|
|
|
+ private List<T> data;
|
|
|
+
|
|
|
+ public PageResultBean() {
|
|
|
+ super();
|
|
|
+ }
|
|
|
+
|
|
|
+ public PageResultBean(Throwable e) {
|
|
|
+ super();
|
|
|
+ this.msg = e.toString();
|
|
|
+ this.code = FAIL_CODE;
|
|
|
+ }
|
|
|
+
|
|
|
+ public PageResultBean(Page<T> data) {
|
|
|
+ super();
|
|
|
+ this.data = data.getContent();
|
|
|
+ this.totalElements = data.getTotalElements();
|
|
|
+ this.totalPages = data.getTotalPages();
|
|
|
+ this.first = data.isFirst();
|
|
|
+ this.last = data.isLast();
|
|
|
+ this.page = data.getNumber();
|
|
|
+ this.size = data.getSize();
|
|
|
+ }
|
|
|
+}
|