From 8d72493908063ac544b1b8a6f1366874b08918ac Mon Sep 17 00:00:00 2001 From: CaptainB Date: Thu, 1 Jun 2023 16:30:51 +0800 Subject: [PATCH] =?UTF-8?q?build:=20=E8=BF=94=E5=9B=9E=E5=AE=9E=E4=BD=93?= =?UTF-8?q?=E5=B0=81=E8=A3=85=20ResultHolder=20=E4=B8=AD=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E8=AF=A6=E7=BB=86=E4=BF=A1=E6=81=AF=E7=9A=84?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sdk/controller/handler/ResultHolder.java | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/controller/handler/ResultHolder.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/controller/handler/ResultHolder.java index a8163e1940..949c6db8f9 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/controller/handler/ResultHolder.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/controller/handler/ResultHolder.java @@ -1,15 +1,15 @@ package io.metersphere.sdk.controller.handler; import lombok.Data; -import org.apache.commons.lang3.builder.ReflectionToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; @Data public class ResultHolder { // 请求是否成功 private int code = 0; - // 描述信息 + // 描述信息,一般是错误信息 private String message; + // 详细描述信息, 如有异常,这里是详细日志 + private String messageDetail; // 返回数据 private Object data = ""; @@ -33,6 +33,13 @@ public class ResultHolder { this.data = data; } + public ResultHolder(int code, String msg, String messageDetail, Object data) { + this.code = code; + this.message = msg; + this.messageDetail = messageDetail; + this.data = data; + } + public static ResultHolder success(Object obj) { return new ResultHolder(obj); } @@ -41,11 +48,15 @@ public class ResultHolder { return new ResultHolder(code, message, null); } - public static ResultHolder error(int code, String message, Object object) { - return new ResultHolder(code, message, object); + public static ResultHolder error(int code, String message, Object data) { + return new ResultHolder(code, message, data); } - public String toString() { - return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE); + public static ResultHolder error(String message, String messageDetail) { + return new ResultHolder(-1, message, messageDetail, null); + } + + public static ResultHolder error(int code, String message, String messageDetail) { + return new ResultHolder(code, message, messageDetail, null); } }