using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FlexJobApi.Core
{
///
/// 字典数据
///
public class DictionaryData : CommonEntity, IEntityTypeBuilder, ITreeData, IIsDisabled, IDbAuditLogIgnore
{
public DictionaryData()
{
Children = [];
}
///
/// 类别Id
///
public Guid CategoryId { get; set; }
///
/// 类别
///
public DictionaryCategory Category { get; set; }
///
/// 上级Id
///
public Guid? ParentId { get; set; }
///
/// 上级
///
public DictionaryData Parent { get; set; }
///
/// 下级
///
public List Children { get; set; }
///
/// 字典路径
///
public string Path { get; set; }
///
/// 编号
///
[MaxLength(128)]
[Required]
public string Code { get; set; }
///
/// 显示内容
///
[Required]
public string Content { get; set; }
///
/// 字段1
///
public string Field1 { get; set; }
///
/// 字段2
///
public string Field2 { get; set; }
///
/// 字段3
///
public string Field3 { get; set; }
///
/// 字段4
///
public string Field4 { get; set; }
///
/// 字段5
///
public string Field5 { get; set; }
///
/// 深度
///
public int Deep { get; set; }
///
/// 是否禁用
///
public bool IsDisabled { get; set; }
public void Configure(EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)
{
entityBuilder.HasIndex(x => x.Code).IsUnique();
entityBuilder
.HasMany(x => x.Children)
.WithOne(x => x.Parent)
.HasForeignKey(x => x.ParentId)
.OnDelete(DeleteBehavior.ClientSetNull);
}
}
}