[前台API] DeviceManageController 取得 DisasterDevice API 增加 building_tag 引數

This commit is contained in:
dev01 2023-10-26 18:13:06 +08:00
parent 14285abf75
commit 59534413f2
2 changed files with 18 additions and 5 deletions

View File

@ -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
/// <returns></returns>
[HttpPost]
[Route("api/Device/GetDisasterDevice")]
public async Task<ActionResult<ApiResult<List<DeviceDisaster>>>> GetDisasterDevice()
public async Task<ActionResult<ApiResult<List<DeviceDisaster>>>> GetDisasterDevice([FromBody] FindDeviceDisaster fdd)
{
ApiResult<List<DeviceDisaster>> apiResult = new ApiResult<List<DeviceDisaster>>();
try
{
var sqlString = $@" SELECT * FROM device_disaster";
var fr = await backendRepository.GetAllAsync<DeviceDisaster>(sqlString);
var result = new List<DeviceDisaster>();
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<DeviceDisaster>(sqlString,fdd);
apiResult.Code = "0000";
apiResult.Data = fr;
apiResult.Data = result;
}
catch (Exception exception)
{

View File

@ -215,4 +215,8 @@ namespace FrontendWebApi.Models
public string device_number { get; set; }
}
public class FindDeviceDisaster
{
public string building_tag { get; set; }
}
}