2024-10-16 15:22:09 +08:00
|
|
|
|
namespace LFlow.Base.Utils;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 返回结果包装 (分页)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
|
|
[Serializable]
|
|
|
|
|
|
public class PagedApiResult<T> : ApiResult<T> where T : class, new()
|
|
|
|
|
|
{
|
|
|
|
|
|
public new T? Data
|
|
|
|
|
|
{
|
|
|
|
|
|
get; set;
|
|
|
|
|
|
}
|
|
|
|
|
|
public int TotalCount
|
|
|
|
|
|
{
|
|
|
|
|
|
get; set;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int PageIndex
|
|
|
|
|
|
{
|
|
|
|
|
|
get; set;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int PageSize
|
|
|
|
|
|
{
|
|
|
|
|
|
get; set;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public PagedApiResult()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-31 10:36:17 +08:00
|
|
|
|
public PagedApiResult(bool success, string message, int code, T? data, int totalCount, int pageIndex, int pageSize)
|
2024-10-16 15:22:09 +08:00
|
|
|
|
{
|
|
|
|
|
|
Success = success;
|
|
|
|
|
|
Message = message;
|
2024-10-18 11:24:31 +08:00
|
|
|
|
Code = code;
|
2024-10-16 15:22:09 +08:00
|
|
|
|
Data = data;
|
|
|
|
|
|
TotalCount = totalCount;
|
|
|
|
|
|
PageIndex = pageIndex;
|
|
|
|
|
|
PageSize = pageSize;
|
|
|
|
|
|
}
|
2024-10-31 10:36:17 +08:00
|
|
|
|
public static PagedApiResult<T> SuccessResult(T? data, int totalCount, int pageIndex, int pageSize, string message = "操作成功", int code = 200)
|
2024-10-18 11:24:31 +08:00
|
|
|
|
{
|
|
|
|
|
|
return new PagedApiResult<T>(true, message, code, data, totalCount, pageIndex, pageSize);
|
|
|
|
|
|
}
|
2024-10-31 10:36:17 +08:00
|
|
|
|
public static new PagedApiResult<T>? FailResult(string message = "操作失败", int errCode = 500)
|
2024-10-18 11:24:31 +08:00
|
|
|
|
{
|
2024-10-29 14:40:07 +08:00
|
|
|
|
return new PagedApiResult<T>(false, message, errCode, null, 0, 0, 0);
|
2024-10-18 11:24:31 +08:00
|
|
|
|
}
|
2024-10-16 15:22:09 +08:00
|
|
|
|
}
|