using Furion.DatabaseAccessor; using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml.Serialization; namespace Ewide.Core { [Table("sys_area_code")] [Comment("区域表")] public class SysAreaCode: IEntity { [Key] [Comment("系统使用的区域编码")] [MaxLength(50)] public string Code { get; set; } [Comment("区域的行政编码")] [MaxLength(50)] public string AdCode { get; set; } [Comment("名称")] [Required] [MaxLength(100)] public string Name { get; set; } [Comment("备注")] [MaxLength(1000)] public string Note { get; set; } [Comment("类别")] [Required] public int LevelType { get; set; } [Comment("排序")] public int Sort { get; set; } /// /// 父节点就是去掉后面两位 /// public string ParentCode => LevelType switch { // 市级 => 没有父级 3302 1 => string.Empty, // 区级 => 6位取4位得到市级 330201 2 => Code[0..(Code.Length - 2)], // 其他 => 去除后3位得到上级 330201001 _ => Code[0..(Code.Length - 3)], }; /// /// 多个区域有多个用户绑定自定义数据 /// [XmlIgnore] public ICollection SysUsers { get; set; } /// /// 中间表 /// [XmlIgnore] public List SysUserAreas { get; set; } /// /// 多个区域有多个角色绑定权限数据 /// [XmlIgnore] public ICollection SysRoles { get; set; } /// /// 中间表 /// [XmlIgnore] public List SysRoleAreas { get; set; } /// /// 一个区域有多个组织 /// [XmlIgnore] public ICollection SysOrgs { get; set; } } }