chore
This commit is contained in:
@@ -152,7 +152,7 @@
|
||||
async void LoadData()
|
||||
{
|
||||
pageLoading = true;
|
||||
var url = $"/api/stateprovince/detail?id={Id}";
|
||||
var url = $"/api/area/detail?id={Id}";
|
||||
var apiResult = await HttpService.Get<ApiResult<AreaLocalizedModel>>(url);
|
||||
if (apiResult.Success)
|
||||
{
|
||||
@@ -185,6 +185,8 @@
|
||||
|
||||
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.ParentId = long.Parse(selectedNodes.Last().Value.ToString() ?? "0");
|
||||
if (model.StateProvinceId == model.ParentId)
|
||||
@@ -198,7 +200,7 @@
|
||||
if (editform.Validate())
|
||||
{
|
||||
saving = true;
|
||||
var url = $"api/stateprovince/save";
|
||||
var url = $"api/area/save";
|
||||
var result = new ApiResult<string>();
|
||||
result = await HttpService.Post<ApiResult<string>>(url, model);
|
||||
|
||||
@@ -207,7 +209,7 @@
|
||||
{
|
||||
saving = false;
|
||||
await ModalService.InfoAsync(new ConfirmOptions() { Title = "提示", Content = "数据提交成功!" });
|
||||
Navigation.NavigateTo($"/stateprovince/list/{CountryId}");
|
||||
Navigation.NavigateTo($"/area/list/{CountryId}");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -128,7 +128,7 @@
|
||||
var uri = new Uri(Navigation.Uri);
|
||||
var query = uri.Query;
|
||||
search.Name = query.GetQueryString("Name");
|
||||
search.StateProvinceId = query.GetQueryString("StateProvinceId").ToLong();
|
||||
search.StateProvinceId = StateProvinceId;
|
||||
search.CountryId = CountryId;
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@
|
||||
|
||||
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.Entities;
|
||||
using Atomx.Common.Models;
|
||||
using Atomx.Core.Jos;
|
||||
using Atomx.Data;
|
||||
using Atomx.Data.CacheServices;
|
||||
using Atomx.Data.Services;
|
||||
@@ -29,6 +30,7 @@ namespace Atomx.Admin.Controllers
|
||||
private readonly IIdentityService _identityService;
|
||||
private readonly IMapper _mapper;
|
||||
private readonly ICacheService _cacheService;
|
||||
private readonly IBackgroundJobService _backgroundService;
|
||||
readonly IValidator<AreaModel> _validator;
|
||||
readonly IStringLocalizer<AreaController> _localizer;
|
||||
|
||||
@@ -40,9 +42,12 @@ namespace Atomx.Admin.Controllers
|
||||
/// <param name="identityService"></param>
|
||||
/// <param name="dbContext"></param>
|
||||
/// <param name="mapper"></param>
|
||||
/// <param name="jwtSettings"></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;
|
||||
_idCreator = idCreator;
|
||||
@@ -50,6 +55,7 @@ namespace Atomx.Admin.Controllers
|
||||
_dbContext = dbContext;
|
||||
_mapper = mapper;
|
||||
_cacheService = cacheService;
|
||||
_backgroundService = backgroundJobService;
|
||||
_validator = validator;
|
||||
_localizer = localizer;
|
||||
}
|
||||
@@ -112,7 +118,7 @@ namespace Atomx.Admin.Controllers
|
||||
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);
|
||||
if (state != null)
|
||||
@@ -213,6 +219,8 @@ namespace Atomx.Admin.Controllers
|
||||
}
|
||||
if (model.Id > 0)
|
||||
{
|
||||
|
||||
|
||||
data = _dbContext.Areas.SingleOrDefault(p => p.Id == model.Id);
|
||||
if (data == null)
|
||||
{
|
||||
@@ -221,6 +229,18 @@ namespace Atomx.Admin.Controllers
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
@@ -229,10 +249,25 @@ namespace Atomx.Admin.Controllers
|
||||
data = _mapper.Map<Area>(model);
|
||||
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.SaveChanges();
|
||||
}
|
||||
|
||||
_backgroundService.ResetStateProvinceAndAreaTree(model.CountryId);
|
||||
|
||||
|
||||
return new JsonResult(new ApiResult<string>().IsSuccess("操作成功"));
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using Atomx.Admin.Services;
|
||||
using Atomx.Common.Constants;
|
||||
using Atomx.Common.Entities;
|
||||
using Atomx.Common.Models;
|
||||
using Atomx.Core.Jos;
|
||||
using Atomx.Data;
|
||||
using Atomx.Data.CacheServices;
|
||||
using Atomx.Data.Services;
|
||||
@@ -26,6 +27,7 @@ namespace Atomx.Admin.Controllers
|
||||
private readonly IIdentityService _identityService;
|
||||
private readonly IMapper _mapper;
|
||||
private readonly ICacheService _cacheService;
|
||||
private readonly IBackgroundJobService _backgroundService;
|
||||
readonly IValidator<StateProvinceModel> _validator;
|
||||
readonly IStringLocalizer<StateProvinceController> _localizer;
|
||||
|
||||
@@ -39,7 +41,8 @@ namespace Atomx.Admin.Controllers
|
||||
/// <param name="mapper"></param>
|
||||
/// <param name="jwtSettings"></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;
|
||||
_idCreator = idCreator;
|
||||
@@ -47,6 +50,7 @@ namespace Atomx.Admin.Controllers
|
||||
_dbContext = dbContext;
|
||||
_mapper = mapper;
|
||||
_cacheService = cacheService;
|
||||
_backgroundService = backgroundJobService;
|
||||
_validator = validator;
|
||||
_localizer = localizer;
|
||||
}
|
||||
@@ -200,7 +204,7 @@ namespace Atomx.Admin.Controllers
|
||||
data = _mapper.Map(model, data);
|
||||
|
||||
_dbContext.SaveChanges();
|
||||
|
||||
_backgroundService.ResetStateProvinceAndAreaTree(data.CountryId);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user