From 59534413f26689e5bcbd3a4aa98dd66524edf3c5 Mon Sep 17 00:00:00 2001 From: dev01 Date: Thu, 26 Oct 2023 18:13:06 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=89=8D=E5=8F=B0API]=20DeviceManageControlle?= =?UTF-8?q?r=20=E5=8F=96=E5=BE=97=20DisasterDevice=20API=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=20building=5Ftag=20=E5=BC=95=E6=95=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/DeviceManageController.cs | 19 ++++++++++++++----- FrontendWebApi/Models/Device.cs | 4 ++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/FrontendWebApi/ApiControllers/DeviceManageController.cs b/FrontendWebApi/ApiControllers/DeviceManageController.cs index 09fac2b..a9ec4b8 100644 --- a/FrontendWebApi/ApiControllers/DeviceManageController.cs +++ b/FrontendWebApi/ApiControllers/DeviceManageController.cs @@ -812,7 +812,7 @@ namespace FrontendWebApi.ApiControllers catch (Exception exception) { apiResult.Code = "9999"; - Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception); return Ok(apiResult); } return Ok(apiResult); @@ -1183,17 +1183,26 @@ namespace FrontendWebApi.ApiControllers /// [HttpPost] [Route("api/Device/GetDisasterDevice")] - public async Task>>> GetDisasterDevice() + public async Task>>> GetDisasterDevice([FromBody] FindDeviceDisaster fdd) { ApiResult> apiResult = new ApiResult>(); try { - var sqlString = $@" SELECT * FROM device_disaster"; - var fr = await backendRepository.GetAllAsync(sqlString); + var result = new List(); + var sqlString = $@" SELECT * FROM device_disaster WHERE 1=1"; + if (fdd != null) + { + if (!string.IsNullOrEmpty(fdd.building_tag)) { + sqlString += " AND device_building_tag = @building_tag"; + } + } + + result = await backendRepository.GetAllAsync(sqlString,fdd); + apiResult.Code = "0000"; - apiResult.Data = fr; + apiResult.Data = result; } catch (Exception exception) { diff --git a/FrontendWebApi/Models/Device.cs b/FrontendWebApi/Models/Device.cs index 4cf8b13..7213f07 100644 --- a/FrontendWebApi/Models/Device.cs +++ b/FrontendWebApi/Models/Device.cs @@ -215,4 +215,8 @@ namespace FrontendWebApi.Models public string device_number { get; set; } } + public class FindDeviceDisaster + { + public string building_tag { get; set; } + } }