12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using Ant.Core.WebApi.Enum;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Ant.Core.WebApi.Model
- {
- public class PagedApiResult<T>: ApiResult<List<T>>
- {
- public PagedApiResult(ApiStatusCode code, string message = null) : base(code, message)
- {
- }
- /// <summary>
- /// 兼容使用skiplimit查询的方式,自动计算pageindex
- /// </summary>
- /// <param name="datas"></param>
- /// <param name="total"></param>
- /// <param name="skip"></param>
- /// <param name="limit"></param>
- public PagedApiResult(List<T> datas, int total, int skip, int limit) : base(datas)
- {
- this.Pager = new Pager
- {
- Total = total,
- PageSize = limit,
- PageIndex = limit == 0 ? 1 : (skip / limit) + 1
- };
- }
- /// <summary>
- /// 分页信息
- /// </summary>
- public Pager Pager { set; get; } = new Pager();
- }
- public class Pager
- {
- public int PageIndex { set; get; }
- public int PageSize { set; get; }
- public int Total { set; get; }
- }
- }
|