From 316b95d1e500b539cfec641e2aacb0bdf594ff56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=96=B5=E4=BD=A0=E4=B8=AA=E6=97=BA=E5=91=80?= Date: Fri, 17 Jan 2025 18:00:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=98=80=E5=A2=9E=E5=8A=A0=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=B8=B8=E7=94=A8=E5=93=8D=E5=BA=94=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E9=9B=86=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Utils/AdminResultProvider.cs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/Admin.NET/Admin.NET.Core/Utils/AdminResultProvider.cs b/Admin.NET/Admin.NET.Core/Utils/AdminResultProvider.cs index 5e6f06a7..a9e1d959 100644 --- a/Admin.NET/Admin.NET.Core/Utils/AdminResultProvider.cs +++ b/Admin.NET/Admin.NET.Core/Utils/AdminResultProvider.cs @@ -132,6 +132,45 @@ public class AdminResultProvider : IUnifyResultProvider Time = DateTime.Now }; } + + /// + /// 返回成功结果集 + /// + /// + /// + /// + public static AdminResult Ok(string message, object data = default) + { + return new AdminResult + { + Code = StatusCodes.Status200OK, + Message = message, + Result = data, + Type = "success", + Extras = UnifyContext.Take(), + Time = DateTime.Now + }; + } + + /// + /// 返回失败结果集 + /// + /// + /// + /// + /// + public static AdminResult Error(string message, int code = StatusCodes.Status400BadRequest, object data = default) + { + return new AdminResult + { + Code = code, + Message = message, + Result = data, + Type = "error", + Extras = UnifyContext.Take(), + Time = DateTime.Now + }; + } } ///