using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace HoneyBox.Admin.Entities;

/// <summary>
/// 部门（支持无限嵌套）
/// </summary>
[Table("departments")]
public class Department
{
    /// <summary>
    /// 主键ID
    /// </summary>
    [Key]
    public long Id { get; set; }

    /// <summary>
    /// 父部门ID，0表示顶级部门
    /// </summary>
    public long ParentId { get; set; } = 0;

    /// <summary>
    /// 部门名称
    /// </summary>
    [Required]
    [MaxLength(100)]
    public string Name { get; set; } = null!;

    /// <summary>
    /// 部门编码
    /// </summary>
    [MaxLength(50)]
    public string? Code { get; set; }

    /// <summary>
    /// 部门描述
    /// </summary>
    [MaxLength(500)]
    public string? Description { get; set; }

    /// <summary>
    /// 排序号
    /// </summary>
    public int SortOrder { get; set; } = 0;

    /// <summary>
    /// 状态：0禁用 1启用
    /// </summary>
    public byte Status { get; set; } = 1;

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

    /// <summary>
    /// 更新时间
    /// </summary>
    public DateTime? UpdatedAt { get; set; }

    // 导航属性
    /// <summary>
    /// 部门下的管理员
    /// </summary>
    public virtual ICollection<AdminUser> AdminUsers { get; set; } = new List<AdminUser>();

    /// <summary>
    /// 部门菜单关联
    /// </summary>
    public virtual ICollection<DepartmentMenu> DepartmentMenus { get; set; } = new List<DepartmentMenu>();
}
