From 840ee8e9f0cf226f261004af32e84a5de65f3356 Mon Sep 17 00:00:00 2001 From: dev01 Date: Wed, 18 Jan 2023 10:20:29 +0800 Subject: [PATCH] =?UTF-8?q?[FrontendWebApi]=20Device=20GetBaseDevice=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20device=5Fnumber=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 | 17 +++++++++++++++-- FrontendWebApi/Models/Device.cs | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/FrontendWebApi/ApiControllers/DeviceManageController.cs b/FrontendWebApi/ApiControllers/DeviceManageController.cs index 60866ea..fa2025f 100644 --- a/FrontendWebApi/ApiControllers/DeviceManageController.cs +++ b/FrontendWebApi/ApiControllers/DeviceManageController.cs @@ -340,8 +340,20 @@ namespace FrontendWebApi.ApiControllers ApiResult apiResult = new ApiResult(); try { - string sql = $@"select device_number, full_name, device_coordinate, device_coordinate_3d from device where deleted = 0 and device_guid = @device_guid"; - object param = new { @device_guid = fd.device_guid }; + if (fd.device_guid == null && fd.device_number == null) { + apiResult.Code = "0002"; + apiResult.Msg = "必需輸入設備資訊"; + return Ok(apiResult); + } + + string sql = $@"select device_number, full_name, device_coordinate,device_coordinate_3d from device where deleted = 0 and + ( + (@device_guid is not null and device_guid = @device_guid) + OR (@device_guid is null and device_number = @device_number) + ) + "; + object param = new { @device_guid = fd.device_guid,@device_number = fd.device_number}; + var device = await backendRepository.GetOneAsync(sql, param); if (device == null) @@ -356,6 +368,7 @@ namespace FrontendWebApi.ApiControllers } catch (Exception exception) { + apiResult.Code = "9999"; Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); return Ok(apiResult); diff --git a/FrontendWebApi/Models/Device.cs b/FrontendWebApi/Models/Device.cs index 92ba15a..2bfe850 100644 --- a/FrontendWebApi/Models/Device.cs +++ b/FrontendWebApi/Models/Device.cs @@ -11,6 +11,7 @@ namespace FrontendWebApi.Models public string building_tag { get; set; } public string floor_tag { get; set; } public string device_guid { get; set; } + public string device_number { get; set; } } public class BuildList