From 56ce9a5fa67991cc8bdca66c5e36282ef02272f4 Mon Sep 17 00:00:00 2001 From: ZhouXY108 Date: Wed, 12 Apr 2023 11:01:42 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8D=95=E8=B0=83=E6=95=B4=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E5=8E=BB=E9=99=A4=20lombok=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 13 ------- .../zhouxy/plusone/commons/util/PageDTO.java | 21 +++++++--- .../util/PagingAndSortingQueryParams.java | 18 +++++++-- .../plusone/commons/util/RestfulResult.java | 39 +++++++++++++++---- 4 files changed, 62 insertions(+), 29 deletions(-) diff --git a/pom.xml b/pom.xml index 9ebd1b5..3b0b071 100644 --- a/pom.xml +++ b/pom.xml @@ -12,18 +12,11 @@ UTF-8 1.8 1.8 - 1.18.24 2.13.4 - 3.0.2 31.1-jre - - com.google.code.findbugs - jsr305 - ${google-jsr305.version} - com.google.guava guava @@ -34,12 +27,6 @@ jackson-annotations ${jackson.version} - - org.projectlombok - lombok - ${lombok.version} - true - org.junit.jupiter diff --git a/src/main/java/xyz/zhouxy/plusone/commons/util/PageDTO.java b/src/main/java/xyz/zhouxy/plusone/commons/util/PageDTO.java index fbd265a..049658e 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/util/PageDTO.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/util/PageDTO.java @@ -18,9 +18,6 @@ package xyz.zhouxy.plusone.commons.util; import java.util.List; -import lombok.Setter; -import lombok.ToString; - /** * 返回分页查询的结果 * @@ -29,8 +26,6 @@ import lombok.ToString; * @author ZhouXY * @see PagingAndSortingQueryParams */ -@ToString -@Setter public class PageDTO { private Long total; @@ -53,4 +48,20 @@ public class PageDTO { return content; } + // Setters + + public void setTotal(Long total) { + this.total = total; + } + + public void setContent(List content) { + this.content = content; + } + + // Setters end + + @Override + public String toString() { + return "PageDTO [total=" + total + ", content=" + content + "]"; + } } diff --git a/src/main/java/xyz/zhouxy/plusone/commons/util/PagingAndSortingQueryParams.java b/src/main/java/xyz/zhouxy/plusone/commons/util/PagingAndSortingQueryParams.java index fb15ca6..5959189 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/util/PagingAndSortingQueryParams.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/util/PagingAndSortingQueryParams.java @@ -20,8 +20,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import lombok.Setter; - /** * 分页排序查询参数 * @@ -33,7 +31,6 @@ import lombok.Setter; * @author ZhouXY * @see PageDTO */ -@Setter public class PagingAndSortingQueryParams { protected String orderBy; @@ -66,4 +63,19 @@ public class PagingAndSortingQueryParams { return (getPageNum() - 1) * getSize(); } + // Setters + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public void setSize(Integer size) { + this.size = size; + } + + public void setPageNum(Long pageNum) { + this.pageNum = pageNum; + } + + // Setters end } diff --git a/src/main/java/xyz/zhouxy/plusone/commons/util/RestfulResult.java b/src/main/java/xyz/zhouxy/plusone/commons/util/RestfulResult.java index 9128b0f..7a8b5f1 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/util/RestfulResult.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/util/RestfulResult.java @@ -21,20 +21,12 @@ import java.util.function.Supplier; import com.fasterxml.jackson.annotation.JsonInclude; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.ToString; - /** * 对返回给前端的数据进行封装 * * @author ZhouXY */ @JsonInclude(JsonInclude.Include.NON_NULL) -@ToString -@Getter -@AllArgsConstructor(access = AccessLevel.PRIVATE) public class RestfulResult { public static final int SUCCESS_STATUS = 2000000; @@ -90,6 +82,37 @@ public class RestfulResult { return isSuccess.getAsBoolean() ? success.get() : error.get(); } + // Constructors + + private RestfulResult(Object status, String message, Object data) { + this.status = status; + this.message = message; + this.data = data; + } + + // Constructors end + + // Getters + + public Object getStatus() { + return status; + } + + public String getMessage() { + return message; + } + + public Object getData() { + return data; + } + + // Getters end + + @Override + public String toString() { + return "RestfulResult [status=" + status + ", message=" + message + ", data=" + data + "]"; + } + // Builder public static Builder successIf(final boolean condition) { return successIf(() -> condition);