using System.Collections;
using YBEE.EQM.Core;

namespace YBEE.EQM.Application
{
    /// <summary>
    /// 菜单输出参数
    /// </summary>
    public class SysMenuOutput : ITreeNode
    {
        /// <summary>
        /// 菜单Id
        /// </summary>
        [Required]
        public int Id { get; set; }

        /// <summary>
        /// 父Id
        /// </summary>
        [Required]
        public int Pid { get; set; }

        /// <summary>
        /// 名称
        /// </summary>
        [Required]
        public string Name { get; set; }

        /// <summary>
        /// 编码
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// 菜单类型（字典 0目录 1菜单 2按钮）
        /// </summary>
        [Required]
        public MenuType MenuType { get; set; }

        /// <summary>
        /// 图标
        /// </summary>
        public string Icon { get; set; }

        /// <summary>
        /// 路由地址
        /// </summary>
        public string Router { get; set; }

        /// <summary>
        /// 组件地址
        /// </summary>
        public string Component { get; set; }

        /// <summary>
        /// 权限标识
        /// </summary>
        public string Permission { get; set; }

        /// <summary>
        /// 打开方式（字典 0无 1组件 2内链 3外链）
        /// </summary>
        public MenuOpenType OpenType { get; set; }

        /// <summary>
        /// 是否可见
        /// </summary>
        public bool Visible { get; set; }

        /// <summary>
        /// 内链地址
        /// </summary>
        public string Link { get; set; }

        /// <summary>
        /// 重定向地址
        /// </summary>
        public string Redirect { get; set; }

        /// <summary>
        /// 排序
        /// </summary>
        public int Sort { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }

        /// <summary>
        /// 子菜单项
        /// </summary>
        public List<SysMenuOutput> Children { get; set; }

        public int GetId()
        {
            return Id;
        }

        public int GetPid()
        {
            return Pid;
        }

        public void SetChildren(IList children)
        {
            var c = (List<SysMenuOutput>)children;
            if (c.Any())
            {
                Children = c;
            }
        }
    }
}