using JSMachine.WMS.Domain.IRepository; using JSMachine.WMS.Domain.Repository; using System.Collections.Generic; namespace JSMachine.WMS.Domain.Entity { /// /// 通用分页查询结果,封装分页统计信息和当前页数据。 /// /// 页数据的元素类型。 public class PagedResult { public static readonly PagedResult EmptyPagedResult = new PagedResult(0, 0, 0, 0, null); #region Public Properties /// /// 总记录数 /// public int TotalRecords { get; set; } /// /// 总页数 /// public int TotalPages { get; set; } /// /// 每页的记录数 /// public int PageSize { get; set; } /// /// 当前页码 /// public int PageNumber { get; set; } /// /// 获取或设置当前页码的记录 /// public List PageData { get; set; } #endregion /// /// 创建空的分页结果,页数据初始化为空集合。 /// public PagedResult() { this.PageData = new List(); } /// /// 使用完整分页统计信息创建结果。 /// /// 符合条件的总记录数。 /// 总页数。 /// 每页记录数。 /// 当前页码。 /// 当前页数据。 public PagedResult(int totalRecords, int totalPages, int pageSize, int pageNumber, List data) { this.TotalPages = totalPages; this.TotalRecords = totalRecords; this.PageSize = pageSize; this.PageNumber = pageNumber; this.PageData = data; } /// /// 根据总记录数和分页参数计算总页数并创建结果。 /// /// 符合条件的总记录数。 /// 每页记录数。 /// 当前页码。 /// 当前页数据。 public PagedResult(int totalRecords, int pageSize, int pageNumber, List data) { if (pageSize > 0) { this.TotalPages = totalRecords % pageSize == 0 ? totalRecords / pageSize : totalRecords / pageSize + 1; } this.TotalRecords = totalRecords; this.PageSize = pageSize; this.PageNumber = pageNumber; this.PageData = data; } } }