重复设备sn 判断
This commit is contained in:
parent
1e0e5ff151
commit
32e9ced4dc
|
|
@ -64,6 +64,15 @@ namespace LY.App.Service
|
||||||
public async Task<ApiResult> Add(AddDevice input)
|
public async Task<ApiResult> Add(AddDevice input)
|
||||||
{
|
{
|
||||||
var entity = input.Adapt<DeviceEntity>();
|
var entity = input.Adapt<DeviceEntity>();
|
||||||
|
var exists = await _db.Queryable<DeviceEntity>().FirstAsync(s => s.DeviceSN == entity.DeviceSN);
|
||||||
|
if (exists!= null)
|
||||||
|
{
|
||||||
|
return new ApiResult()
|
||||||
|
{
|
||||||
|
code = 1,
|
||||||
|
msg = "设备SN已存在"
|
||||||
|
};
|
||||||
|
}
|
||||||
var id = await _db.Insertable(entity).ExecuteReturnSnowflakeIdAsync();
|
var id = await _db.Insertable(entity).ExecuteReturnSnowflakeIdAsync();
|
||||||
entity.Id = id;
|
entity.Id = id;
|
||||||
await AddDevice2Manager(entity);
|
await AddDevice2Manager(entity);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue