using System.ComponentModel.DataAnnotations;
using Masuit.Tools.Models;
using SqlSugar;
using static EasyTemplate.Tool.Entity.PublicEnum;
namespace EasyTemplate.Tool.Entity;
///
/// 系统区域
///
[SugarTable(null, "系统区域")]
[SugarIndex("ParentCode", nameof(ParentCode), OrderByType.Asc)]
public class SystemArea : EntityBaseLite
{
///
/// 父级编码
///
[SugarColumn(ColumnDescription = "父级编码", IsNullable = true)]
public long ParentCode { get; set; }
///
/// 地区编码
///
[SugarColumn(ColumnDescription = "地区编码", IsNullable = true, IsTreeKey = true)]
public long AreaCode { get; set; }
///
/// 键
///
[SugarColumn(ColumnDescription = "地区名称", IsNullable = true)]
public string AreaName { get; set; }
///
/// 层级
///
[SugarColumn(ColumnDescription = "层级", IsNullable = true)]
public int Level { get; set; }
///
/// 排序
///
[SugarColumn(ColumnDescription = "排序", DefaultValue ="0", IsNullable = true)]
public long Sort { get; set; }
///
///
///
[SugarColumn(IsIgnore = true)]
public List Children { get; set; }
}
public class SystemAreaSeedData : ISeedData
{
public IEnumerable Generate()
{
var json = File.ReadAllText($"{AppDomain.CurrentDomain.BaseDirectory}wwwroot\\data\\area.json");
if (!string.IsNullOrWhiteSpace(json))
{
var list = json.ToEntity>();
if (list?.Count > 0)
{
return list;
}
}
return new List();
}
}