using Mapster; using MapsterMapper; using System; using System.Collections.Generic; namespace EntrustSettle.Model { /// /// 通用分页信息类 /// public class PageModel { /// /// 当前页标 /// public int page { get; set; } = 1; /// /// 总页数 /// public int pageCount => (int)Math.Ceiling((decimal)dataCount / PageSize); /// /// 数据总数 /// public int dataCount { get; set; } = 0; /// /// 每页大小 /// public int PageSize { set; get; } = 20; /// /// 返回数据 /// public List data { get; set; } public PageModel() { } public PageModel(int page, int dataCount, int pageSize, List data) { this.page = page; this.dataCount = dataCount; PageSize = pageSize; this.data = data; } public PageModel ConvertTo(bool isAdapt) { var model = new PageModel(page, dataCount, PageSize, default); if (isAdapt) { model.data = data.Adapt>(); } return model; } public PageModel ConvertTo(TypeAdapterConfig adapterConfig) { var model = new PageModel(page, dataCount, PageSize, default); var mapper = new Mapper(adapterConfig); model.data = mapper.Map>(data); return model; } } }