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