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);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Atomx.Data.Migrations
{
/// <inheritdoc />
public partial class _02 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "Count",
table: "Areas",
type: "integer",
nullable: false,
defaultValue: 0);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Count",
table: "Areas");
}
}
}

View File

@@ -243,6 +243,9 @@ namespace Atomx.Data.Migrations
b.Property<bool>("AllowShipping")
.HasColumnType("boolean");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<long>("CountryId")
.HasColumnType("bigint");