chore
This commit is contained in:
@@ -47,21 +47,21 @@ namespace Atomx.Data.CacheServices
|
||||
/// </summary>
|
||||
/// <param name="area"></param>
|
||||
/// <returns></returns>
|
||||
Task ResetArea(Area area);
|
||||
Task UpdateArea(Area area);
|
||||
|
||||
/// <summary>
|
||||
/// 更新调整州省缓存数据
|
||||
/// </summary>
|
||||
/// <param name="stateProvince"></param>
|
||||
/// <returns></returns>
|
||||
Task ResetStateProvince(StateProvince stateProvince);
|
||||
Task UpdateStateProvince(StateProvince stateProvince);
|
||||
|
||||
/// <summary>
|
||||
/// 更新调整国家缓存数据
|
||||
/// </summary>
|
||||
/// <param name="country"></param>
|
||||
/// <returns></returns>
|
||||
Task ResetCountry(Country country);
|
||||
Task UpdateCountry(Country country);
|
||||
|
||||
/// <summary>
|
||||
/// 获取国家-省份-城市树形数据
|
||||
@@ -78,8 +78,8 @@ namespace Atomx.Data.CacheServices
|
||||
var cacheData = await GetCacheAsync<List<KeyValueTree>>($"{CacheKeys.CountryTree}{countryId}");
|
||||
if (cacheData == null || reloadData)
|
||||
{
|
||||
var states = await GetStateProvinces(countryId);
|
||||
var cities = await GetAreas(countryId);
|
||||
var states = await GetStateProvinces(countryId, true);
|
||||
var cities = await GetAreas(countryId, true);
|
||||
|
||||
var tree = new List<KeyValueTree>();
|
||||
|
||||
@@ -87,13 +87,24 @@ namespace Atomx.Data.CacheServices
|
||||
{
|
||||
var item = new KeyValueTree
|
||||
{
|
||||
Label = state.Id.ToString(),
|
||||
Value = state.Name,
|
||||
Children = new List<KeyValueTree>()
|
||||
Label = state.Name,
|
||||
Value = state.Id.ToString()
|
||||
};
|
||||
|
||||
item.Children = BuildAreaTree(state.Id, cities, new List<KeyValueTree>());
|
||||
var citysInState = cities.Where(p => p.StateProvinceId == state.Id).ToList();
|
||||
foreach (var city in citysInState)
|
||||
{
|
||||
var cityItem = new KeyValueTree
|
||||
{
|
||||
Label = state.Name,
|
||||
Value = state.Id.ToString()
|
||||
};
|
||||
|
||||
cityItem.Children = BuildAreaTree(city.Id, cities, new List<KeyValueTree>());
|
||||
item.Children.Add(cityItem);
|
||||
}
|
||||
tree.Add(item);
|
||||
|
||||
}
|
||||
|
||||
await SetCacheAsync($"{CacheKeys.CountryTree}{countryId}", tree);
|
||||
@@ -188,7 +199,7 @@ namespace Atomx.Data.CacheServices
|
||||
return cacheData;
|
||||
}
|
||||
|
||||
public async Task ResetArea(Area area)
|
||||
public async Task UpdateArea(Area area)
|
||||
{
|
||||
var cacheData = await GetAreas(area.CountryId);
|
||||
var data = cacheData.Where(p => p.Id == area.Id).SingleOrDefault();
|
||||
@@ -207,7 +218,7 @@ namespace Atomx.Data.CacheServices
|
||||
/// </summary>
|
||||
/// <param name="stateProvince"></param>
|
||||
/// <returns></returns>
|
||||
public async Task ResetStateProvince(StateProvince stateProvince)
|
||||
public async Task UpdateStateProvince(StateProvince stateProvince)
|
||||
{
|
||||
var cacheData = await GetStateProvinces(stateProvince.CountryId);
|
||||
var data = cacheData.Where(p => p.Id == stateProvince.Id).SingleOrDefault();
|
||||
@@ -224,7 +235,7 @@ namespace Atomx.Data.CacheServices
|
||||
/// </summary>
|
||||
/// <param name="country"></param>
|
||||
/// <returns></returns>
|
||||
public async Task ResetCountry(Country country)
|
||||
public async Task UpdateCountry(Country country)
|
||||
{
|
||||
var cacheData = await GetCountries();
|
||||
var data = cacheData.Where(p => p.Id == country.Id).SingleOrDefault();
|
||||
@@ -243,9 +254,8 @@ namespace Atomx.Data.CacheServices
|
||||
{
|
||||
var item = new KeyValueTree
|
||||
{
|
||||
Label = area.Id.ToString(),
|
||||
Value = area.Name,
|
||||
Children = new List<KeyValueTree>()
|
||||
Label = area.Name,
|
||||
Value = area.Id.ToString()
|
||||
};
|
||||
var childs = areas.Where(p => p.ParentId == area.Id).ToList();
|
||||
if (childs.Count > 0)
|
||||
|
||||
Reference in New Issue
Block a user