namespace HoneyBox.Admin.Business.Models.Upload;

/// <summary>
/// 上传响应模型
/// </summary>
public class UploadResponse
{
    /// <summary>
    /// 文件URL
    /// </summary>
    public string Url { get; set; } = string.Empty;

    /// <summary>
    /// 文件名
    /// </summary>
    public string FileName { get; set; } = string.Empty;

    /// <summary>
    /// 文件大小(字节)
    /// </summary>
    public long FileSize { get; set; }
}

/// <summary>
/// 获取预签名上传URL请求
/// </summary>
public class GetPresignedUrlRequest
{
    /// <summary>
    /// 原始文件名
    /// </summary>
    public string FileName { get; set; } = string.Empty;

    /// <summary>
    /// 文件MIME类型
    /// </summary>
    public string ContentType { get; set; } = string.Empty;

    /// <summary>
    /// 文件大小(字节)
    /// </summary>
    public long FileSize { get; set; }
}

/// <summary>
/// 预签名上传URL响应
/// </summary>
public class PresignedUrlResponse
{
    /// <summary>
    /// 预签名上传URL
    /// </summary>
    public string UploadUrl { get; set; } = string.Empty;

    /// <summary>
    /// 文件最终访问URL
    /// </summary>
    public string FileUrl { get; set; } = string.Empty;

    /// <summary>
    /// 对象Key（COS路径）
    /// </summary>
    public string ObjectKey { get; set; } = string.Empty;

    /// <summary>
    /// URL过期时间（秒）
    /// </summary>
    public int ExpiresIn { get; set; }

    /// <summary>
    /// 存储类型 (1=本地, 3=COS)
    /// </summary>
    public string StorageType { get; set; } = string.Empty;
}

/// <summary>
/// 上传结果(内部使用)
/// </summary>
public class UploadResult
{
    /// <summary>
    /// 是否成功
    /// </summary>
    public bool Success { get; set; }

    /// <summary>
    /// 文件URL
    /// </summary>
    public string? Url { get; set; }

    /// <summary>
    /// 错误信息
    /// </summary>
    public string? ErrorMessage { get; set; }

    /// <summary>
    /// 创建成功结果
    /// </summary>
    public static UploadResult Ok(string url)
    {
        return new UploadResult
        {
            Success = true,
            Url = url
        };
    }

    /// <summary>
    /// 创建失败结果
    /// </summary>
    public static UploadResult Fail(string errorMessage)
    {
        return new UploadResult
        {
            Success = false,
            ErrorMessage = errorMessage
        };
    }
}
