Просмотр исходного кода

add dto 添加antd相关组件

bianlz 1 месяц назад
Родитель
Сommit
64caeb8f51

+ 54 - 0
pangu-component/pangu-component-dto/src/main/java/com/hrsk/pangu/dto/AntDMultiResponse.java

@@ -0,0 +1,54 @@
+package com.hrsk.pangu.dto;
+
+import java.util.Collection;
+
+/**
+ * @author: bianlanzhou
+ * @create: 2024-10-21 11:19
+ * @description: ANTD页面适配列表响应
+ **/
+public class AntDMultiResponse <T> extends Response {
+    private static final long serialVersionUID = 1L;
+    private Collection<T> data;
+
+    public AntDMultiResponse() {
+    }
+
+    public void setData(Collection<T> data) {
+        this.data = data;
+    }
+
+    public Collection<T> getData() {
+        return this.data;
+    }
+
+    public static <T> AntDMultiResponse<T> of(Collection<T> data) {
+        AntDMultiResponse<T> response = new AntDMultiResponse();
+        response.setSuccess(true);
+        response.setData(data);
+        return response;
+    }
+
+    public static <T> AntDMultiResponse<T> of(MultiResponse<T> multiResponse) {
+        AntDMultiResponse<T> response = new AntDMultiResponse();
+        response.setData(multiResponse.getData());
+        response.setErrCode(multiResponse.getErrCode());
+        response.setErrMessage(multiResponse.getErrMessage());
+        response.setSuccess(multiResponse.isSuccess());
+        return response;
+    }
+
+    public static AntDMultiResponse buildSuccess() {
+        AntDMultiResponse response = new AntDMultiResponse();
+        response.setSuccess(true);
+        return response;
+    }
+
+    public static AntDMultiResponse buildFailure(String errCode, String errMessage) {
+        AntDMultiResponse response = new AntDMultiResponse();
+        response.setSuccess(false);
+        response.setErrCode(errCode);
+        response.setErrMessage(errMessage);
+        return response;
+    }
+}

+ 120 - 0
pangu-component/pangu-component-dto/src/main/java/com/hrsk/pangu/dto/AntDPageResponse.java

@@ -0,0 +1,120 @@
+package com.hrsk.pangu.dto;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author: bianlanzhou
+ * @create: 2024-10-21 11:21
+ * @description: ANTD页面适配分页响应
+ **/
+public class AntDPageResponse<T> extends Response {
+    private static final long serialVersionUID = 1L;
+    private long total = 0L;
+    private long pageSize = 10L;
+    private long pageIndex = 0L;
+    private Collection<T> data;
+
+    public AntDPageResponse() {
+    }
+
+    public long getTotal() {
+        return this.total;
+    }
+
+    public void setTotal(long total) {
+        this.total = total;
+    }
+
+    public long getPageSize() {
+        return this.pageSize < 1L ? 1L : this.pageSize;
+    }
+
+    public void setPageSize(long pageSize) {
+        if (pageSize < 1L) {
+            this.pageSize = 1L;
+        } else {
+            this.pageSize = pageSize;
+        }
+
+    }
+
+    public long getPageIndex() {
+        return this.pageIndex < 1L ? 1L : this.pageIndex;
+    }
+
+    public void setPageIndex(long pageIndex) {
+        if (pageIndex < 1L) {
+            this.pageIndex = 1L;
+        } else {
+            this.pageIndex = pageIndex;
+        }
+
+    }
+
+    public List<T> getData() {
+        return (List)(null == this.data ? Collections.emptyList() : new ArrayList(this.data));
+    }
+
+    public void setData(Collection<T> data) {
+        this.data = data;
+    }
+
+    public long getTotalPages() {
+        return this.total % this.pageSize == 0L ? this.total / this.pageSize : this.total / this.pageSize + 1L;
+    }
+
+    public boolean isEmpty() {
+        return this.data == null || this.data.size() == 0;
+    }
+
+    public boolean isNotEmpty() {
+        return !this.isEmpty();
+    }
+
+    public static AntDPageResponse buildSuccess() {
+        AntDPageResponse response = new AntDPageResponse();
+        response.setSuccess(true);
+        return response;
+    }
+
+    public static AntDPageResponse buildFailure(String errCode, String errMessage) {
+        AntDPageResponse response = new AntDPageResponse();
+        response.setSuccess(false);
+        response.setErrCode(errCode);
+        response.setErrMessage(errMessage);
+        return response;
+    }
+
+    public static <T> AntDPageResponse<T> of(int pageSize, int pageIndex) {
+        AntDPageResponse<T> response = new AntDPageResponse();
+        response.setSuccess(true);
+        response.setData(Collections.emptyList());
+        response.setTotal(0L);
+        response.setPageSize((long)pageSize);
+        response.setPageIndex((long)pageIndex);
+        return response;
+    }
+
+    public static <T> AntDPageResponse<T> of(Collection<T> data, long total, int pageSize, int pageIndex) {
+        AntDPageResponse<T> response = new AntDPageResponse();
+        response.setSuccess(true);
+        response.setData(data);
+        response.setTotal(total);
+        response.setPageSize((long)pageSize);
+        response.setPageIndex((long)pageIndex);
+        return response;
+    }
+
+    public static <T> AntDPageResponse<T> of(PageResponse<T> pageResponse) {
+        AntDPageResponse<T> response = new AntDPageResponse();
+        response.setSuccess(pageResponse.isSuccess());
+        response.setData(pageResponse.getData());
+        response.setTotal(pageResponse.getTotalCount());
+        response.setPageSize(pageResponse.getPageSize());
+        response.setPageIndex(pageResponse.getPageIndex());
+        return response;
+    }
+}

