chore
This commit is contained in:
@@ -152,7 +152,7 @@
|
|||||||
async void LoadData()
|
async void LoadData()
|
||||||
{
|
{
|
||||||
pageLoading = true;
|
pageLoading = true;
|
||||||
var url = $"/api/stateprovince/detail?id={Id}";
|
var url = $"/api/area/detail?id={Id}";
|
||||||
var apiResult = await HttpService.Get<ApiResult<AreaLocalizedModel>>(url);
|
var apiResult = await HttpService.Get<ApiResult<AreaLocalizedModel>>(url);
|
||||||
if (apiResult.Success)
|
if (apiResult.Success)
|
||||||
{
|
{
|
||||||
@@ -185,6 +185,8 @@
|
|||||||
|
|
||||||
void OnCitiesChange(CascaderNode[] selectedNodes)
|
void OnCitiesChange(CascaderNode[] selectedNodes)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine($"value: {cities} selected: {string.Join(",", selectedNodes.Select(x => x.Value))}");
|
||||||
|
|
||||||
model.StateProvinceId = long.Parse(selectedNodes.First().Value.ToString() ?? "0");
|
model.StateProvinceId = long.Parse(selectedNodes.First().Value.ToString() ?? "0");
|
||||||
model.ParentId = long.Parse(selectedNodes.Last().Value.ToString() ?? "0");
|
model.ParentId = long.Parse(selectedNodes.Last().Value.ToString() ?? "0");
|
||||||
if (model.StateProvinceId == model.ParentId)
|
if (model.StateProvinceId == model.ParentId)
|
||||||
@@ -198,7 +200,7 @@
|
|||||||
if (editform.Validate())
|
if (editform.Validate())
|
||||||
{
|
{
|
||||||
saving = true;
|
saving = true;
|
||||||
var url = $"api/stateprovince/save";
|
var url = $"api/area/save";
|
||||||
var result = new ApiResult<string>();
|
var result = new ApiResult<string>();
|
||||||
result = await HttpService.Post<ApiResult<string>>(url, model);
|
result = await HttpService.Post<ApiResult<string>>(url, model);
|
||||||
|
|
||||||
@@ -207,7 +209,7 @@
|
|||||||
{
|
{
|
||||||
saving = false;
|
saving = false;
|
||||||
await ModalService.InfoAsync(new ConfirmOptions() { Title = "提示", Content = "数据提交成功!" });
|
await ModalService.InfoAsync(new ConfirmOptions() { Title = "提示", Content = "数据提交成功!" });
|
||||||
Navigation.NavigateTo($"/stateprovince/list/{CountryId}");
|
Navigation.NavigateTo($"/area/list/{CountryId}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -128,7 +128,7 @@
|
|||||||
var uri = new Uri(Navigation.Uri);
|
var uri = new Uri(Navigation.Uri);
|
||||||
var query = uri.Query;
|
var query = uri.Query;
|
||||||
search.Name = query.GetQueryString("Name");
|
search.Name = query.GetQueryString("Name");
|
||||||
search.StateProvinceId = query.GetQueryString("StateProvinceId").ToLong();
|
search.StateProvinceId = StateProvinceId;
|
||||||
search.CountryId = CountryId;
|
search.CountryId = CountryId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,7 +220,7 @@
|
|||||||
|
|
||||||
void HandleEdit(Area model)
|
void HandleEdit(Area model)
|
||||||
{
|
{
|
||||||
Navigation.NavigateTo($"/area/edit/{model.Id}");
|
Navigation.NavigateTo($"/area/edit/{model.CountryId}/{model.StateProvinceId}/{model.Id}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using Atomx.Admin.Services;
|
|||||||
using Atomx.Common.Constants;
|
using Atomx.Common.Constants;
|
||||||
using Atomx.Common.Entities;
|
using Atomx.Common.Entities;
|
||||||
using Atomx.Common.Models;
|
using Atomx.Common.Models;
|
||||||
|
using Atomx.Core.Jos;
|
||||||
using Atomx.Data;
|
using Atomx.Data;
|
||||||
using Atomx.Data.CacheServices;
|
using Atomx.Data.CacheServices;
|
||||||
using Atomx.Data.Services;
|
using Atomx.Data.Services;
|
||||||
@@ -29,6 +30,7 @@ namespace Atomx.Admin.Controllers
|
|||||||
private readonly IIdentityService _identityService;
|
private readonly IIdentityService _identityService;
|
||||||
private readonly IMapper _mapper;
|
private readonly IMapper _mapper;
|
||||||
private readonly ICacheService _cacheService;
|
private readonly ICacheService _cacheService;
|
||||||
|
private readonly IBackgroundJobService _backgroundService;
|
||||||
readonly IValidator<AreaModel> _validator;
|
readonly IValidator<AreaModel> _validator;
|
||||||
readonly IStringLocalizer<AreaController> _localizer;
|
readonly IStringLocalizer<AreaController> _localizer;
|
||||||
|
|
||||||
@@ -40,9 +42,12 @@ namespace Atomx.Admin.Controllers
|
|||||||
/// <param name="identityService"></param>
|
/// <param name="identityService"></param>
|
||||||
/// <param name="dbContext"></param>
|
/// <param name="dbContext"></param>
|
||||||
/// <param name="mapper"></param>
|
/// <param name="mapper"></param>
|
||||||
/// <param name="jwtSettings"></param>
|
|
||||||
/// <param name="cacheService"></param>
|
/// <param name="cacheService"></param>
|
||||||
public AreaController(ILogger<AreaController> logger, IIdCreatorService idCreator, IIdentityService identityService, DataContext dbContext, IMapper mapper, ICacheService cacheService, IValidator<AreaModel> validator, IStringLocalizer<AreaController> localizer)
|
/// <param name="backgroundJobService"></param>
|
||||||
|
/// <param name="validator"></param>
|
||||||
|
/// <param name="localizer"></param>
|
||||||
|
public AreaController(ILogger<AreaController> logger, IIdCreatorService idCreator, IIdentityService identityService, DataContext dbContext, IMapper mapper,
|
||||||
|
ICacheService cacheService, IBackgroundJobService backgroundJobService, IValidator<AreaModel> validator, IStringLocalizer<AreaController> localizer)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_idCreator = idCreator;
|
_idCreator = idCreator;
|
||||||
@@ -50,6 +55,7 @@ namespace Atomx.Admin.Controllers
|
|||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
_mapper = mapper;
|
_mapper = mapper;
|
||||||
_cacheService = cacheService;
|
_cacheService = cacheService;
|
||||||
|
_backgroundService = backgroundJobService;
|
||||||
_validator = validator;
|
_validator = validator;
|
||||||
_localizer = localizer;
|
_localizer = localizer;
|
||||||
}
|
}
|
||||||
@@ -112,7 +118,7 @@ namespace Atomx.Admin.Controllers
|
|||||||
countries = _dbContext.Countries.Where(p => countryIds.Contains(p.Id)).ToList();
|
countries = _dbContext.Countries.Where(p => countryIds.Contains(p.Id)).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(search.StateProvinceId > 0)
|
if (search.StateProvinceId > 0)
|
||||||
{
|
{
|
||||||
var state = _dbContext.StateProvinces.SingleOrDefault(p => p.Id == search.StateProvinceId);
|
var state = _dbContext.StateProvinces.SingleOrDefault(p => p.Id == search.StateProvinceId);
|
||||||
if (state != null)
|
if (state != null)
|
||||||
@@ -213,6 +219,8 @@ namespace Atomx.Admin.Controllers
|
|||||||
}
|
}
|
||||||
if (model.Id > 0)
|
if (model.Id > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
data = _dbContext.Areas.SingleOrDefault(p => p.Id == model.Id);
|
data = _dbContext.Areas.SingleOrDefault(p => p.Id == model.Id);
|
||||||
if (data == null)
|
if (data == null)
|
||||||
{
|
{
|
||||||
@@ -221,6 +229,18 @@ namespace Atomx.Admin.Controllers
|
|||||||
|
|
||||||
data = _mapper.Map(model, data);
|
data = _mapper.Map(model, data);
|
||||||
|
|
||||||
|
var parent = _dbContext.Categories.Where(p => p.Id == model.ParentId).SingleOrDefault();
|
||||||
|
if (parent == null)
|
||||||
|
{
|
||||||
|
data.Depth = 0;
|
||||||
|
data.Path = model.Id.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data.Depth = parent.Depth + 1;
|
||||||
|
data.Path = $"{parent.Path},{data.Id}";
|
||||||
|
}
|
||||||
|
|
||||||
_dbContext.SaveChanges();
|
_dbContext.SaveChanges();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -229,10 +249,25 @@ namespace Atomx.Admin.Controllers
|
|||||||
data = _mapper.Map<Area>(model);
|
data = _mapper.Map<Area>(model);
|
||||||
data.Id = _idCreator.CreateId();
|
data.Id = _idCreator.CreateId();
|
||||||
|
|
||||||
|
var parent = _dbContext.Categories.Where(p => p.Id == data.ParentId).SingleOrDefault();
|
||||||
|
if (parent == null)
|
||||||
|
{
|
||||||
|
data.Depth = 0;
|
||||||
|
data.Path = data.Id.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data.Depth = parent.Depth + 1;
|
||||||
|
data.Path = $"{parent.Path},{data.Id}";
|
||||||
|
}
|
||||||
|
|
||||||
_dbContext.Areas.Add(data);
|
_dbContext.Areas.Add(data);
|
||||||
_dbContext.SaveChanges();
|
_dbContext.SaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_backgroundService.ResetStateProvinceAndAreaTree(model.CountryId);
|
||||||
|
|
||||||
|
|
||||||
return new JsonResult(new ApiResult<string>().IsSuccess("操作成功"));
|
return new JsonResult(new ApiResult<string>().IsSuccess("操作成功"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using Atomx.Admin.Services;
|
|||||||
using Atomx.Common.Constants;
|
using Atomx.Common.Constants;
|
||||||
using Atomx.Common.Entities;
|
using Atomx.Common.Entities;
|
||||||
using Atomx.Common.Models;
|
using Atomx.Common.Models;
|
||||||
|
using Atomx.Core.Jos;
|
||||||
using Atomx.Data;
|
using Atomx.Data;
|
||||||
using Atomx.Data.CacheServices;
|
using Atomx.Data.CacheServices;
|
||||||
using Atomx.Data.Services;
|
using Atomx.Data.Services;
|
||||||
@@ -26,6 +27,7 @@ namespace Atomx.Admin.Controllers
|
|||||||
private readonly IIdentityService _identityService;
|
private readonly IIdentityService _identityService;
|
||||||
private readonly IMapper _mapper;
|
private readonly IMapper _mapper;
|
||||||
private readonly ICacheService _cacheService;
|
private readonly ICacheService _cacheService;
|
||||||
|
private readonly IBackgroundJobService _backgroundService;
|
||||||
readonly IValidator<StateProvinceModel> _validator;
|
readonly IValidator<StateProvinceModel> _validator;
|
||||||
readonly IStringLocalizer<StateProvinceController> _localizer;
|
readonly IStringLocalizer<StateProvinceController> _localizer;
|
||||||
|
|
||||||
@@ -39,7 +41,8 @@ namespace Atomx.Admin.Controllers
|
|||||||
/// <param name="mapper"></param>
|
/// <param name="mapper"></param>
|
||||||
/// <param name="jwtSettings"></param>
|
/// <param name="jwtSettings"></param>
|
||||||
/// <param name="cacheService"></param>
|
/// <param name="cacheService"></param>
|
||||||
public StateProvinceController(ILogger<StateProvinceController> logger, IIdCreatorService idCreator, IIdentityService identityService, DataContext dbContext, IMapper mapper, ICacheService cacheService, IValidator<StateProvinceModel> validator, IStringLocalizer<StateProvinceController> localizer)
|
public StateProvinceController(ILogger<StateProvinceController> logger, IIdCreatorService idCreator, IIdentityService identityService, DataContext dbContext, IMapper mapper,
|
||||||
|
ICacheService cacheService, IBackgroundJobService backgroundJobService, IValidator<StateProvinceModel> validator, IStringLocalizer<StateProvinceController> localizer)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_idCreator = idCreator;
|
_idCreator = idCreator;
|
||||||
@@ -47,6 +50,7 @@ namespace Atomx.Admin.Controllers
|
|||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
_mapper = mapper;
|
_mapper = mapper;
|
||||||
_cacheService = cacheService;
|
_cacheService = cacheService;
|
||||||
|
_backgroundService = backgroundJobService;
|
||||||
_validator = validator;
|
_validator = validator;
|
||||||
_localizer = localizer;
|
_localizer = localizer;
|
||||||
}
|
}
|
||||||
@@ -200,7 +204,7 @@ namespace Atomx.Admin.Controllers
|
|||||||
data = _mapper.Map(model, data);
|
data = _mapper.Map(model, data);
|
||||||
|
|
||||||
_dbContext.SaveChanges();
|
_dbContext.SaveChanges();
|
||||||
|
_backgroundService.ResetStateProvinceAndAreaTree(data.CountryId);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -44,6 +44,17 @@ namespace Atomx.Common.Entities
|
|||||||
[Column(TypeName = "varchar(1)")]
|
[Column(TypeName = "varchar(1)")]
|
||||||
public string Initial { get; set; } = string.Empty;
|
public string Initial { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 地区深度
|
||||||
|
/// </summary>
|
||||||
|
public int Depth { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 层级路径
|
||||||
|
/// </summary>
|
||||||
|
[Column(TypeName = "varchar(100)")]
|
||||||
|
public string Path { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否允许配送
|
/// 是否允许配送
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
54
Atomx.Core/Jos/ResetCacheJob.cs
Normal file
54
Atomx.Core/Jos/ResetCacheJob.cs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
using Atomx.Data;
|
||||||
|
using Atomx.Data.CacheServices;
|
||||||
|
using Hangfire;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace Atomx.Core.Jos
|
||||||
|
{
|
||||||
|
public class ResetCacheJob
|
||||||
|
{
|
||||||
|
readonly ILogger<ResetCacheJob> _logger;
|
||||||
|
readonly DataContext _dbContext;
|
||||||
|
readonly ICacheService _cacheService;
|
||||||
|
public ResetCacheJob(ILogger<ResetCacheJob> logger, DataContext dataContext, ICacheService cacheService)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_dbContext = dataContext;
|
||||||
|
_cacheService = cacheService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 如果任务失败,重试 3 次,超过后删除任务,60 秒内不允许并发执行
|
||||||
|
/// </summary>
|
||||||
|
[AutomaticRetry(Attempts = 3, OnAttemptsExceeded = AttemptsExceededAction.Delete)]
|
||||||
|
[DisableConcurrentExecution(60)]
|
||||||
|
public async Task ResetStateProvinceAndAreaTree(long countryId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _cacheService.GetAreaTree(countryId, true);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error resetting cache for countryId: {CountryId}", countryId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 如果任务失败,重试 3 次,超过后删除任务,60 秒内不允许并发执行
|
||||||
|
/// </summary>
|
||||||
|
[AutomaticRetry(Attempts = 3, OnAttemptsExceeded = AttemptsExceededAction.Delete)]
|
||||||
|
[DisableConcurrentExecution(60)]
|
||||||
|
public async Task ResetCountry()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _cacheService.GetCountries(true);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error resetting country cache");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
using Hangfire;
|
using Hangfire;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace Atomx.Core.Jos
|
namespace Atomx.Core.Jos
|
||||||
{
|
{
|
||||||
@@ -24,6 +26,13 @@ namespace Atomx.Core.Jos
|
|||||||
|
|
||||||
|
|
||||||
string SendSMSVerificationCode(string phoneNumber, string code, TimeSpan validDuration);
|
string SendSMSVerificationCode(string phoneNumber, string code, TimeSpan validDuration);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新调整区域树缓存数据,会更新州省缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="countryId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
string ResetStateProvinceAndAreaTree(long countryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial class BackgroundJobService : IBackgroundJobService
|
public partial class BackgroundJobService : IBackgroundJobService
|
||||||
@@ -68,5 +77,16 @@ namespace Atomx.Core.Jos
|
|||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新调整区域树缓存数据,会更新州省缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="countryId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string ResetStateProvinceAndAreaTree(long countryId)
|
||||||
|
{
|
||||||
|
var jobId = _backgroundJobClient.Enqueue<ResetCacheJob>(job => job.ResetStateProvinceAndAreaTree(countryId));
|
||||||
|
return jobId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,21 +47,21 @@ namespace Atomx.Data.CacheServices
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="area"></param>
|
/// <param name="area"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task ResetArea(Area area);
|
Task UpdateArea(Area area);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新调整州省缓存数据
|
/// 更新调整州省缓存数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="stateProvince"></param>
|
/// <param name="stateProvince"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task ResetStateProvince(StateProvince stateProvince);
|
Task UpdateStateProvince(StateProvince stateProvince);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新调整国家缓存数据
|
/// 更新调整国家缓存数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="country"></param>
|
/// <param name="country"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task ResetCountry(Country country);
|
Task UpdateCountry(Country country);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取国家-省份-城市树形数据
|
/// 获取国家-省份-城市树形数据
|
||||||
@@ -78,8 +78,8 @@ namespace Atomx.Data.CacheServices
|
|||||||
var cacheData = await GetCacheAsync<List<KeyValueTree>>($"{CacheKeys.CountryTree}{countryId}");
|
var cacheData = await GetCacheAsync<List<KeyValueTree>>($"{CacheKeys.CountryTree}{countryId}");
|
||||||
if (cacheData == null || reloadData)
|
if (cacheData == null || reloadData)
|
||||||
{
|
{
|
||||||
var states = await GetStateProvinces(countryId);
|
var states = await GetStateProvinces(countryId, true);
|
||||||
var cities = await GetAreas(countryId);
|
var cities = await GetAreas(countryId, true);
|
||||||
|
|
||||||
var tree = new List<KeyValueTree>();
|
var tree = new List<KeyValueTree>();
|
||||||
|
|
||||||
@@ -87,13 +87,24 @@ namespace Atomx.Data.CacheServices
|
|||||||
{
|
{
|
||||||
var item = new KeyValueTree
|
var item = new KeyValueTree
|
||||||
{
|
{
|
||||||
Label = state.Id.ToString(),
|
Label = state.Name,
|
||||||
Value = state.Name,
|
Value = state.Id.ToString()
|
||||||
Children = new List<KeyValueTree>()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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);
|
tree.Add(item);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await SetCacheAsync($"{CacheKeys.CountryTree}{countryId}", tree);
|
await SetCacheAsync($"{CacheKeys.CountryTree}{countryId}", tree);
|
||||||
@@ -188,7 +199,7 @@ namespace Atomx.Data.CacheServices
|
|||||||
return cacheData;
|
return cacheData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task ResetArea(Area area)
|
public async Task UpdateArea(Area area)
|
||||||
{
|
{
|
||||||
var cacheData = await GetAreas(area.CountryId);
|
var cacheData = await GetAreas(area.CountryId);
|
||||||
var data = cacheData.Where(p => p.Id == area.Id).SingleOrDefault();
|
var data = cacheData.Where(p => p.Id == area.Id).SingleOrDefault();
|
||||||
@@ -207,7 +218,7 @@ namespace Atomx.Data.CacheServices
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="stateProvince"></param>
|
/// <param name="stateProvince"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task ResetStateProvince(StateProvince stateProvince)
|
public async Task UpdateStateProvince(StateProvince stateProvince)
|
||||||
{
|
{
|
||||||
var cacheData = await GetStateProvinces(stateProvince.CountryId);
|
var cacheData = await GetStateProvinces(stateProvince.CountryId);
|
||||||
var data = cacheData.Where(p => p.Id == stateProvince.Id).SingleOrDefault();
|
var data = cacheData.Where(p => p.Id == stateProvince.Id).SingleOrDefault();
|
||||||
@@ -224,7 +235,7 @@ namespace Atomx.Data.CacheServices
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="country"></param>
|
/// <param name="country"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task ResetCountry(Country country)
|
public async Task UpdateCountry(Country country)
|
||||||
{
|
{
|
||||||
var cacheData = await GetCountries();
|
var cacheData = await GetCountries();
|
||||||
var data = cacheData.Where(p => p.Id == country.Id).SingleOrDefault();
|
var data = cacheData.Where(p => p.Id == country.Id).SingleOrDefault();
|
||||||
@@ -243,9 +254,8 @@ namespace Atomx.Data.CacheServices
|
|||||||
{
|
{
|
||||||
var item = new KeyValueTree
|
var item = new KeyValueTree
|
||||||
{
|
{
|
||||||
Label = area.Id.ToString(),
|
Label = area.Name,
|
||||||
Value = area.Name,
|
Value = area.Id.ToString()
|
||||||
Children = new List<KeyValueTree>()
|
|
||||||
};
|
};
|
||||||
var childs = areas.Where(p => p.ParentId == area.Id).ToList();
|
var childs = areas.Where(p => p.ParentId == area.Id).ToList();
|
||||||
if (childs.Count > 0)
|
if (childs.Count > 0)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
namespace Atomx.Data.Migrations
|
namespace Atomx.Data.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(DataContext))]
|
[DbContext(typeof(DataContext))]
|
||||||
[Migration("20251224030208_0.1")]
|
[Migration("20260104093702_0.1")]
|
||||||
partial class _01
|
partial class _01
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -245,6 +245,9 @@ namespace Atomx.Data.Migrations
|
|||||||
b.Property<long>("CountryId")
|
b.Property<long>("CountryId")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<int>("Depth")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<int>("DisplayOrder")
|
b.Property<int>("DisplayOrder")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
@@ -262,6 +265,10 @@ namespace Atomx.Data.Migrations
|
|||||||
b.Property<long>("ParentId")
|
b.Property<long>("ParentId")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("Path")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("varchar(100)");
|
||||||
|
|
||||||
b.Property<long>("StateProvinceId")
|
b.Property<long>("StateProvinceId")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
@@ -106,6 +106,8 @@ namespace Atomx.Data.Migrations
|
|||||||
ParentId = table.Column<long>(type: "bigint", nullable: false),
|
ParentId = table.Column<long>(type: "bigint", nullable: false),
|
||||||
Name = table.Column<string>(type: "varchar(256)", nullable: false),
|
Name = table.Column<string>(type: "varchar(256)", nullable: false),
|
||||||
Initial = table.Column<string>(type: "varchar(1)", nullable: false),
|
Initial = table.Column<string>(type: "varchar(1)", 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),
|
AllowShipping = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
Enabled = table.Column<bool>(type: "boolean", nullable: false),
|
Enabled = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
DisplayOrder = table.Column<int>(type: "integer", nullable: false)
|
DisplayOrder = table.Column<int>(type: "integer", nullable: false)
|
||||||
@@ -242,6 +242,9 @@ namespace Atomx.Data.Migrations
|
|||||||
b.Property<long>("CountryId")
|
b.Property<long>("CountryId")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<int>("Depth")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<int>("DisplayOrder")
|
b.Property<int>("DisplayOrder")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
@@ -259,6 +262,10 @@ namespace Atomx.Data.Migrations
|
|||||||
b.Property<long>("ParentId")
|
b.Property<long>("ParentId")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("Path")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("varchar(100)");
|
||||||
|
|
||||||
b.Property<long>("StateProvinceId")
|
b.Property<long>("StateProvinceId")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user