chore
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Atomx.Admin.Client.Models
|
namespace Atomx.Admin.Client.Models
|
||||||
{
|
{
|
||||||
public class StateProvinceModel: StateProvince
|
public class StateProvinceModel: Area
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,7 +111,7 @@
|
|||||||
|
|
||||||
async Task LoadStateProvinceAndCities()
|
async Task LoadStateProvinceAndCities()
|
||||||
{
|
{
|
||||||
var url = $"/api/stateprovince/tree/{CountryId}";
|
var url = $"/api/area/tree/{CountryId}";
|
||||||
var apiResult = await HttpService.Get<ApiResult<List<KeyValueTree>>>(url);
|
var apiResult = await HttpService.Get<ApiResult<List<KeyValueTree>>>(url);
|
||||||
if (apiResult.Success)
|
if (apiResult.Success)
|
||||||
{
|
{
|
||||||
@@ -164,14 +164,14 @@
|
|||||||
{
|
{
|
||||||
area = apiResult.Data;
|
area = apiResult.Data;
|
||||||
model = apiResult.Data.Adapt<AreaModel>();
|
model = apiResult.Data.Adapt<AreaModel>();
|
||||||
if (model.ParentId > 0)
|
// if (model.ParentId > 0)
|
||||||
{
|
// {
|
||||||
cities = $"{model.StateProvinceId},{model.ParentId}";
|
// cities = $"{model.StateProvinceId},{model.ParentId}";
|
||||||
}
|
// }
|
||||||
else if (model.StateProvinceId > 0)
|
// else if (model.StateProvinceId > 0)
|
||||||
{
|
// {
|
||||||
cities = $"{model.StateProvinceId}";
|
// cities = $"{model.StateProvinceId}";
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -186,13 +186,7 @@
|
|||||||
void OnCitiesChange(CascaderNode[] selectedNodes)
|
void OnCitiesChange(CascaderNode[] selectedNodes)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"value: {cities} selected: {string.Join(",", selectedNodes.Select(x => x.Value))}");
|
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");
|
model.ParentId = long.Parse(selectedNodes.Last().Value.ToString() ?? "0");
|
||||||
if (model.StateProvinceId == model.ParentId)
|
|
||||||
{
|
|
||||||
model.ParentId = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async void OnFormFinishAsync()
|
async void OnFormFinishAsync()
|
||||||
|
|||||||
@@ -57,11 +57,11 @@
|
|||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
|
|
||||||
[SupplyParameterFromForm]
|
[SupplyParameterFromForm]
|
||||||
StateProvinceModel model { get; set; } = new();
|
AreaModel model { get; set; } = new();
|
||||||
Form<StateProvinceModel> editform = null!;
|
Form<AreaModel> editform = null!;
|
||||||
List<KeyValue> languageList = new();
|
List<KeyValue> languageList = new();
|
||||||
Country country = new();
|
Country country = new();
|
||||||
StateProvinceLocalizedModel stateProvince = new();
|
AreaLocalizedModel stateProvince = new();
|
||||||
bool pageLoading = false;
|
bool pageLoading = false;
|
||||||
bool saving = false;
|
bool saving = false;
|
||||||
|
|
||||||
@@ -125,8 +125,8 @@
|
|||||||
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<StateProvinceLocalizedModel>>(url);
|
var apiResult = await HttpService.Get<ApiResult<AreaLocalizedModel>>(url);
|
||||||
if (apiResult.Success)
|
if (apiResult.Success)
|
||||||
{
|
{
|
||||||
if (apiResult.Data == null)
|
if (apiResult.Data == null)
|
||||||
@@ -136,7 +136,7 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
stateProvince = apiResult.Data;
|
stateProvince = apiResult.Data;
|
||||||
model = apiResult.Data.Adapt<StateProvinceModel>();
|
model = apiResult.Data.Adapt<AreaModel>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -153,7 +153,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);
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@
|
|||||||
Form<StateProvinceSearch> searchForm = new();
|
Form<StateProvinceSearch> searchForm = new();
|
||||||
StateProvinceSearch search = new();
|
StateProvinceSearch search = new();
|
||||||
|
|
||||||
PagingList<StateProvince> PagingList = new() { Size = 20 };
|
PagingList<Area> PagingList = new() { Size = 20 };
|
||||||
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
@@ -136,8 +136,8 @@
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
pageLoading = true;
|
pageLoading = true;
|
||||||
var url = "/api/stateprovince/search";
|
var url = "/api/area/stateprovince/search";
|
||||||
var apiResult = await HttpService.GetPagingList<StateProvince>(url, search, Page.GetValueOrDefault(1), PageSize.GetValueOrDefault(20));
|
var apiResult = await HttpService.GetPagingList<Area>(url, search, Page.GetValueOrDefault(1), PageSize.GetValueOrDefault(20));
|
||||||
if (apiResult.Success)
|
if (apiResult.Success)
|
||||||
{
|
{
|
||||||
if (apiResult.Data != null)
|
if (apiResult.Data != null)
|
||||||
@@ -209,12 +209,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void HandleEdit(StateProvince model)
|
void HandleEdit(Area model)
|
||||||
{
|
{
|
||||||
Navigation.NavigateTo($"/stateprovince/{CountryId}/edit/{model.Id}");
|
Navigation.NavigateTo($"/stateprovince/{CountryId}/edit/{model.Id}");
|
||||||
}
|
}
|
||||||
|
|
||||||
void GotoArea(StateProvince model)
|
void GotoArea(Area model)
|
||||||
{
|
{
|
||||||
Navigation.NavigateTo($"/area/list/{CountryId}/{model.Id}");
|
Navigation.NavigateTo($"/area/list/{CountryId}/{model.Id}");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
using Microsoft.Extensions.Localization;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Atomx.Admin.Controllers
|
namespace Atomx.Admin.Controllers
|
||||||
{
|
{
|
||||||
@@ -60,6 +61,21 @@ namespace Atomx.Admin.Controllers
|
|||||||
_localizer = localizer;
|
_localizer = localizer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取省份-城市树形数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="search"></param>
|
||||||
|
/// <param name="page"></param>
|
||||||
|
/// <param name="size"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("tree/{countryId}")]
|
||||||
|
public async Task<IActionResult> GetAreatree(long countryId)
|
||||||
|
{
|
||||||
|
var result = new ApiResult<List<KeyValueTree>>();
|
||||||
|
var list = await _cacheService.GetAreaTree(countryId);
|
||||||
|
return new JsonResult(result.IsSuccess(list));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 数据查询
|
/// 数据查询
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -67,8 +83,8 @@ namespace Atomx.Admin.Controllers
|
|||||||
/// <param name="page"></param>
|
/// <param name="page"></param>
|
||||||
/// <param name="size"></param>
|
/// <param name="size"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost("search")]
|
[HttpPost("stateprovince/search")]
|
||||||
public IActionResult Search(AreaSearch search, int page, int size = 20)
|
public async Task<IActionResult> StateProvinceSearch(AreaSearch search, int page, int size = 20)
|
||||||
{
|
{
|
||||||
if (page < 1)
|
if (page < 1)
|
||||||
{
|
{
|
||||||
@@ -77,9 +93,83 @@ namespace Atomx.Admin.Controllers
|
|||||||
var result = new ApiResult<PagingList<AreaItem>>();
|
var result = new ApiResult<PagingList<AreaItem>>();
|
||||||
var list = new PagingList<AreaItem>() { Index = page, Size = size };
|
var list = new PagingList<AreaItem>() { Index = page, Size = size };
|
||||||
var countries = new List<Country>();
|
var countries = new List<Country>();
|
||||||
var stateProvices = new List<StateProvince>();
|
|
||||||
|
|
||||||
var query = from p in _dbContext.Areas
|
var query = from p in _dbContext.Areas
|
||||||
|
where p.StateProvinceId == 0
|
||||||
|
select p;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(search.Name))
|
||||||
|
{
|
||||||
|
query = from p in query
|
||||||
|
where p.Name.Contains(search.Name)
|
||||||
|
select p;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (search.CountryId > 0)
|
||||||
|
{
|
||||||
|
query = from p in query
|
||||||
|
where p.CountryId == search.CountryId
|
||||||
|
select p;
|
||||||
|
}
|
||||||
|
|
||||||
|
list.Count = query.Count();
|
||||||
|
var data = query.OrderByDescending(p => p.DisplayOrder).Skip((page - 1) * size).Take(size).ToList();
|
||||||
|
|
||||||
|
if (search.CountryId > 0)
|
||||||
|
{
|
||||||
|
var country = _dbContext.Countries.SingleOrDefault(p => p.Id == search.CountryId);
|
||||||
|
if (country != null)
|
||||||
|
{
|
||||||
|
countries.Add(country);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var countryIds = data.Select(p => p.CountryId).Distinct().ToList();
|
||||||
|
countries = _dbContext.Countries.Where(p => countryIds.Contains(p.Id)).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var item in data)
|
||||||
|
{
|
||||||
|
var model = _mapper.Map<AreaItem>(item);
|
||||||
|
var country = countries.SingleOrDefault(p => p.Id == item.CountryId);
|
||||||
|
if (country != null)
|
||||||
|
{
|
||||||
|
model.CountryName = country.Name;
|
||||||
|
}
|
||||||
|
var state = await _cacheService.GetStateProvince(item.CountryId, item.ParentId);
|
||||||
|
if (state != null)
|
||||||
|
{
|
||||||
|
model.StateProvinceName = state.Name;
|
||||||
|
}
|
||||||
|
list.Items.Add(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
result = result.IsSuccess(list);
|
||||||
|
|
||||||
|
return new JsonResult(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数据查询
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="search"></param>
|
||||||
|
/// <param name="page"></param>
|
||||||
|
/// <param name="size"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("search")]
|
||||||
|
public async Task<IActionResult> SearchAsync(AreaSearch search, int page, int size = 20)
|
||||||
|
{
|
||||||
|
if (page < 1)
|
||||||
|
{
|
||||||
|
page = 1;
|
||||||
|
}
|
||||||
|
var result = new ApiResult<PagingList<AreaItem>>();
|
||||||
|
var list = new PagingList<AreaItem>() { Index = page, Size = size };
|
||||||
|
var countries = new List<Country>();
|
||||||
|
|
||||||
|
var query = from p in _dbContext.Areas
|
||||||
|
where p.StateProvinceId != 0
|
||||||
select p;
|
select p;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(search.Name))
|
if (!string.IsNullOrEmpty(search.Name))
|
||||||
@@ -98,7 +188,7 @@ namespace Atomx.Admin.Controllers
|
|||||||
if (search.StateProvinceId > 0)
|
if (search.StateProvinceId > 0)
|
||||||
{
|
{
|
||||||
query = from p in query
|
query = from p in query
|
||||||
where p.StateProvinceId == search.StateProvinceId
|
where p.ParentId == search.StateProvinceId
|
||||||
select p;
|
select p;
|
||||||
}
|
}
|
||||||
list.Count = query.Count();
|
list.Count = query.Count();
|
||||||
@@ -118,20 +208,6 @@ 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)
|
|
||||||
{
|
|
||||||
var state = _dbContext.StateProvinces.SingleOrDefault(p => p.Id == search.StateProvinceId);
|
|
||||||
if (state != null)
|
|
||||||
{
|
|
||||||
stateProvices.Add(state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var stateIds = data.Select(p => p.StateProvinceId).Distinct().ToList();
|
|
||||||
stateProvices = _dbContext.StateProvinces.Where(p => stateIds.Contains(p.Id)).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var item in data)
|
foreach (var item in data)
|
||||||
{
|
{
|
||||||
var model = _mapper.Map<AreaItem>(item);
|
var model = _mapper.Map<AreaItem>(item);
|
||||||
@@ -140,7 +216,7 @@ namespace Atomx.Admin.Controllers
|
|||||||
{
|
{
|
||||||
model.CountryName = country.Name;
|
model.CountryName = country.Name;
|
||||||
}
|
}
|
||||||
var state = stateProvices.SingleOrDefault(p => p.Id == item.StateProvinceId);
|
var state = await _cacheService.GetStateProvince(item.CountryId, item.ParentId);
|
||||||
if (state != null)
|
if (state != null)
|
||||||
{
|
{
|
||||||
model.StateProvinceName = state.Name;
|
model.StateProvinceName = state.Name;
|
||||||
@@ -196,14 +272,13 @@ namespace Atomx.Admin.Controllers
|
|||||||
return new JsonResult(result);
|
return new JsonResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 新增编辑数据
|
/// 新增编辑数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model"></param>
|
/// <param name="model"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost("save")]
|
[HttpPost("save")]
|
||||||
public IActionResult AddressEdit(AreaModel model)
|
public IActionResult Edit(AreaModel model)
|
||||||
{
|
{
|
||||||
var result = new ApiResult<bool>();
|
var result = new ApiResult<bool>();
|
||||||
var validation = _validator.Validate(model);
|
var validation = _validator.Validate(model);
|
||||||
@@ -212,15 +287,13 @@ namespace Atomx.Admin.Controllers
|
|||||||
var message = validation.Errors.FirstOrDefault()?.ErrorMessage ?? string.Empty;
|
var message = validation.Errors.FirstOrDefault()?.ErrorMessage ?? string.Empty;
|
||||||
return new JsonResult(new ApiResult<string>().IsFail(message, null));
|
return new JsonResult(new ApiResult<string>().IsFail(message, null));
|
||||||
}
|
}
|
||||||
var data = _dbContext.Areas.SingleOrDefault(p => p.CountryId == model.CountryId && p.StateProvinceId == model.StateProvinceId && p.Name == model.Name && p.Id != model.Id);
|
var data = _dbContext.Areas.SingleOrDefault(p => p.CountryId == model.CountryId && p.ParentId == model.ParentId && p.Name == model.Name && p.Id != model.Id);
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
{
|
||||||
return new JsonResult(new ApiResult<string>().IsFail("当前站点语言下已经存在这个配置,请认真检查", null));
|
return new JsonResult(new ApiResult<string>().IsFail("当前站点语言下已经存在这个配置,请认真检查", null));
|
||||||
}
|
}
|
||||||
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)
|
||||||
{
|
{
|
||||||
@@ -229,7 +302,7 @@ 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();
|
var parent = _dbContext.Areas.Where(p => p.Id == model.ParentId).SingleOrDefault();
|
||||||
if (parent == null)
|
if (parent == null)
|
||||||
{
|
{
|
||||||
data.Depth = 0;
|
data.Depth = 0;
|
||||||
@@ -237,6 +310,15 @@ namespace Atomx.Admin.Controllers
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (parent.StateProvinceId == 0)
|
||||||
|
{
|
||||||
|
data.StateProvinceId = parent.Id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data.StateProvinceId = parent.StateProvinceId;
|
||||||
|
}
|
||||||
|
|
||||||
data.Depth = parent.Depth + 1;
|
data.Depth = parent.Depth + 1;
|
||||||
data.Path = $"{parent.Path},{data.Id}";
|
data.Path = $"{parent.Path},{data.Id}";
|
||||||
}
|
}
|
||||||
@@ -249,7 +331,7 @@ 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();
|
var parent = _dbContext.Areas.Where(p => p.Id == data.ParentId).SingleOrDefault();
|
||||||
if (parent == null)
|
if (parent == null)
|
||||||
{
|
{
|
||||||
data.Depth = 0;
|
data.Depth = 0;
|
||||||
@@ -257,6 +339,14 @@ namespace Atomx.Admin.Controllers
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (parent.StateProvinceId == 0)
|
||||||
|
{
|
||||||
|
data.StateProvinceId = parent.Id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data.StateProvinceId = parent.StateProvinceId;
|
||||||
|
}
|
||||||
data.Depth = parent.Depth + 1;
|
data.Depth = parent.Depth + 1;
|
||||||
data.Path = $"{parent.Path},{data.Id}";
|
data.Path = $"{parent.Path},{data.Id}";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,246 +0,0 @@
|
|||||||
using Atomx.Admin.Client.Models;
|
|
||||||
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;
|
|
||||||
using FluentValidation;
|
|
||||||
using MapsterMapper;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Atomx.Admin.Controllers
|
|
||||||
{
|
|
||||||
[Route("api/[controller]")]
|
|
||||||
[ApiController]
|
|
||||||
public class StateProvinceController : ControllerBase
|
|
||||||
{
|
|
||||||
private readonly ILogger<StateProvinceController> _logger;
|
|
||||||
private readonly DataContext _dbContext;
|
|
||||||
private readonly IIdCreatorService _idCreator;
|
|
||||||
private readonly IIdentityService _identityService;
|
|
||||||
private readonly IMapper _mapper;
|
|
||||||
private readonly ICacheService _cacheService;
|
|
||||||
private readonly IBackgroundJobService _backgroundService;
|
|
||||||
readonly IValidator<StateProvinceModel> _validator;
|
|
||||||
readonly IStringLocalizer<StateProvinceController> _localizer;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="logger"></param>
|
|
||||||
/// <param name="idCreator"></param>
|
|
||||||
/// <param name="identityService"></param>
|
|
||||||
/// <param name="dbContext"></param>
|
|
||||||
/// <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, IBackgroundJobService backgroundJobService, IValidator<StateProvinceModel> validator, IStringLocalizer<StateProvinceController> localizer)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_idCreator = idCreator;
|
|
||||||
_identityService = identityService;
|
|
||||||
_dbContext = dbContext;
|
|
||||||
_mapper = mapper;
|
|
||||||
_cacheService = cacheService;
|
|
||||||
_backgroundService = backgroundJobService;
|
|
||||||
_validator = validator;
|
|
||||||
_localizer = localizer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 数据查询
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="search"></param>
|
|
||||||
/// <param name="page"></param>
|
|
||||||
/// <param name="size"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("tree/{countryId:long}")]
|
|
||||||
public async Task<IActionResult> GetTree(long countryId, int page, int size = 20)
|
|
||||||
{
|
|
||||||
var list = await _cacheService.GetAreaTree(countryId);
|
|
||||||
|
|
||||||
return new JsonResult(new ApiResult<List<KeyValueTree>>().IsSuccess(list));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 数据查询
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="search"></param>
|
|
||||||
/// <param name="page"></param>
|
|
||||||
/// <param name="size"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("select/{countryId:long}")]
|
|
||||||
public IActionResult Select(long countryId, int page, int size = 20)
|
|
||||||
{
|
|
||||||
var list = new List<KeyValue>();
|
|
||||||
var query = from p in _dbContext.StateProvinces
|
|
||||||
where p.CountryId == countryId && p.Enabled
|
|
||||||
select p;
|
|
||||||
list = query.OrderByDescending(p => p.DisplayOrder).Select(p => new KeyValue() { Label = p.Id.ToString(), Value = p.Name }).ToList();
|
|
||||||
|
|
||||||
return new JsonResult(new ApiResult<List<KeyValue>>().IsSuccess(list));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 数据查询
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="search"></param>
|
|
||||||
/// <param name="page"></param>
|
|
||||||
/// <param name="size"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost("search")]
|
|
||||||
public IActionResult Search(StateProvinceSearch search, int page, int size = 20)
|
|
||||||
{
|
|
||||||
if (page < 1)
|
|
||||||
{
|
|
||||||
page = 1;
|
|
||||||
}
|
|
||||||
var result = new ApiResult<PagingList<StateProvince>>();
|
|
||||||
var list = new PagingList<StateProvince>() { Index = page, Size = size };
|
|
||||||
var query = from p in _dbContext.StateProvinces
|
|
||||||
select p;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(search.Name))
|
|
||||||
{
|
|
||||||
query = from p in query
|
|
||||||
where p.Name.Contains(search.Name)
|
|
||||||
select p;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (search.CountryId > 0)
|
|
||||||
{
|
|
||||||
query = from p in query
|
|
||||||
where p.CountryId == search.CountryId
|
|
||||||
select p;
|
|
||||||
}
|
|
||||||
list.Count = query.Count();
|
|
||||||
list.Items = query.OrderByDescending(p => p.DisplayOrder).Skip((page - 1) * size).Take(size).ToList();
|
|
||||||
|
|
||||||
result = result.IsSuccess(list);
|
|
||||||
|
|
||||||
return new JsonResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 通过ID获取数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("{id:long}")]
|
|
||||||
public IActionResult Get(long id)
|
|
||||||
{
|
|
||||||
var result = new ApiResult<StateProvince>();
|
|
||||||
var data = _dbContext.StateProvinces.SingleOrDefault(p => p.Id == id);
|
|
||||||
if (data == null)
|
|
||||||
{
|
|
||||||
return new JsonResult(new ApiResult<string>().IsFail("数据不存在", null));
|
|
||||||
}
|
|
||||||
|
|
||||||
result = result.IsSuccess(data);
|
|
||||||
return new JsonResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 通过ID获取详情,含多语言
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("detail")]
|
|
||||||
public IActionResult Detail(long id)
|
|
||||||
{
|
|
||||||
var result = new ApiResult<StateProvinceLocalizedModel>();
|
|
||||||
var data = _dbContext.StateProvinces.SingleOrDefault(p => p.Id == id);
|
|
||||||
if (data == null)
|
|
||||||
{
|
|
||||||
return new JsonResult(new ApiResult<string>().IsFail("数据不存在", null));
|
|
||||||
}
|
|
||||||
var localizedList = _dbContext.LocalizedProperties.Where(p => p.EntityId == id).ToList();
|
|
||||||
var model = _mapper.Map<StateProvinceLocalizedModel>(data);
|
|
||||||
model.Locales = localizedList;
|
|
||||||
|
|
||||||
result = result.IsSuccess(model);
|
|
||||||
|
|
||||||
return new JsonResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 新增编辑数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="model"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost("save")]
|
|
||||||
public IActionResult AddressEdit(StateProvinceModel model)
|
|
||||||
{
|
|
||||||
var result = new ApiResult<bool>();
|
|
||||||
var validation = _validator.Validate(model);
|
|
||||||
if (!validation.IsValid)
|
|
||||||
{
|
|
||||||
var message = validation.Errors.FirstOrDefault()?.ErrorMessage ?? string.Empty;
|
|
||||||
return new JsonResult(new ApiResult<string>().IsFail(message, null));
|
|
||||||
}
|
|
||||||
var data = _dbContext.StateProvinces.SingleOrDefault(p => p.CountryId == model.CountryId && p.Name == model.Name && p.Id != model.Id);
|
|
||||||
if (data != null)
|
|
||||||
{
|
|
||||||
return new JsonResult(new ApiResult<string>().IsFail("当前数据已经存在,请认真检查", null));
|
|
||||||
}
|
|
||||||
if (model.Id > 0)
|
|
||||||
{
|
|
||||||
data = _dbContext.StateProvinces.SingleOrDefault(p => p.Id == model.Id);
|
|
||||||
if (data == null)
|
|
||||||
{
|
|
||||||
return new JsonResult(new ApiResult<string>().IsFail("数据不存在", null));
|
|
||||||
}
|
|
||||||
|
|
||||||
data = _mapper.Map(model, data);
|
|
||||||
|
|
||||||
_dbContext.SaveChanges();
|
|
||||||
_backgroundService.ResetStateProvinceAndAreaTree(data.CountryId);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
data = _mapper.Map<StateProvince>(model);
|
|
||||||
data.Id = _idCreator.CreateId();
|
|
||||||
|
|
||||||
_dbContext.StateProvinces.Add(data);
|
|
||||||
_dbContext.SaveChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new JsonResult(new ApiResult<string>().IsSuccess("操作成功"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 删除数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="model"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
|
|
||||||
[HttpPost("delete")]
|
|
||||||
public async Task<IActionResult> DeleteAsync(long id)
|
|
||||||
{
|
|
||||||
var result = new ApiResult<string>();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Console.WriteLine($"{id} deleted");
|
|
||||||
var count = _dbContext.StateProvinces.Where(p => p.Id == id).ExecuteDelete();
|
|
||||||
result = result.IsSuccess(count.ToString());
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
result = result.IsFail(ex.Message);
|
|
||||||
_logger.LogError(ex.Message);
|
|
||||||
}
|
|
||||||
return new JsonResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -22,7 +22,7 @@ namespace Atomx.Common.Entities
|
|||||||
public long CountryId { get; set; }
|
public long CountryId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 州省ID
|
/// 州/省ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long StateProvinceId { get; set; }
|
public long StateProvinceId { get; set; }
|
||||||
|
|
||||||
@@ -44,6 +44,12 @@ 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>
|
||||||
|
[Column(TypeName = "varchar(32)")]
|
||||||
|
public string Abbreviation { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 地区深度
|
/// 地区深度
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
|
|
||||||
namespace Atomx.Common.Entities
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 州省
|
|
||||||
/// </summary>
|
|
||||||
[Table("StateProvinces")]
|
|
||||||
public class StateProvince
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 数据ID
|
|
||||||
/// </summary>
|
|
||||||
[DatabaseGenerated(DatabaseGeneratedOption.None)]
|
|
||||||
[Key]
|
|
||||||
public long Id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 地区名称
|
|
||||||
/// </summary>
|
|
||||||
|
|
||||||
[Column(TypeName = "varchar(256)")]
|
|
||||||
public string Name { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 国家ID
|
|
||||||
/// </summary>
|
|
||||||
public long CountryId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 首字母
|
|
||||||
/// </summary>
|
|
||||||
[Column(TypeName = "varchar(1)")]
|
|
||||||
public string Initial { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 缩写
|
|
||||||
/// </summary>
|
|
||||||
[Column(TypeName = "varchar(32)")]
|
|
||||||
public string Abbreviation { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 是否启用
|
|
||||||
/// </summary>
|
|
||||||
public bool Enabled { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 显示排序
|
|
||||||
/// </summary>
|
|
||||||
public int DisplayOrder { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
using Atomx.Common.Entities;
|
|
||||||
|
|
||||||
namespace Atomx.Common.Models
|
|
||||||
{
|
|
||||||
public class StateProvinceLocalizedModel : StateProvince
|
|
||||||
{
|
|
||||||
public List<LocalizedProperty> Locales { get; set; } = new List<LocalizedProperty>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -24,7 +24,7 @@ namespace Atomx.Data.CacheServices
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parentId"></param>
|
/// <param name="parentId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<List<StateProvince>> GetStateProvinces(long countryId, bool? reload = false);
|
Task<List<Area>> GetStateProvinces(long countryId, bool? reload = false);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取州省数据
|
/// 获取州省数据
|
||||||
@@ -32,7 +32,7 @@ namespace Atomx.Data.CacheServices
|
|||||||
/// <param name="countryId"></param>
|
/// <param name="countryId"></param>
|
||||||
/// <param name="stateProvinceId"></param>
|
/// <param name="stateProvinceId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<StateProvince> GetStateProvince(long countryId, long stateProvinceId);
|
Task<Area> GetStateProvince(long countryId, long stateProvinceId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取地区数据
|
/// 获取地区数据
|
||||||
@@ -54,7 +54,7 @@ namespace Atomx.Data.CacheServices
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="stateProvince"></param>
|
/// <param name="stateProvince"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task UpdateStateProvince(StateProvince stateProvince);
|
Task UpdateStateProvince(Area area);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新调整国家缓存数据
|
/// 更新调整国家缓存数据
|
||||||
@@ -141,14 +141,14 @@ namespace Atomx.Data.CacheServices
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="countryId"></param>
|
/// <param name="countryId"></param>
|
||||||
/// <returns></returns>
|
/// <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;
|
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)
|
if (cacheData == null || reloadData)
|
||||||
{
|
{
|
||||||
var stateProvinces = (from p in _dbContext.StateProvinces
|
var stateProvinces = (from p in _dbContext.Areas
|
||||||
where p.CountryId == countryId && p.Enabled
|
where p.CountryId == countryId && p.Enabled && p.ParentId == 0
|
||||||
select p).ToList();
|
select p).ToList();
|
||||||
await SetCacheAsync($"{CacheKeys.StateProvince}.{countryId}", stateProvinces);
|
await SetCacheAsync($"{CacheKeys.StateProvince}.{countryId}", stateProvinces);
|
||||||
return stateProvinces;
|
return stateProvinces;
|
||||||
@@ -162,7 +162,7 @@ namespace Atomx.Data.CacheServices
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="stateProvinceId"></param>
|
/// <param name="stateProvinceId"></param>
|
||||||
/// <returns></returns>
|
/// <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 cacheData = await GetStateProvinces(countryId);
|
||||||
var data = cacheData.SingleOrDefault(p => p.Id == stateProvinceId);
|
var data = cacheData.SingleOrDefault(p => p.Id == stateProvinceId);
|
||||||
@@ -183,7 +183,7 @@ namespace Atomx.Data.CacheServices
|
|||||||
{
|
{
|
||||||
List<Area> areas = new();
|
List<Area> areas = new();
|
||||||
var query = from p in _dbContext.Areas
|
var query = from p in _dbContext.Areas
|
||||||
where p.CountryId == countryId && p.Enabled
|
where p.CountryId == countryId && p.Enabled && p.StateProvinceId != 0
|
||||||
select p;
|
select p;
|
||||||
var count = query.Count();
|
var count = query.Count();
|
||||||
int size = 50;
|
int size = 50;
|
||||||
@@ -193,7 +193,7 @@ namespace Atomx.Data.CacheServices
|
|||||||
var list = query.Skip((i - 1) * size).Take(size).ToList();
|
var list = query.Skip((i - 1) * size).Take(size).ToList();
|
||||||
areas.AddRange(list);
|
areas.AddRange(list);
|
||||||
}
|
}
|
||||||
await SetCacheAsync(CacheKeys.Country, areas);
|
await SetCacheAsync($"{CacheKeys.City}.{countryId}", areas);
|
||||||
return areas;
|
return areas;
|
||||||
}
|
}
|
||||||
return cacheData;
|
return cacheData;
|
||||||
@@ -218,16 +218,16 @@ namespace Atomx.Data.CacheServices
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="stateProvince"></param>
|
/// <param name="stateProvince"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task UpdateStateProvince(StateProvince stateProvince)
|
public async Task UpdateStateProvince(Area area)
|
||||||
{
|
{
|
||||||
var cacheData = await GetStateProvinces(stateProvince.CountryId);
|
var cacheData = await GetStateProvinces(area.CountryId);
|
||||||
var data = cacheData.Where(p => p.Id == stateProvince.Id).SingleOrDefault();
|
var data = cacheData.Where(p => p.Id == area.Id).SingleOrDefault();
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
{
|
||||||
cacheData.Remove(data);
|
cacheData.Remove(data);
|
||||||
}
|
}
|
||||||
cacheData.Add(stateProvince);
|
cacheData.Add(area);
|
||||||
await SetCacheAsync($"{CacheKeys.StateProvince}.{stateProvince.CountryId}", cacheData);
|
await SetCacheAsync($"{CacheKeys.StateProvince}.{area.CountryId}", cacheData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace Atomx.Data
|
|||||||
public DbSet<AppVersion> AppVersions { get; set; }
|
public DbSet<AppVersion> AppVersions { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 市区数据
|
/// 州省/市区数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DbSet<Area> Areas { get; set; }
|
public DbSet<Area> Areas { get; set; }
|
||||||
|
|
||||||
@@ -141,11 +141,6 @@ namespace Atomx.Data
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public DbSet<SpecificationAttributeOption> SpecificationAttributeOptions { get; set; }
|
public DbSet<SpecificationAttributeOption> SpecificationAttributeOptions { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 州省份数据
|
|
||||||
/// </summary>
|
|
||||||
public DbSet<StateProvince> StateProvinces { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 刷新Tokens
|
/// 刷新Tokens
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
namespace Atomx.Data.Migrations
|
namespace Atomx.Data.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(DataContext))]
|
[DbContext(typeof(DataContext))]
|
||||||
[Migration("20260104093702_0.1")]
|
[Migration("20260104144630_0.1")]
|
||||||
partial class _01
|
partial class _01
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -239,6 +239,10 @@ namespace Atomx.Data.Migrations
|
|||||||
b.Property<long>("Id")
|
b.Property<long>("Id")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("Abbreviation")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("varchar(32)");
|
||||||
|
|
||||||
b.Property<bool>("AllowShipping")
|
b.Property<bool>("AllowShipping")
|
||||||
.HasColumnType("boolean");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
@@ -1382,37 +1386,6 @@ namespace Atomx.Data.Migrations
|
|||||||
b.ToTable("SpecificationAttributeOptions");
|
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 =>
|
modelBuilder.Entity("Atomx.Common.Entities.Tag", b =>
|
||||||
{
|
{
|
||||||
b.Property<long>("Id")
|
b.Property<long>("Id")
|
||||||
@@ -106,6 +106,7 @@ 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),
|
||||||
|
Abbreviation = table.Column<string>(type: "varchar(32)", nullable: false),
|
||||||
Depth = table.Column<int>(type: "integer", nullable: false),
|
Depth = table.Column<int>(type: "integer", nullable: false),
|
||||||
Path = table.Column<string>(type: "varchar(100)", 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),
|
||||||
@@ -654,23 +655,6 @@ namespace Atomx.Data.Migrations
|
|||||||
table.PrimaryKey("PK_SpecificationAttributes", x => x.Id);
|
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(
|
migrationBuilder.CreateTable(
|
||||||
name: "Tags",
|
name: "Tags",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
@@ -825,9 +809,6 @@ namespace Atomx.Data.Migrations
|
|||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "SpecificationAttributes");
|
name: "SpecificationAttributes");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "StateProvinces");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Tags");
|
name: "Tags");
|
||||||
|
|
||||||
@@ -236,6 +236,10 @@ namespace Atomx.Data.Migrations
|
|||||||
b.Property<long>("Id")
|
b.Property<long>("Id")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("Abbreviation")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("varchar(32)");
|
||||||
|
|
||||||
b.Property<bool>("AllowShipping")
|
b.Property<bool>("AllowShipping")
|
||||||
.HasColumnType("boolean");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
@@ -1379,37 +1383,6 @@ namespace Atomx.Data.Migrations
|
|||||||
b.ToTable("SpecificationAttributeOptions");
|
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 =>
|
modelBuilder.Entity("Atomx.Common.Entities.Tag", b =>
|
||||||
{
|
{
|
||||||
b.Property<long>("Id")
|
b.Property<long>("Id")
|
||||||
|
|||||||
Reference in New Issue
Block a user