+ 34 - 0
pangu-component/pangu-component-dto/src/main/java/com/hrsk/pangu/dto/AntDQuery.java

@@ -0,0 +1,34 @@
+package com.hrsk.pangu.dto;
+
+/**
+ * @author: bianlanzhou
+ * @create: 2024-10-21 11:20
+ * @description: ANTD页面适配分页查询
+ **/
+public class AntDQuery extends Query {
+    private int current;
+    private int pageSize;
+
+    public AntDQuery() {
+    }
+
+    public int getCurrent() {
+        return this.current < 1 ? 1 : this.current;
+    }
+
+    public void setCurrent(int current) {
+        this.current = current;
+    }
+
+    public Integer getPageSize() {
+        return this.pageSize;
+    }
+
+    public void setPageSize(Integer pageSize) {
+        if (pageSize < 1) {
+            pageSize = 10;
+        }
+
+        this.pageSize = pageSize;
+    }
+}

+ 50 - 0
pangu-component/pangu-component-dto/src/main/java/com/hrsk/pangu/dto/AntDSingleResponse.java

@@ -0,0 +1,50 @@
+package com.hrsk.pangu.dto;
+
+/**
+ * @author: bianlanzhou
+ * @create: 2024-10-21 11:21
+ * @description: ANTD页面适配单独响应
+ **/
+public class AntDSingleResponse <T> extends Response {
+    private static final long serialVersionUID = 1L;
+    private T data;
+
+    public AntDSingleResponse() {
+    }
+
+    public T getData() {
+        return this.data;
+    }
+
+    public void setData(T data) {
+        this.data = data;
+    }
+
+    public static AntDSingleResponse buildSuccess() {
+        AntDSingleResponse response = new AntDSingleResponse();
+        response.setSuccess(true);
+        return response;
+    }
+
+    public static AntDSingleResponse buildFailure(String errCode, String errMessage) {
+        AntDSingleResponse response = new AntDSingleResponse();
+        response.setSuccess(false);
+        response.setErrCode(errCode);
+        response.setErrMessage(errMessage);
+        return response;
+    }
+
+    public static <T> AntDSingleResponse<T> of(T data) {
+        AntDSingleResponse<T> response = new AntDSingleResponse();
+        response.setSuccess(true);
+        response.setData(data);
+        return response;
+    }
+
+    public static <T> AntDSingleResponse<T> of(SingleResponse<T> singleResponse) {
+        AntDSingleResponse<T> response = new AntDSingleResponse();
+        response.setSuccess(singleResponse.isSuccess());
+        response.setData(singleResponse.getData());
+        return response;
+    }
+}