根据新需求更改
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using Azure;
|
||||
using Azure;
|
||||
using FastEndpoints;
|
||||
using MoviconWebApi.Common;
|
||||
using MoviconWebApi.Entities;
|
||||
@@ -35,12 +35,33 @@ namespace MoviconWebApi.API.DeviceAlarmApi
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await DeviceAlarmData.GetDeviceAlarmList(_freeSql, req);
|
||||
Response = ApiResponse<List<DeviceAlarmResponse>>.Success(data, "success");
|
||||
// 参数兜底
|
||||
if (req.PageNo <= 0) req.PageNo = 1;
|
||||
if (req.PageSize <= 0) req.PageSize = 100;
|
||||
if (req.PageSize > 100) req.PageSize = 100;
|
||||
|
||||
var listResult = await DeviceAlarmData.GetDeviceAlarmList(_freeSql, req);
|
||||
var items = listResult.Item1;
|
||||
var total = listResult.Item2;
|
||||
|
||||
var resp = ApiResponse<List<DeviceAlarmResponse>>.Success(
|
||||
items ?? new List<DeviceAlarmResponse>(),
|
||||
(items != null && items.Count > 0) ? "请求成功" : "暂无数据");
|
||||
|
||||
resp.pagination = new MoviconWebApi.Common.Pagination
|
||||
{
|
||||
total = total,
|
||||
count = items?.Count ?? 0,
|
||||
pageNo = req.PageNo,
|
||||
totalPage = req.PageSize > 0 ? (int)Math.Ceiling((double)total / req.PageSize) : 0,
|
||||
pageSize = req.PageSize
|
||||
};
|
||||
|
||||
Response = resp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Response = ApiResponse<List<DeviceAlarmResponse>>.Error("500", $"获取数据失败: {ex.Message}");
|
||||
Response = ApiResponse<List<DeviceAlarmResponse>>.Error("500", $"获取数据失败: {ex.Message}", new List<DeviceAlarmResponse>());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,7 +94,9 @@ namespace MoviconWebApi.API.DeviceAlarmApi
|
||||
{
|
||||
try
|
||||
{
|
||||
var (items, total) = await DeviceAlarmData.GetDeviceAlarmPagedList(_freeSql, req);
|
||||
var result = await DeviceAlarmData.GetDeviceAlarmPagedList(_freeSql, req);
|
||||
var items = result.Items;
|
||||
var total = result.Total;
|
||||
var pagedResponse = new DeviceAlarmPagedResponse
|
||||
{
|
||||
Items = items,
|
||||
|
||||
Reference in New Issue
Block a user