From 6af2daad181f957eadcdcf580302eebd59ff1720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=A2=A6=E6=8A=80=E6=9C=AF?= <596392912@qq.com> Date: Sun, 10 Mar 2024 11:46:54 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E5=AE=8C=E5=96=84=20R?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/springblade/core/tool/api/R.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/api/R.java b/blade-core-tool/src/main/java/org/springblade/core/tool/api/R.java index 0f04315..6a9e513 100644 --- a/blade-core-tool/src/main/java/org/springblade/core/tool/api/R.java +++ b/blade-core-tool/src/main/java/org/springblade/core/tool/api/R.java @@ -130,6 +130,16 @@ public class R implements Serializable { return new R<>(code, data, data == null ? BladeConstant.DEFAULT_NULL_MESSAGE : msg); } + /** + * 返回成功 + * + * @param 泛型标记 + * @return Result + */ + public static R success() { + return new R<>(ResultCode.SUCCESS); + } + /** * 返回R * @@ -222,4 +232,16 @@ public class R implements Serializable { return flag ? success(BladeConstant.DEFAULT_SUCCESS_MESSAGE) : fail(BladeConstant.DEFAULT_FAILURE_MESSAGE); } + /** + * 根据状态返回成功或者失败 + * + * @param status 状态 + * @param msg 异常msg + * @param 泛型标记 + * @return Result + */ + public static R status(boolean status, String msg) { + return status ? R.success() : R.fail(msg); + } + }