This commit is contained in:
Putoo
2026-05-29 19:06:51 +08:00
parent 69ae1e3174
commit bd1535aee9
48 changed files with 1571 additions and 133 deletions

View File

@@ -0,0 +1,27 @@
namespace Application.Service.Pub;
public class PageExtend
{
/// <summary>
/// List 通用分页
/// </summary>
/// <param name="list">数据源</param>
/// <param name="pageIndex">当前页码从1开始</param>
/// <param name="pageSize">每页条数</param>
/// <returns>当前页数据</returns>
public static List<T> GetPageList<T>(List<T> list, int pageIndex, int pageSize)
{
// 空值保护
if (list == null || list.Count == 0)
return new List<T>();
// 页码最小为 1
pageIndex = pageIndex < 1 ? 1 : pageIndex;
// 分页核心
return list
.Skip((pageIndex - 1) * pageSize)
.Take(pageSize)
.ToList();
}
}