namespace HoneyBox.Admin.Business.Models;

/// <summary>
/// 业务异常类
/// </summary>
public class BusinessException : Exception
{
    /// <summary>
    /// 错误码
    /// </summary>
    public int Code { get; }

    /// <summary>
    /// 创建业务异常
    /// </summary>
    /// <param name="code">错误码</param>
    /// <param name="message">错误消息</param>
    public BusinessException(int code, string message) : base(message)
    {
        Code = code;
    }

    /// <summary>
    /// 创建业务异常
    /// </summary>
    /// <param name="code">错误码</param>
    /// <param name="message">错误消息</param>
    /// <param name="innerException">内部异常</param>
    public BusinessException(int code, string message, Exception innerException) : base(message, innerException)
    {
        Code = code;
    }
}

/// <summary>
/// 业务错误码常量
/// </summary>
public static class BusinessErrorCodes
{
    /// <summary>
    /// 成功
    /// </summary>
    public const int Success = 0;

    /// <summary>
    /// 认证失败
    /// </summary>
    public const int AuthenticationFailed = 40001;

    /// <summary>
    /// 权限不足
    /// </summary>
    public const int PermissionDenied = 40101;

    /// <summary>
    /// 参数验证失败
    /// </summary>
    public const int ValidationFailed = 40201;

    /// <summary>
    /// 资源不存在
    /// </summary>
    public const int NotFound = 40401;

    /// <summary>
    /// 资源冲突（如重复数据）
    /// </summary>
    public const int Conflict = 40901;

    /// <summary>
    /// 服务器内部错误
    /// </summary>
    public const int InternalError = 50001;

    /// <summary>
    /// 操作失败
    /// </summary>
    public const int OperationFailed = 50002;

    /// <summary>
    /// 配置错误
    /// </summary>
    public const int ConfigurationError = 50003;
}
