优化分页统一返回
This commit is contained in:
@@ -4,6 +4,10 @@
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Model\PagedInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AspectCore.Abstractions" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.7" />
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Infrastructure.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// 分页参数
|
||||
/// </summary>
|
||||
public class PagedInfo<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// 每页行数
|
||||
/// </summary>
|
||||
public int PageSize { get; set; } = 10;
|
||||
/// <summary>
|
||||
/// 当前页
|
||||
/// </summary>
|
||||
public int PageIndex { get; set; } = 1;
|
||||
/// <summary>
|
||||
/// 排序列
|
||||
/// </summary>
|
||||
//public string Sort { get; set; }
|
||||
/// <summary>
|
||||
/// 排序类型
|
||||
/// </summary>
|
||||
//public string SortType { get; set; }
|
||||
/// <summary>
|
||||
/// 总记录数
|
||||
/// </summary>
|
||||
public int TotalCount { get; set; }
|
||||
/// <summary>
|
||||
/// 总页数
|
||||
/// </summary>
|
||||
//public int TotalPage
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// if (TotalCount > 0)
|
||||
// {
|
||||
// return TotalCount % this.PageSize == 0 ? TotalCount / this.PageSize : TotalCount / this.PageSize + 1;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return 0;
|
||||
// }
|
||||
// }
|
||||
// set { }
|
||||
//}
|
||||
public int TotalPage { get; set; }
|
||||
public List<T> Result { get; set; }
|
||||
|
||||
public PagedInfo()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public PagedInfo(List<T> source, int pageIndex, int pageSize)
|
||||
{
|
||||
PageIndex = pageIndex;
|
||||
PageSize = pageSize;
|
||||
TotalCount = source.Count;
|
||||
TotalPage = (int)Math.Ceiling(TotalCount / (double)PageSize);//计算总页数
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user