添加redis获取机场数据

main
zhangbin 2025-11-26 09:07:25 +08:00
parent 5bb38d60e0
commit f7317974f6
3 changed files with 39 additions and 4 deletions

View File

@ -1642,7 +1642,7 @@ namespace OpenAuth.App.ServiceApp
public async Task<string> TestPreventFlyTask(string taskId) public async Task<string> TestPreventFlyTask(string taskId)
{ {
// 任务信息 // 任务信息
var task = await Repository.ChangeRepository<SugarRepositiry<LasaTask>>().GetByIdAsync(taskId); var task = await Repository.ChangeRepository<SugarRepositiry<LasaTask>>().GetByIdAsync(taskId);
var dronePort = await Repository.ChangeRepository<SugarRepositiry<LasaDronePort>>() var dronePort = await Repository.ChangeRepository<SugarRepositiry<LasaDronePort>>()
.GetByIdAsync(task.TaskDronePort); .GetByIdAsync(task.TaskDronePort);
@ -2973,7 +2973,8 @@ WHERE
{ {
Result = new Result = new
{ {
modeCode, droneInDock modeCode,
droneInDock
} }
}; };
} }
@ -3004,5 +3005,25 @@ WHERE
} }
).First(); ).First();
} }
#region redis获取数据
public async Task<Response<string>> GetDronePortInfoFromRedis(string key)
{
var info = _redisCacheContext.Get<string>(key);
if (!string.IsNullOrEmpty(info))
{
return new Response<string>
{
Result = info
};
}
return new Response<string>
{
Message = "暂无数据",
Code = 500
};
}
#endregion
} }
} }

View File

@ -1011,5 +1011,19 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
{ {
await _configSubscribe.HandleTopic(null, topic, message); await _configSubscribe.HandleTopic(null, topic, message);
} }
#region 获取redis数据
/// <summary>
/// 根据key获取redis数据
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
[HttpGet]
[AllowAnonymous]
public async Task<Response<string>> GetDronePortInfoFromRedis(string key)
{
return await _app.GetDronePortInfoFromRedis(key);
}
#endregion
} }
} }

View File

@ -22,8 +22,8 @@
"UploadPath": "", "UploadPath": "",
// //
"RedisConf": { "RedisConf": {
//"Conn": "192.168.10.163:6379,password=123456", "Conn": "192.168.10.163:6379,password=123456",
"Conn": "127.0.0.1:6379,password=123456", //"Conn": "127.0.0.1:6379,password=123456",
"Database": 7 "Database": 7
}, },
//redis //redis