| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- #nullable enable
- using System.ComponentModel.DataAnnotations;
- using System.ComponentModel.DataAnnotations.Schema;
- using Abp.Domain.Entities.Auditing;
- using VberZero.BaseSystem.Users;
- namespace VberZero.BaseSystem;
- public abstract class TreeEntity<TEntity> : TreeEntity<int, TEntity>
- where TEntity : class
- {
- }
- public abstract class TreeEntity<TPrimaryKey, TEntity> : TreeEntityBase<TPrimaryKey?>
- where TEntity : class
- {
- [ForeignKey("ParentNo")]
- public TEntity Parent { get; set; }
- }
- public abstract class TreeEntityBase<TPrimaryKey> : AuditedEntity<TPrimaryKey, User>
- {
- public const int MaxDepth = 20;
- public const int PathMaxLength = 15 * MaxDepth;
- /// <summary>
- /// 父节点
- /// </summary>
- public TPrimaryKey? ParentNo { get; set; }
- /// <summary>
- /// 路径
- /// </summary>
- [StringLength(PathMaxLength)]
- public string Path { get; set; }
- /// <summary>
- /// 是否是叶子节点
- /// </summary>
- public bool IsLeaf { get; set; }
- /// <summary>
- /// 节点深度
- /// </summary>
- public int Depth { get; set; }
- public int Sort { get; set; }
- }
|