sunpengfei
2025-08-07 59e73ad4283491cd407854874879e0ddc8dafaba
FlexJobApi.Core/Entities/Common/DictionaryData.cs
@@ -13,11 +13,11 @@
    /// <summary>
    /// 字典数据
    /// </summary>
    public class DictionaryData : CommonEntity, IEntityTypeBuilder<DictionaryData>
    public class DictionaryData : CommonEntity, IEntityTypeBuilder<DictionaryData>, ITreeData<DictionaryData>, IIsDisabled
    {
        public DictionaryData()
        {
            Childrens = [];
            Children = [];
        }
        /// <summary>
@@ -43,12 +43,18 @@
        /// <summary>
        /// 下级
        /// </summary>
        public List<DictionaryData> Childrens { get; set; }
        public List<DictionaryData> Children { get; set; }
        /// <summary>
        /// 字典路径
        /// </summary>
        public string Path { get; set; }
        /// <summary>
        /// 编号
        /// </summary>
        [MaxLength(128)]
        [Required]
        public string Code { get; set; }
        /// <summary>
@@ -82,10 +88,16 @@
        /// </summary>
        public string Field5 { get; set; }
        /// <summary>
        /// 是否禁用
        /// </summary>
        public bool IsDisabled { get; set; }
        public void Configure(EntityTypeBuilder<DictionaryData> entityBuilder, DbContext dbContext, Type dbContextLocator)
        {
            entityBuilder.HasIndex(x => x.Code).IsUnique();
            entityBuilder
                .HasMany(x => x.Childrens)
                .HasMany(x => x.Children)
                .WithOne(x => x.Parent)
                .HasForeignKey(x => x.ParentId)
                .OnDelete(DeleteBehavior.ClientSetNull);