根据新需求更改
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using MoviconWebApi.Entities;
|
||||
using MoviconWebApi.Entities;
|
||||
|
||||
namespace MoviconWebApi.API.ClearDataQrApi
|
||||
{
|
||||
@@ -13,7 +13,7 @@ namespace MoviconWebApi.API.ClearDataQrApi
|
||||
/// <param name="request">查询请求参数</param>
|
||||
/// <param name="freeSql">FreeSql实例</param>
|
||||
/// <returns>清洗数据列表</returns>
|
||||
public static async Task<List<ClearDataQrResponse>> GetClearDataByQr(
|
||||
public static async Task<(List<ClearDataQrResponse> Data, long Total)> GetClearDataByQr(
|
||||
ClearDataQrRequest request,
|
||||
IFreeSql freeSql)
|
||||
{
|
||||
@@ -34,11 +34,19 @@ namespace MoviconWebApi.API.ClearDataQrApi
|
||||
query = query.Where(x => x.part_qrid == request.PartQRCode);
|
||||
}
|
||||
|
||||
// 按创建时间降序排序
|
||||
query = query.OrderByDescending(x => x.CreateTime);
|
||||
// 统计总数
|
||||
var total = await query.CountAsync();
|
||||
|
||||
// 执行查询并映射到响应模型
|
||||
var result = await query.ToListAsync(x => new ClearDataQrResponse
|
||||
// 参数兜底
|
||||
var pageNo = request.PageNo <= 0 ? 1 : request.PageNo;
|
||||
var pageSize = request.PageSize <= 0 ? 100 : request.PageSize;
|
||||
if (pageSize > 100) pageSize = 100;
|
||||
|
||||
// 按创建时间降序排序 + 分页 + 映射
|
||||
var result = await query
|
||||
.OrderByDescending(x => x.CreateTime)
|
||||
.Page(pageNo, pageSize)
|
||||
.ToListAsync(x => new ClearDataQrResponse
|
||||
{
|
||||
DeviceCode = x.DeviceCode,
|
||||
DeviceName = x.DeviceName,
|
||||
@@ -71,7 +79,7 @@ namespace MoviconWebApi.API.ClearDataQrApi
|
||||
CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")
|
||||
});
|
||||
|
||||
return result;
|
||||
return (result ?? new List<ClearDataQrResponse>(), total);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user