fix 省市地区管理

This commit is contained in:
yxw
2026-01-05 19:09:54 +08:00
parent ea541fb6e4
commit 4eb09a79fc
12 changed files with 1704 additions and 36 deletions

View File

@@ -91,13 +91,13 @@ namespace Atomx.Data.CacheServices
Value = state.Id.ToString()
};
var citysInState = cities.Where(p => p.StateProvinceId == state.Id).ToList();
var citysInState = cities.Where(p => p.ParentId == state.Id).ToList();
foreach (var city in citysInState)
{
var cityItem = new KeyValueTree
{
Label = state.Name,
Value = state.Id.ToString()
Label = city.Name,
Value = city.Id.ToString()
};
cityItem.Children = BuildAreaTree(city.Id, cities, new List<KeyValueTree>());
@@ -250,7 +250,7 @@ namespace Atomx.Data.CacheServices
private List<KeyValueTree> BuildAreaTree(long parentId, List<Area> areas, List<KeyValueTree> result)
{
var data = areas.Where(p => p.ParentId == parentId).ToList();
foreach (var area in areas)
foreach (var area in data)
{
var item = new KeyValueTree
{
@@ -261,7 +261,7 @@ namespace Atomx.Data.CacheServices
if (childs.Count > 0)
{
var childrenTrees = BuildAreaTree(area.Id, areas, result);
item.Children.AddRange(childrenTrees);
item.Children = childrenTrees;
}
result.Add(item);
}