From 4171756c54a23c5d6ab2d5337762cfcd6c1064aa Mon Sep 17 00:00:00 2001 From: xRain Date: Tue, 26 Mar 2024 10:06:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20ErrorWhenTrue=E5=92=8CErro?= =?UTF-8?q?rWhenFalse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controllers/SimApiBaseController.cs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Controllers/SimApiBaseController.cs b/Controllers/SimApiBaseController.cs index 80ea814..e3137a0 100644 --- a/Controllers/SimApiBaseController.cs +++ b/Controllers/SimApiBaseController.cs @@ -50,7 +50,7 @@ public class SimApiBaseController : Controller } /// - /// 检测条件,根据条件返回报错 + /// 检测条件,根据条件返回报错 如果condition是ture报错 /// /// 检测条件 /// 错误代码 @@ -63,6 +63,30 @@ public class SimApiBaseController : Controller } } + + /// + /// 检测条件,根据条件返回报错 如果condition是ture报错 + /// + /// 检测条件 + /// 错误代码 + /// 错误描述 + protected static void ErrorWhenTrue(bool condition, int code = 500, string message = "") + { + ErrorWhen(condition, code, message); + } + + + /// + /// 如果condition是false 报错 + /// + /// + /// + /// + protected static void ErrorWhenFalse(bool condition, int code = 500, string message = "") + { + ErrorWhen(!condition, code, message); + } + /// /// 检测给定的变量是否为NUll ///