更新区域

This commit is contained in:
2021-05-06 10:58:19 +08:00
parent a1e5b2f238
commit e519f1344e

View File

@@ -32,6 +32,7 @@ namespace Ewide.Core.Service.Area
public async Task AddAreaCode(AreaCodeInput input)
{
CheckInput(input);
CheckCode(input);
CheckArea(input);
await _areaCodeRep.InsertNowAsync(input.Adapt<SysAreaCode>());
await _sysCacheService.SetAreaCode(await _areaCodeRep.DetachedEntities.ToListAsync());
@@ -138,5 +139,15 @@ namespace Ewide.Core.Service.Area
}
return true;
}
private bool CheckCode(AreaCodeInput input)
{
var any = _areaCodeRep.DetachedEntities.Any(p => p.Code == input.Code);
if (any)
{
throw Oops.Oh("编码重复");
}
return true;
}
}
}