TProductProperty.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using SqlSugar;
  2. namespace EasyTemplate.Tool.Entity;
  3. /// <summary>
  4. /// 属性
  5. /// </summary>
  6. [SugarTable(null, "属性")]
  7. [SugarIndex("ParentId", nameof(ParentId), OrderByType.Desc)]
  8. public partial class TProductProperty : EntityBaseId, IDeletedFilter
  9. {
  10. /// <summary>
  11. /// 属性名称
  12. /// </summary>
  13. [SugarColumn(ColumnDescription = "属性名称", IsNullable = true)]
  14. public string Name { get; set; }
  15. /// <summary>
  16. /// 父级id
  17. /// </summary>
  18. [SugarColumn(ColumnDescription = "父级id", IsNullable = true)]
  19. public long ParentId { get; set; }
  20. /// <summary>
  21. /// 软删除,1:删除,0:不删除
  22. /// </summary>
  23. [SugarColumn(ColumnDescription = "软删除", DefaultValue = "0")]
  24. public virtual bool IsDelete { get; set; } = false;
  25. /// <summary>
  26. /// 子集
  27. /// </summary>
  28. [SqlSugar.SugarColumn(IsIgnore = true)]
  29. public List<TProductProperty> Children { get; set; }
  30. }
  31. public class TProductPropertySeedData : ISeedData<TProductProperty>
  32. {
  33. public IEnumerable<TProductProperty> Generate()
  34. =>
  35. [
  36. new TProductProperty() { Id = 1, Name="默认", ParentId = 0 },
  37. new TProductProperty() { Id = 2, Name="默认", ParentId = 1 },
  38. new TProductProperty() { Id = 3, Name="颜色", ParentId = 0 },
  39. new TProductProperty() { Id = 4, Name="红色", ParentId = 3 },
  40. new TProductProperty() { Id = 5, Name="绿色", ParentId = 3 },
  41. new TProductProperty() { Id = 6, Name="黄色", ParentId = 3 },
  42. new TProductProperty() { Id = 7, Name="口味", ParentId = 0 },
  43. new TProductProperty() { Id = 8, Name="水果", ParentId = 7 },
  44. new TProductProperty() { Id = 9, Name="可乐", ParentId = 7 },
  45. ];
  46. }