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
|
{
|
/// <summary>
|
/// 字典数据
|
/// </summary>
|
public class DictionaryData : CommonEntity, IEntityTypeBuilder<DictionaryData>, ITreeData<DictionaryData>, IIsDisabled, IDbAuditLogIgnore
|
{
|
public DictionaryData()
|
{
|
Children = [];
|
}
|
|
/// <summary>
|
/// 类别Id
|
/// </summary>
|
public Guid CategoryId { get; set; }
|
|
/// <summary>
|
/// 类别
|
/// </summary>
|
public DictionaryCategory Category { get; set; }
|
|
/// <summary>
|
/// 上级Id
|
/// </summary>
|
public Guid? ParentId { get; set; }
|
|
/// <summary>
|
/// 上级
|
/// </summary>
|
public DictionaryData Parent { get; set; }
|
|
/// <summary>
|
/// 下级
|
/// </summary>
|
public List<DictionaryData> Children { get; set; }
|
|
/// <summary>
|
/// 字典路径
|
/// </summary>
|
public string Path { get; set; }
|
|
/// <summary>
|
/// 编号
|
/// </summary>
|
[MaxLength(128)]
|
[Required]
|
public string Code { get; set; }
|
|
/// <summary>
|
/// 显示内容
|
/// </summary>
|
[Required]
|
public string Content { get; set; }
|
|
/// <summary>
|
/// 字段1
|
/// </summary>
|
public string Field1 { get; set; }
|
|
/// <summary>
|
/// 字段2
|
/// </summary>
|
public string Field2 { get; set; }
|
|
/// <summary>
|
/// 字段3
|
/// </summary>
|
public string Field3 { get; set; }
|
|
/// <summary>
|
/// 字段4
|
/// </summary>
|
public string Field4 { get; set; }
|
|
/// <summary>
|
/// 字段5
|
/// </summary>
|
public string Field5 { get; set; }
|
|
/// <summary>
|
/// 深度
|
/// </summary>
|
public int Deep { 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.Children)
|
.WithOne(x => x.Parent)
|
.HasForeignKey(x => x.ParentId)
|
.OnDelete(DeleteBehavior.ClientSetNull);
|
}
|
}
|
}
|