using System;
using SqlSugar;

namespace MDL.Models
{
    /// <summary>
    /// 客户API信息表
    /// </summary>
    [SugarTable("customer_apis")]
    public class CustomerApiEntity
    {
        /// <summary>
        /// 主键ID，自增
        /// </summary>
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
        public int Id { get; set; }

        /// <summary>
        /// 客户ID（关联customers表）
        /// </summary>
        [SugarColumn(IsNullable = false, ColumnDescription = "客户ID")]
        public int CustomerId { get; set; }

        /// <summary>
        /// 客户代码（与customers表关联）
        /// </summary>
        [SugarColumn(Length = 50, IsNullable = false, ColumnDescription = "客户代码")]
        public string CustomerCode { get; set; }

        /// <summary>
        /// API密钥
        /// </summary>
        [SugarColumn(Length = 100, IsNullable = false, ColumnDescription = "API密钥")]
        public string ApiKey { get; set; }

        /// <summary>
        /// API密钥状态（Y: 启用, N: 禁用）
        /// </summary>
        [SugarColumn(Length = 1, DefaultValue = "Y", IsNullable = false, ColumnDescription = "API密钥状态")]
        public string Status { get; set; } = "Y";

        /// <summary>
        /// API密钥过期时间
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnDescription = "API密钥过期时间")]
        public DateTime? ExpireDate { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        [SugarColumn(IsNullable = false, ColumnDescription = "创建时间")]
        public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

        /// <summary>
        /// 更新时间
        /// </summary>
        [SugarColumn(IsNullable = false, ColumnDescription = "更新时间")]
        public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;

        /// <summary>
        /// 备注信息
        /// </summary>
        [SugarColumn(Length = 500, IsNullable = true, ColumnDescription = "备注信息")]
        public string Remark { get; set; }

        /// <summary>
        /// 与客户表的关联关系
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        [Navigate(NavigateType.OneToOne, nameof(CustomerCode), nameof(CustomerEntity.CustomerCode))]
        public CustomerEntity Customer { get; set; }
    }
}