Update区域更新和新增时是否有重复
This commit is contained in:
@@ -32,6 +32,7 @@ namespace Ewide.Core.Service.Area
|
||||
public async Task AddAreaCode(AreaCodeInput input)
|
||||
{
|
||||
CheckInput(input);
|
||||
CheckArea(input);
|
||||
await _areaCodeRep.InsertNowAsync(input.Adapt<SysAreaCode>());
|
||||
await _sysCacheService.SetAreaCode(await _areaCodeRep.DetachedEntities.ToListAsync());
|
||||
}
|
||||
@@ -112,6 +113,7 @@ namespace Ewide.Core.Service.Area
|
||||
public async Task UpdateAreaCode(AreaCodeInput input)
|
||||
{
|
||||
CheckInput(input);
|
||||
CheckArea(input);
|
||||
var area = input.Adapt<SysAreaCode>();
|
||||
await area.UpdateNowAsync();
|
||||
await _sysCacheService.SetAreaCode(await _areaCodeRep.DetachedEntities.ToListAsync());
|
||||
@@ -126,5 +128,15 @@ namespace Ewide.Core.Service.Area
|
||||
//检查是否有子节点
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool CheckArea(AreaCodeInput input)
|
||||
{
|
||||
var any = _areaCodeRep.DetachedEntities.Any(p => p.AdCode == input.AdCode && p.Code != input.Code);
|
||||
if (any)
|
||||
{
|
||||
throw Oops.Oh("区域编码重复");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user