细节调整

This commit is contained in:
yanghongwei 2025-04-26 01:13:29 +08:00
parent 94edbc7498
commit 20728526e0
3 changed files with 19 additions and 5 deletions

View File

@ -111,6 +111,8 @@ namespace LY.App.Service
await _db.Updateable(entity).ExecuteCommandAsync();
await deviceManager.RemoveDevice(entity.Id);
await AddDevice2Manager(entity);
var key = RedisKeyList.DeviceInfo(input.DeviceSN);
await _redisService.SetAsync(key, entity);
return new ApiResult()
{
code = 0,

View File

@ -6,6 +6,7 @@ using Mapster;
using Microsoft.AspNetCore.Http;
using NetTopologySuite.Geometries;
using NetTopologySuite.GeometriesGraph;
using NetTopologySuite.Index.HPRtree;
using SqlSugar;
using System.Xml.Schema;
@ -52,6 +53,8 @@ namespace LY.App.Service
}
// 位置
await _db.Insertable(entity).ExecuteReturnSnowflakeIdAsync();
var key = RedisKeyList.PositioinRegion(entity.Id);
await _redisService.SetAsync(key, entity);
return new ApiResult(true, "添加成功");
}
public async Task<ApiResult> Update(UpdatePosition input)
@ -72,6 +75,8 @@ namespace LY.App.Service
}
}
await _db.Updateable(entity).ExecuteCommandAsync();
var key = RedisKeyList.PositioinRegion(entity.Id);
await _redisService.SetAsync(key, entity);
return new ApiResult(true, "添加成功");
}
return new ApiResult(false, "未找到要更新的对象");
@ -88,6 +93,8 @@ namespace LY.App.Service
{
entity.IsDeleted = true;
await _db.Updateable(entity).ExecuteCommandAsync();
var key = RedisKeyList.PositioinRegion(entity.Id);
await _redisService.DeleteAsync(key);
return new ApiResult(true, "删除成功");
}
return new ApiResult(false, "未找到要删除的对象");

View File

@ -1,4 +1,5 @@
using LY.App.Common.Redis;
using GraphQL;
using LY.App.Common.Redis;
using LY.App.Extensions.DI;
using LY.App.Model;
using Mapster;
@ -41,7 +42,8 @@ namespace LY.App.Service
return result;
}
var id = await _db.Insertable(entity).ExecuteReturnSnowflakeIdAsync();
await _redisService.SetAsync(entity.sn, entity);
var key = RedisKeyList.white_list(input.sn);
await _redisService.SetAsync(key, entity);
result.data = id.ToString();
return result;
}
@ -54,10 +56,12 @@ namespace LY.App.Service
{
var result = new ApiResult();
var entity = await _db.Queryable<Whitelist>().FirstAsync(x => x.Id == id);
if (entity == null)
if (entity != null)
{
entity.IsDeleted = true;
await _db.Updateable(entity).ExecuteCommandAsync();
var key = RedisKeyList.white_list(entity.sn);
await _redisService.DeleteAsync(key);
return result;
}
return result;
@ -113,11 +117,12 @@ namespace LY.App.Service
public async Task<ApiResult> Update(UpdateWhitelist input)
{
var entity = input.Adapt<Whitelist>();
await _db.Updateable(entity).ExecuteCommandAsync();
if (entity != null)
{
entity.Adapt(input);
await _db.Updateable(entity).ExecuteCommandAsync();
var key = RedisKeyList.white_list(input.sn);
await _redisService.SetAsync(key, entity);
return new ApiResult() { code = 0 };
}
return new ApiResult() { code = 1, msg = "更新失败" };