using System.Collections;
using System.Collections.Generic;

namespace Ewide.Core.Service
{
    /// <summary>
    /// 字典类型与字典值构造的树
    /// </summary>
    public class DictTreeOutput : ITreeNode
    {
        /// <summary>
        /// Id
        /// </summary>
        public string Id { get; set; }

        /// <summary>
        /// 父Id
        /// </summary>
        public string Pid { get; set; }

        /// <summary>
        /// 编码-对应字典值的编码
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// 名称-对应字典值的value
        /// </summary>
        public string Name { get; set; }

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

        /// <summary>
        /// 排序
        /// </summary>
        public int Sort { set; get; }
        /// <summary>
        /// 子节点集合
        /// </summary>
        public List<DictTreeOutput> Children { get; set; } = new List<DictTreeOutput>();

        public string GetId()
        {
            return Id;
        }

        public string GetPid()
        {
            return Pid;
        }

        public void SetChildren(IList children)
        {
            Children = (List<DictTreeOutput>)children;
        }
    }

    public class DictTreeNode : ITreeNode
    {
        /// <summary>
        /// Id
        /// </summary>
        public string Id { get; set; }

        /// <summary>
        /// 父Id
        /// </summary>
        public string ParentId { get; set; }

        /// <summary>
        /// 名称
        /// </summary>
        public string Title { get; set; }

        /// <summary>
        /// 值
        /// </summary>
        public string Value { get; set; }

        /// <summary>
        /// 排序，越小优先级越高
        /// </summary>
        public int Weight { get; set; }

        /// <summary>
        /// 子节点
        /// </summary>
        public List<DictTreeNode> Children { get; set; } = new List<DictTreeNode>();

        public string GetId()
        {
            return Id;
        }

        public string GetPid()
        {
            return ParentId;
        }

        public void SetChildren(IList children)
        {
            Children = (List<DictTreeNode>)children;
        }
    }
}
