From 60fca91c9c89135188552ce959f131fca9aab31c Mon Sep 17 00:00:00 2001 From: "Jerry.Chen" Date: Wed, 11 Nov 2020 10:16:26 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E5=A2=9E=E5=8A=A0=E9=9D=99=E6=80=81?= =?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=8C=E7=94=A8=E4=BA=8E=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=20Result=20=E5=AE=9E=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/myoss/cloud/core/lang/dto/Result.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/myoss-starter-core/src/main/java/app/myoss/cloud/core/lang/dto/Result.java b/myoss-starter-core/src/main/java/app/myoss/cloud/core/lang/dto/Result.java index ca8fa18..46ddd14 100644 --- a/myoss-starter-core/src/main/java/app/myoss/cloud/core/lang/dto/Result.java +++ b/myoss-starter-core/src/main/java/app/myoss/cloud/core/lang/dto/Result.java @@ -136,4 +136,50 @@ public Object getExtraInfo(String key) { public String toString() { return JsonApi.toJson(this); } + + /** + * 创建成功的返回值 + * + * @param 泛型 + * @return Result 实例 + */ + public static Result ok() { + return new Result<>(); + } + + /** + * 创建成功的返回值 + * + * @param value 结果值 + * @param 泛型 + * @return Result 实例 + */ + public static Result ok(T value) { + return new Result<>(value); + } + + /** + * 创建失败的返回值 + * + * @param 泛型 + * @return Result 实例 + */ + public static Result fail() { + Result result = new Result<>(); + result.setSuccess(false); + return result; + } + + /** + * 创建失败的返回值 + * + * @param value 结果值 + * @param 泛型 + * @return Result 实例 + */ + public static Result fail(T value) { + Result result = new Result<>(value); + result.setSuccess(false); + return result; + } }