namespace Atomx.Common.Models
{
    public class PagingList<T>
    {
        /// <summary>
        /// 总记录数
        /// </summary>
        public int Count { get; set; }

        /// <summary>
        /// 分页大小
        /// </summary>
        public int Size { get; set; }

        /// <summary>
        /// 当前页数
        /// </summary>
        public int Index { get; set; }

        /// <summary>
        /// 表格数据
        /// </summary>
        public List<T> Items { get; set; } = new List<T>();

        /// <summary>
        /// 总页数
        /// </summary>
        public int Pages
        {
            get
            {
                var total = 1;
                if (Count > 0)
                {
                    total = Count / Size;
                    if (Count % Size > 0)
                    {
                        total++;
                    }
                }
                return total;
            }
        }
    }
}
