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