namespace MilitaryTrainingManagement.Models.Entities;

/// <summary>
/// 审计日志实体
/// </summary>
public class AuditLog
{
    public int Id { get; set; }
    
    /// <summary>
    /// 实体类型名称
    /// </summary>
    public string EntityType { get; set; } = string.Empty;
    
    /// <summary>
    /// 实体ID
    /// </summary>
    public int EntityId { get; set; }
    
    /// <summary>
    /// 操作类型 (Create, Update, Delete, Approve, Reject, etc.)
    /// </summary>
    public string Action { get; set; } = string.Empty;
    
    /// <summary>
    /// 操作描述
    /// </summary>
    public string? Description { get; set; }
    
    /// <summary>
    /// 修改前的值（JSON格式）
    /// </summary>
    public string? OldValues { get; set; }
    
    /// <summary>
    /// 修改后的值（JSON格式）
    /// </summary>
    public string? NewValues { get; set; }
    
    /// <summary>
    /// 变更的字段列表（JSON数组）
    /// </summary>
    public string? ChangedFields { get; set; }
    
    /// <summary>
    /// 操作用户ID
    /// </summary>
    public int? UserId { get; set; }
    
    /// <summary>
    /// 操作用户
    /// </summary>
    public UserAccount? User { get; set; }
    
    /// <summary>
    /// 操作用户所属组织单位ID
    /// </summary>
    public int? OrganizationalUnitId { get; set; }
    
    /// <summary>
    /// 操作用户所属组织单位
    /// </summary>
    public OrganizationalUnit? OrganizationalUnit { get; set; }
    
    /// <summary>
    /// 操作时间戳
    /// </summary>
    public DateTime Timestamp { get; set; } = DateTime.UtcNow;
    
    /// <summary>
    /// 客户端IP地址
    /// </summary>
    public string? IpAddress { get; set; }
    
    /// <summary>
    /// 用户代理（浏览器信息）
    /// </summary>
    public string? UserAgent { get; set; }
    
    /// <summary>
    /// 请求路径
    /// </summary>
    public string? RequestPath { get; set; }
    
    /// <summary>
    /// 是否成功
    /// </summary>
    public bool IsSuccess { get; set; } = true;
    
    /// <summary>
    /// 错误信息（如果操作失败）
    /// </summary>
    public string? ErrorMessage { get; set; }
}
