using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace HoneyBox.Admin.Entities;

/// <summary>
/// 操作日志
/// </summary>
[Table("operation_logs")]
public class OperationLog
{
    /// <summary>
    /// 主键ID
    /// </summary>
    [Key]
    public long Id { get; set; }

    /// <summary>
    /// 管理员ID
    /// </summary>
    public long? AdminUserId { get; set; }

    /// <summary>
    /// 用户名
    /// </summary>
    [MaxLength(50)]
    public string? Username { get; set; }

    /// <summary>
    /// 操作模块
    /// </summary>
    [MaxLength(50)]
    public string? Module { get; set; }

    /// <summary>
    /// 操作动作
    /// </summary>
    [MaxLength(50)]
    public string? Action { get; set; }

    /// <summary>
    /// 请求方法
    /// </summary>
    [MaxLength(10)]
    public string? Method { get; set; }

    /// <summary>
    /// 请求URL
    /// </summary>
    [MaxLength(500)]
    public string? Url { get; set; }

    /// <summary>
    /// IP地址
    /// </summary>
    [MaxLength(50)]
    public string? Ip { get; set; }

    /// <summary>
    /// 请求数据
    /// </summary>
    public string? RequestData { get; set; }

    /// <summary>
    /// 响应数据
    /// </summary>
    public string? ResponseData { get; set; }

    /// <summary>
    /// 状态：0失败 1成功
    /// </summary>
    public byte Status { get; set; }

    /// <summary>
    /// 错误信息
    /// </summary>
    [MaxLength(2000)]
    public string? ErrorMsg { get; set; }

    /// <summary>
    /// 执行时长（毫秒）
    /// </summary>
    public int Duration { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    public DateTime CreatedAt { get; set; } = DateTime.Now;
}
