using SqlSugar; using System.ComponentModel; using XF.Domain.Entities; using XF.Domain.Exceptions; using XF.Domain.Repository; namespace Hotline.Settings; [SugarIndex("unique_org_code", nameof(SystemOrganize.OrgCode), OrderByType.Desc, true)] [Description("组织架构")] public class SystemOrganize : CreationEntity { /// /// 组织架构名称 /// public string OrgName { get; set; } /// /// 组织架构Code(001001001) 解析:001,001,001) /// public string OrgCode { get; set; } /// /// 部门级别 /// public int OrgLevel { get; set; } /// /// 部门类型 /// public EOrgType OrgType { get; set; } /// /// 上级ID /// [SugarColumn(IsNullable = true)] public string? ParentId { get; set; } /// /// 上级名称 /// [SugarColumn(IsNullable = true)] public string? ParentName { get; set; } /// /// 是否启用 /// public bool IsEnable { get; set; } [SugarColumn(IsIgnore = true)] public List Children { get; set; } public void InitOrgLevel() { if (OrgCode.Length % 3 != 0) throw new UserFriendlyException("非法部门Code"); OrgLevel = OrgCode.Length / 3; } }