From f7317974f63023a66617b02c28720b1db6347fff Mon Sep 17 00:00:00 2001 From: zhangbin <460190368@qq.com> Date: Wed, 26 Nov 2025 09:07:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0redis=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=9C=BA=E5=9C=BA=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenAuth.App/ServiceApp/ManageApp.cs | 25 +++++++++++++++++-- .../ServiceControllers/ManageController.cs | 14 +++++++++++ OpenAuth.WebApi/appsettings.json | 4 +-- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/OpenAuth.App/ServiceApp/ManageApp.cs b/OpenAuth.App/ServiceApp/ManageApp.cs index 8b29c77..e3a6fa9 100644 --- a/OpenAuth.App/ServiceApp/ManageApp.cs +++ b/OpenAuth.App/ServiceApp/ManageApp.cs @@ -1642,7 +1642,7 @@ namespace OpenAuth.App.ServiceApp public async Task TestPreventFlyTask(string taskId) { -// 任务信息 + // 任务信息 var task = await Repository.ChangeRepository>().GetByIdAsync(taskId); var dronePort = await Repository.ChangeRepository>() .GetByIdAsync(task.TaskDronePort); @@ -2973,7 +2973,8 @@ WHERE { Result = new { - modeCode, droneInDock + modeCode, + droneInDock } }; } @@ -3004,5 +3005,25 @@ WHERE } ).First(); } + + + #region redis获取数据 + public async Task> GetDronePortInfoFromRedis(string key) + { + var info = _redisCacheContext.Get(key); + if (!string.IsNullOrEmpty(info)) + { + return new Response + { + Result = info + }; + } + return new Response + { + Message = "暂无数据", + Code = 500 + }; + } + #endregion } } \ No newline at end of file diff --git a/OpenAuth.WebApi/Controllers/ServiceControllers/ManageController.cs b/OpenAuth.WebApi/Controllers/ServiceControllers/ManageController.cs index 3e4dc49..52bfcb5 100644 --- a/OpenAuth.WebApi/Controllers/ServiceControllers/ManageController.cs +++ b/OpenAuth.WebApi/Controllers/ServiceControllers/ManageController.cs @@ -1011,5 +1011,19 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers { await _configSubscribe.HandleTopic(null, topic, message); } + + #region 获取redis数据 + /// + /// 根据key获取redis数据 + /// + /// + /// + [HttpGet] + [AllowAnonymous] + public async Task> GetDronePortInfoFromRedis(string key) + { + return await _app.GetDronePortInfoFromRedis(key); + } + #endregion } } \ No newline at end of file diff --git a/OpenAuth.WebApi/appsettings.json b/OpenAuth.WebApi/appsettings.json index 05c6707..165b129 100644 --- a/OpenAuth.WebApi/appsettings.json +++ b/OpenAuth.WebApi/appsettings.json @@ -22,8 +22,8 @@ "UploadPath": "", //附件上传的路径,如果为空则保存在站点根目录 "RedisConf": { - //"Conn": "192.168.10.163:6379,password=123456", - "Conn": "127.0.0.1:6379,password=123456", + "Conn": "192.168.10.163:6379,password=123456", + //"Conn": "127.0.0.1:6379,password=123456", "Database": 7 }, //redis配置