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; + } }