chore
This commit is contained in:
@@ -24,7 +24,7 @@ namespace Atomx.Data.CacheServices
|
||||
/// </summary>
|
||||
/// <param name="parentId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<StateProvince>> GetStateProvinces(long countryId, bool? reload = false);
|
||||
Task<List<Area>> GetStateProvinces(long countryId, bool? reload = false);
|
||||
|
||||
/// <summary>
|
||||
/// 获取州省数据
|
||||
@@ -32,7 +32,7 @@ namespace Atomx.Data.CacheServices
|
||||
/// <param name="countryId"></param>
|
||||
/// <param name="stateProvinceId"></param>
|
||||
/// <returns></returns>
|
||||
Task<StateProvince> GetStateProvince(long countryId, long stateProvinceId);
|
||||
Task<Area> GetStateProvince(long countryId, long stateProvinceId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取地区数据
|
||||
@@ -54,7 +54,7 @@ namespace Atomx.Data.CacheServices
|
||||
/// </summary>
|
||||
/// <param name="stateProvince"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdateStateProvince(StateProvince stateProvince);
|
||||
Task UpdateStateProvince(Area area);
|
||||
|
||||
/// <summary>
|
||||
/// 更新调整国家缓存数据
|
||||
@@ -141,14 +141,14 @@ namespace Atomx.Data.CacheServices
|
||||
/// </summary>
|
||||
/// <param name="countryId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<StateProvince>> GetStateProvinces(long countryId, bool? reload = false)
|
||||
public async Task<List<Area>> GetStateProvinces(long countryId, bool? reload = false)
|
||||
{
|
||||
bool reloadData = reload.HasValue ? reload.Value : false;
|
||||
var cacheData = await GetCacheAsync<List<StateProvince>>($"{CacheKeys.StateProvince}.{countryId}");
|
||||
var cacheData = await GetCacheAsync<List<Area>>($"{CacheKeys.StateProvince}.{countryId}");
|
||||
if (cacheData == null || reloadData)
|
||||
{
|
||||
var stateProvinces = (from p in _dbContext.StateProvinces
|
||||
where p.CountryId == countryId && p.Enabled
|
||||
var stateProvinces = (from p in _dbContext.Areas
|
||||
where p.CountryId == countryId && p.Enabled && p.ParentId == 0
|
||||
select p).ToList();
|
||||
await SetCacheAsync($"{CacheKeys.StateProvince}.{countryId}", stateProvinces);
|
||||
return stateProvinces;
|
||||
@@ -162,7 +162,7 @@ namespace Atomx.Data.CacheServices
|
||||
/// </summary>
|
||||
/// <param name="stateProvinceId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<StateProvince> GetStateProvince(long countryId, long stateProvinceId)
|
||||
public async Task<Area> GetStateProvince(long countryId, long stateProvinceId)
|
||||
{
|
||||
var cacheData = await GetStateProvinces(countryId);
|
||||
var data = cacheData.SingleOrDefault(p => p.Id == stateProvinceId);
|
||||
@@ -183,7 +183,7 @@ namespace Atomx.Data.CacheServices
|
||||
{
|
||||
List<Area> areas = new();
|
||||
var query = from p in _dbContext.Areas
|
||||
where p.CountryId == countryId && p.Enabled
|
||||
where p.CountryId == countryId && p.Enabled && p.StateProvinceId != 0
|
||||
select p;
|
||||
var count = query.Count();
|
||||
int size = 50;
|
||||
@@ -193,7 +193,7 @@ namespace Atomx.Data.CacheServices
|
||||
var list = query.Skip((i - 1) * size).Take(size).ToList();
|
||||
areas.AddRange(list);
|
||||
}
|
||||
await SetCacheAsync(CacheKeys.Country, areas);
|
||||
await SetCacheAsync($"{CacheKeys.City}.{countryId}", areas);
|
||||
return areas;
|
||||
}
|
||||
return cacheData;
|
||||
@@ -218,16 +218,16 @@ namespace Atomx.Data.CacheServices
|
||||
/// </summary>
|
||||
/// <param name="stateProvince"></param>
|
||||
/// <returns></returns>
|
||||
public async Task UpdateStateProvince(StateProvince stateProvince)
|
||||
public async Task UpdateStateProvince(Area area)
|
||||
{
|
||||
var cacheData = await GetStateProvinces(stateProvince.CountryId);
|
||||
var data = cacheData.Where(p => p.Id == stateProvince.Id).SingleOrDefault();
|
||||
var cacheData = await GetStateProvinces(area.CountryId);
|
||||
var data = cacheData.Where(p => p.Id == area.Id).SingleOrDefault();
|
||||
if (data != null)
|
||||
{
|
||||
cacheData.Remove(data);
|
||||
}
|
||||
cacheData.Add(stateProvince);
|
||||
await SetCacheAsync($"{CacheKeys.StateProvince}.{stateProvince.CountryId}", cacheData);
|
||||
cacheData.Add(area);
|
||||
await SetCacheAsync($"{CacheKeys.StateProvince}.{area.CountryId}", cacheData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Atomx.Data
|
||||
public DbSet<AppVersion> AppVersions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 市区数据
|
||||
/// 州省/市区数据
|
||||
/// </summary>
|
||||
public DbSet<Area> Areas { get; set; }
|
||||
|
||||
@@ -141,11 +141,6 @@ namespace Atomx.Data
|
||||
/// </summary>
|
||||
public DbSet<SpecificationAttributeOption> SpecificationAttributeOptions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 州省份数据
|
||||
/// </summary>
|
||||
public DbSet<StateProvince> StateProvinces { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 刷新Tokens
|
||||
/// </summary>
|
||||
|
||||
@@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
namespace Atomx.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(DataContext))]
|
||||
[Migration("20260104093702_0.1")]
|
||||
[Migration("20260104144630_0.1")]
|
||||
partial class _01
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@@ -239,6 +239,10 @@ namespace Atomx.Data.Migrations
|
||||
b.Property<long>("Id")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Abbreviation")
|
||||
.IsRequired()
|
||||
.HasColumnType("varchar(32)");
|
||||
|
||||
b.Property<bool>("AllowShipping")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
@@ -1382,37 +1386,6 @@ namespace Atomx.Data.Migrations
|
||||
b.ToTable("SpecificationAttributeOptions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Atomx.Common.Entities.StateProvince", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Abbreviation")
|
||||
.IsRequired()
|
||||
.HasColumnType("varchar(32)");
|
||||
|
||||
b.Property<long>("CountryId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("DisplayOrder")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("Enabled")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("Initial")
|
||||
.IsRequired()
|
||||
.HasColumnType("varchar(1)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("varchar(256)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("StateProvinces");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Atomx.Common.Entities.Tag", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
@@ -106,6 +106,7 @@ namespace Atomx.Data.Migrations
|
||||
ParentId = table.Column<long>(type: "bigint", nullable: false),
|
||||
Name = table.Column<string>(type: "varchar(256)", nullable: false),
|
||||
Initial = table.Column<string>(type: "varchar(1)", nullable: false),
|
||||
Abbreviation = table.Column<string>(type: "varchar(32)", nullable: false),
|
||||
Depth = table.Column<int>(type: "integer", nullable: false),
|
||||
Path = table.Column<string>(type: "varchar(100)", nullable: false),
|
||||
AllowShipping = table.Column<bool>(type: "boolean", nullable: false),
|
||||
@@ -654,23 +655,6 @@ namespace Atomx.Data.Migrations
|
||||
table.PrimaryKey("PK_SpecificationAttributes", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "StateProvinces",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false),
|
||||
Name = table.Column<string>(type: "varchar(256)", nullable: false),
|
||||
CountryId = table.Column<long>(type: "bigint", nullable: false),
|
||||
Initial = table.Column<string>(type: "varchar(1)", nullable: false),
|
||||
Abbreviation = table.Column<string>(type: "varchar(32)", nullable: false),
|
||||
Enabled = table.Column<bool>(type: "boolean", nullable: false),
|
||||
DisplayOrder = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_StateProvinces", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Tags",
|
||||
columns: table => new
|
||||
@@ -825,9 +809,6 @@ namespace Atomx.Data.Migrations
|
||||
migrationBuilder.DropTable(
|
||||
name: "SpecificationAttributes");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "StateProvinces");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Tags");
|
||||
|
||||
@@ -236,6 +236,10 @@ namespace Atomx.Data.Migrations
|
||||
b.Property<long>("Id")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Abbreviation")
|
||||
.IsRequired()
|
||||
.HasColumnType("varchar(32)");
|
||||
|
||||
b.Property<bool>("AllowShipping")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
@@ -1379,37 +1383,6 @@ namespace Atomx.Data.Migrations
|
||||
b.ToTable("SpecificationAttributeOptions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Atomx.Common.Entities.StateProvince", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Abbreviation")
|
||||
.IsRequired()
|
||||
.HasColumnType("varchar(32)");
|
||||
|
||||
b.Property<long>("CountryId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("DisplayOrder")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("Enabled")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("Initial")
|
||||
.IsRequired()
|
||||
.HasColumnType("varchar(1)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("varchar(256)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("StateProvinces");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Atomx.Common.Entities.Tag", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
|
||||
Reference in New Issue
Block a user