feat:furion rbac搭建

This commit is contained in:
橙子
2023-04-13 21:12:06 +08:00
parent 18696ec542
commit b9dad93c9d
194 changed files with 9557 additions and 75 deletions

View File

@@ -0,0 +1,41 @@
using System.Runtime.ExceptionServices;
using Microsoft.Extensions.Logging;
using Yi.Framework.Infrastructure.Enums;
namespace Yi.Framework.Infrastructure.Exceptions;
/// <summary>
/// <see cref="Exception"/>类的扩展方法
/// </summary>
public static class ExceptionExtensions
{
/// <summary>
/// 使用 <see cref="ExceptionDispatchInfo.Capture"/> 再次抛出异常
/// </summary>
/// <param name="exception">Exception to be re-thrown</param>
public static void ReThrow(this Exception exception)
{
ExceptionDispatchInfo.Capture(exception).Throw();
}
/// <summary>
/// 获取异常中的日志等级
/// </summary>
/// <param name="exception"></param>
/// <param name="defaultLevel"></param>
/// <returns></returns>
public static LogLevel GetLogLevel(this Exception exception, LogLevel defaultLevel = LogLevel.Error)
{
return (exception as IHasLogLevel)?.LogLevel ?? defaultLevel;
}
/// <summary>
/// 获取异常中的日志错误码
/// </summary>
/// <param name="exception"></param>
/// <param name="defaultLevel"></param>
/// <returns></returns>
public static int GetLogErrorCode(this Exception exception, ResultCodeEnum defaultCode = ResultCodeEnum.NotSuccess)
{
return (exception as IHasErrorCode)?.Code ?? (int)defaultCode;
}
}