SystemArea.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System.ComponentModel.DataAnnotations;
  2. using Masuit.Tools.Models;
  3. using SqlSugar;
  4. using static EasyTemplate.Tool.Entity.PublicEnum;
  5. namespace EasyTemplate.Tool.Entity;
  6. /// <summary>
  7. /// 系统区域
  8. /// </summary>
  9. [SugarTable(null, "系统区域")]
  10. [SugarIndex("ParentCode", nameof(ParentCode), OrderByType.Asc)]
  11. public class SystemArea : EntityBaseLite
  12. {
  13. /// <summary>
  14. /// 父级编码
  15. /// </summary>
  16. [SugarColumn(ColumnDescription = "父级编码", IsNullable = true)]
  17. public long ParentCode { get; set; }
  18. /// <summary>
  19. /// 地区编码
  20. /// </summary>
  21. [SugarColumn(ColumnDescription = "地区编码", IsNullable = true, IsTreeKey = true)]
  22. public long AreaCode { get; set; }
  23. /// <summary>
  24. /// 键
  25. /// </summary>
  26. [SugarColumn(ColumnDescription = "地区名称", IsNullable = true)]
  27. public string AreaName { get; set; }
  28. /// <summary>
  29. /// 层级
  30. /// </summary>
  31. [SugarColumn(ColumnDescription = "层级", IsNullable = true)]
  32. public int Level { get; set; }
  33. /// <summary>
  34. /// 排序
  35. /// </summary>
  36. [SugarColumn(ColumnDescription = "排序", DefaultValue ="0", IsNullable = true)]
  37. public long Sort { get; set; }
  38. /// <summary>
  39. ///
  40. /// </summary>
  41. [SugarColumn(IsIgnore = true)]
  42. public List<SystemArea> Children { get; set; }
  43. }
  44. public class SystemAreaSeedData : ISeedData<SystemArea>
  45. {
  46. public IEnumerable<SystemArea> Generate()
  47. {
  48. var json = File.ReadAllText($"{AppDomain.CurrentDomain.BaseDirectory}wwwroot\\data\\area.json");
  49. if (!string.IsNullOrWhiteSpace(json))
  50. {
  51. var list = json.ToEntity<List<SystemArea>>();
  52. if (list?.Count > 0)
  53. {
  54. return list;
  55. }
  56. }
  57. return new List<SystemArea>();
  58. }
  59. }