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

namespace HoneyBox.Admin.Entities;

/// <summary>
/// 菜单
/// </summary>
[Table("menus")]
public class Menu
{
    /// <summary>
    /// 主键ID
    /// </summary>
    [Key]
    public long Id { get; set; }

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

    /// <summary>
    /// 菜单名称
    /// </summary>
    [Required]
    [MaxLength(50)]
    public string Name { get; set; } = null!;

    /// <summary>
    /// 路由路径
    /// </summary>
    [MaxLength(200)]
    public string? Path { get; set; }

    /// <summary>
    /// 组件路径
    /// </summary>
    [MaxLength(200)]
    public string? Component { get; set; }

    /// <summary>
    /// 图标
    /// </summary>
    [MaxLength(100)]
    public string? Icon { get; set; }

    /// <summary>
    /// 菜单类型：1目录 2菜单 3按钮
    /// </summary>
    public byte MenuType { get; set; } = 1;

    /// <summary>
    /// 权限标识
    /// </summary>
    [MaxLength(100)]
    public string? Permission { get; set; }

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

    /// <summary>
    /// 状态：0隐藏 1显示
    /// </summary>
    public byte Status { get; set; } = 1;

    /// <summary>
    /// 是否外链
    /// </summary>
    public bool IsExternal { get; set; } = false;

    /// <summary>
    /// 是否缓存
    /// </summary>
    public bool IsCache { get; set; } = true;

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

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

    // 导航属性
    /// <summary>
    /// 角色菜单关联
    /// </summary>
    public virtual ICollection<RoleMenu> RoleMenus { get; set; } = new List<RoleMenu>();

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

    /// <summary>
    /// 用户专属菜单关联
    /// </summary>
    public virtual ICollection<AdminUserMenu> AdminUserMenus { get; set; } = new List<AdminUserMenu>();
}
