using System.ComponentModel.DataAnnotations;
using MilitaryTrainingManagement.Models.Enums;

namespace MilitaryTrainingManagement.Models.DTOs;

/// <summary>
/// 创建修改请求
/// </summary>
public class CreateModificationRequest
{
    /// <summary>
    /// 请求类型
    /// </summary>
    [Required(ErrorMessage = "请求类型为必填项")]
    public ApprovalRequestType Type { get; set; }

    /// <summary>
    /// 目标实体ID
    /// </summary>
    [Required(ErrorMessage = "目标实体ID为必填项")]
    public int TargetEntityId { get; set; }

    /// <summary>
    /// 修改原因
    /// </summary>
    [Required(ErrorMessage = "修改原因为必填项")]
    [MaxLength(500, ErrorMessage = "修改原因长度不能超过500个字符")]
    public string Reason { get; set; } = string.Empty;

    /// <summary>
    /// 请求的更改（JSON格式）
    /// </summary>
    [Required(ErrorMessage = "请求的更改为必填项")]
    public string RequestedChanges { get; set; } = string.Empty;
}

/// <summary>
/// 审批处理请求
/// </summary>
public class ProcessApprovalRequest
{
    /// <summary>
    /// 审批意见
    /// </summary>
    [MaxLength(500, ErrorMessage = "审批意见长度不能超过500个字符")]
    public string? Comments { get; set; }
}

/// <summary>
/// 审批请求响应
/// </summary>
public class ApprovalRequestResponse
{
    public int Id { get; set; }
    public ApprovalRequestType Type { get; set; }
    public string TypeName { get; set; } = string.Empty;
    public int TargetEntityId { get; set; }
    public int RequestedByUserId { get; set; }
    public string RequestedByUserName { get; set; } = string.Empty;
    public int RequestedByUnitId { get; set; }
    public string RequestedByUnitName { get; set; } = string.Empty;
    public string Reason { get; set; } = string.Empty;
    public string OriginalData { get; set; } = string.Empty;
    public string RequestedChanges { get; set; } = string.Empty;
    public ApprovalStatus Status { get; set; }
    public string StatusName { get; set; } = string.Empty;
    public int? ReviewedByUserId { get; set; }
    public string? ReviewedByUserName { get; set; }
    public string? ReviewComments { get; set; }
    public DateTime RequestedAt { get; set; }
    public DateTime? ReviewedAt { get; set; }
}

/// <summary>
/// 审批请求列表查询参数
/// </summary>
public class ApprovalRequestQueryParams
{
    /// <summary>
    /// 请求类型筛选
    /// </summary>
    public ApprovalRequestType? Type { get; set; }

    /// <summary>
    /// 状态筛选
    /// </summary>
    public ApprovalStatus? Status { get; set; }

    /// <summary>
    /// 页码
    /// </summary>
    public int Page { get; set; } = 1;

    /// <summary>
    /// 每页数量
    /// </summary>
    public int PageSize { get; set; } = 20;
}
