namespace MilitaryTrainingManagement.Services.Interfaces;

/// <summary>
/// 文件上传服务接口
/// </summary>
public interface IFileUploadService
{
    /// <summary>
    /// 上传人员照片
    /// </summary>
    /// <param name="file">照片文件</param>
    /// <returns>保存的文件路径</returns>
    Task<string> UploadPhotoAsync(IFormFile file);

    /// <summary>
    /// 上传支持文档
    /// </summary>
    /// <param name="file">文档文件</param>
    /// <returns>保存的文件路径</returns>
    Task<string> UploadDocumentAsync(IFormFile file);

    /// <summary>
    /// 验证照片格式（2寸照片要求）
    /// </summary>
    /// <param name="file">照片文件</param>
    /// <returns>验证结果</returns>
    Task<PhotoValidationResult> ValidatePhotoAsync(IFormFile file);

    /// <summary>
    /// 删除文件
    /// </summary>
    /// <param name="filePath">文件路径</param>
    Task DeleteFileAsync(string filePath);

    /// <summary>
    /// 获取文件完整路径
    /// </summary>
    /// <param name="relativePath">相对路径</param>
    /// <returns>完整路径</returns>
    string GetFullPath(string relativePath);
}

/// <summary>
/// 照片验证结果
/// </summary>
public class PhotoValidationResult
{
    public bool IsValid { get; set; }
    public string? ErrorMessage { get; set; }
    public int? Width { get; set; }
    public int? Height { get; set; }

    public static PhotoValidationResult Success(int width, int height) => new()
    {
        IsValid = true,
        Width = width,
        Height = height
    };

    public static PhotoValidationResult Failure(string errorMessage) => new()
    {
        IsValid = false,
        ErrorMessage = errorMessage
    };
}
