using System.Collections.Generic; using System.Linq; using SqlSugar; using Yi.Framework.Infrastructure.Data.Entities; using Yi.Framework.Infrastructure.Ddd.Entities; namespace Yi.Furion.Core.Bbs.Entities { [SugarTable("Article")] public class ArticleEntity : IEntity, ISoftDelete { [SugarColumn(IsPrimaryKey = true)] public long Id { get; set; } public bool IsDeleted { get; set; } [SugarColumn(Length = 999999)] public string Content { get; set; } public string Name { get; set; } public long DiscussId { get; set; } public long ParentId { get; set; } [SugarColumn(IsIgnore = true)] public List Children { get; set; } } public static class ArticleEntityExtensions { /// /// 平铺自己 /// /// /// public static List Tile(this List entities) { if (entities is null) return new List(); var result = new List(); return StartRecursion(entities, result); } private static List StartRecursion(List entities, List result) { foreach (var entity in entities) { result.Add(entity); if (entity.Children is not null && entity.Children.Where(x => x.IsDeleted == false).Count() > 0) { StartRecursion(entity.Children, result); } } return result; } } }