using Rhea.Common; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Tiger.IBusiness { ///// ///// API 返回 泛型标准类 ///// ///// Data数据类型 //public class ApiAction : Rhea.Common.ApiAction //{ // /// // /// 返回的本地化信息 // /// // public AuthOptions Options { get; set; } = new(); // /// // /// 捕获当前 Action 的异常,返回数据和消息, 并记录日志 // /// // /// 捕获到的异常 // /// 返回消息 // /// 返回数据 // /// // public ApiAction CatchExceptionWithLog(Exception ex, Locale localeMsg, T data) // { // Data = data; // return CatchExceptionWithLog(ex, localeMsg); // } // /// // /// 捕获当前 Action 的异常,返回消息, 并记录日志 // /// // /// 捕获到的异常 // /// 返回消息 // public ApiAction CatchExceptionWithLog(Exception ex, Locale localeMsg) // { // CatchException(ex, localeMsg); // Logger.Default.Fatal(ex, localeMsg.Default()); // return this; // } // /// // /// 捕获当前 Action 的异常,返回数据和消息, 并记录日志 // /// // /// 捕获到的异常 // /// 返回消息,最终按 "Catch ApiAction Exception : {msg}. {ex.Message}{ex.StackTrace}" 返回 // /// 返回数据 // /// // public ApiAction CatchExceptionWithLog(Exception ex, string msg, T data) // { // Data = data; // return CatchExceptionWithLog(ex, msg); // } // /// // /// 捕获当前 Action 的异常,返回消息, 并记录日志 // /// // /// 捕获到的异常 // /// 返回消息,最终按 "Catch ApiAction Exception : {msg}. {ex.Message}{ex.StackTrace}" 返回 // public ApiAction CatchExceptionWithLog(Exception ex, string msg = null) // { // CatchException(ex, msg); // Logger.Default.Fatal(ex, msg); // return this; // } //} ///// ///// API 返回 标准类 ///// //public class ApiAction : Rhea.Common.ApiAction //{ // /// // /// 返回的本地化信息 // /// // public AuthOptions Options { get; set; } = new(); // /// // /// 捕获当前 Action 的异常,返回数据和消息, 并记录日志 // /// // /// 捕获到的异常 // /// 返回消息 // /// 返回数据 // /// // public ApiAction CatchExceptionWithLog(Exception ex, Locale localeMsg, object data) // { // Data = data; // return CatchExceptionWithLog(ex, localeMsg); // } // /// // /// 捕获当前 Action 的异常,返回消息, 并记录日志 // /// // /// 捕获到的异常 // /// 返回消息 // public ApiAction CatchExceptionWithLog(Exception ex, Locale localeMsg) // { // CatchException(ex, localeMsg); // Logger.Default.Fatal(ex, localeMsg.Default()); // return this; // } // /// // /// 捕获当前 Action 的异常,返回数据和消息, 并记录日志 // /// // /// 捕获到的异常 // /// 返回消息,最终按 "Catch ApiAction Exception : {msg}. {ex.Message}{ex.StackTrace}" 返回 // /// 返回数据 // /// // public ApiAction CatchExceptionWithLog(Exception ex, string msg, object data) // { // Data = data; // return CatchExceptionWithLog(ex, msg); // } // /// // /// 捕获当前 Action 的异常,返回消息, 并记录日志 // /// // /// 捕获到的异常 // /// 返回消息,最终按 "Catch ApiAction Exception : {msg}. {ex.Message}{ex.StackTrace}" 返回 // public ApiAction CatchExceptionWithLog(Exception ex, string msg = null) // { // CatchException(ex, msg); // Logger.Default.Fatal(ex, msg); // return this; // } //} /// /// ApiAction 扩展类 /// public static class ApiActionExtension { /// /// 捕获当前 Action 的异常,返回数据和消息, 并记录日志 /// /// 捕获到的异常 /// 返回消息 /// 返回数据 /// public static ApiAction CatchExceptionWithLog(this ApiAction action, Exception ex, Locale localeMsg, T data) { action.Data = data; return CatchExceptionWithLog(action, ex, localeMsg); } /// /// 捕获当前 Action 的异常,返回消息, 并记录日志 /// /// 捕获到的异常 /// 返回消息 public static ApiAction CatchExceptionWithLog(this ApiAction action, Exception ex, Locale localeMsg) { action.CatchException(ex, localeMsg); Logger.Default.Fatal(ex, localeMsg.Default()); return action; } /// /// 捕获当前 Action 的异常,返回数据和消息, 并记录日志 /// /// 捕获到的异常 /// 返回消息,最终按 "Catch ApiAction Exception : {msg}. {ex.Message}{ex.StackTrace}" 返回 /// 返回数据 /// public static ApiAction CatchExceptionWithLog(this ApiAction action, Exception ex, string msg, T data) { action.Data = data; return CatchExceptionWithLog(action, ex, msg); } /// /// 捕获当前 Action 的异常,返回消息, 并记录日志 /// /// 捕获到的异常 /// 返回消息,最终按 "Catch ApiAction Exception : {msg}. {ex.Message}{ex.StackTrace}" 返回 public static ApiAction CatchExceptionWithLog(this ApiAction action, Exception ex, string msg = null) { action.CatchException(ex, msg); Logger.Default.Fatal(ex, msg); return action; } /// /// 捕获当前 Action 的异常,返回数据和消息, 并记录日志 /// /// 捕获到的异常 /// 返回消息 /// 返回数据 public static ApiAction CatchExceptionWithLog(this ApiAction action, Exception ex, Locale localeMsg, object data) { action.Data = data; return CatchExceptionWithLog(action, ex, localeMsg); } /// /// 捕获当前 Action 的异常,返回消息, 并记录日志 /// /// 捕获到的异常 /// 返回消息 public static ApiAction CatchExceptionWithLog(this ApiAction action, Exception ex, Locale localeMsg) { action.CatchException(ex, localeMsg); Logger.Default.Fatal(ex, localeMsg.Default()); return action; } /// /// 捕获当前 Action 的异常,返回数据和消息, 并记录日志 /// /// 捕获到的异常 /// 返回消息,最终按 "Catch ApiAction Exception : {msg}. {ex.Message}{ex.StackTrace}" 返回 /// 返回数据 public static ApiAction CatchExceptionWithLog(this ApiAction action, Exception ex, string msg, object data) { action.Data = data; return CatchExceptionWithLog(action, ex, msg); } /// /// 捕获当前 Action 的异常,返回消息, 并记录日志 /// /// 捕获到的异常 /// 返回消息,最终按 "Catch ApiAction Exception : {msg}. {ex.Message}{ex.StackTrace}" 返回 public static ApiAction CatchExceptionWithLog(this ApiAction action, Exception ex, string msg = null) { action.CatchException(ex, msg); Logger.Default.Fatal(ex, msg); return action; } } /// /// ApiAction 扩展实体 /// public class ApiActionExt : ApiAction { /// /// SqlSugar IncludesAllFirstLayer /// public bool NeedInclude { get; set; } = false; } }