[FrontendWebApi] Device GetBaseDevice 增加 device_number 引數

This commit is contained in:
dev01 2023-01-18 10:20:29 +08:00
parent 97a1caa3ec
commit 840ee8e9f0
2 changed files with 16 additions and 2 deletions

View File

@ -340,8 +340,20 @@ namespace FrontendWebApi.ApiControllers
ApiResult<DeviceBaseInfo> apiResult = new ApiResult<DeviceBaseInfo>();
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<DeviceBaseInfo>(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);

View File

@ -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