using System;
using System.Collections.Generic;
using System.Text;

namespace Nirvana.Common
{
    public class PageData<T>
    {
        /// <summary>
        /// 当前页码
        /// </summary>
        public int CurrentPage { get; set; }
        /// <summary>
        /// 总数
        /// </summary>
        public int TotalNum { get; set; }

        /// <summary>
        /// 实体对象
        /// </summary>
        public List<T> Items { get; set; }
        /// <summary>
        /// 总页数
        /// </summary>
        public int TotalPageCount { get; set; }

        public Object Total { get; set; }
    }

    public class PageDataAPI<T>
    {
        /// <summary>
        /// 页码
        /// </summary>
        public int pagesize { get; set; }
        /// <summary>
        /// 总页数
        /// </summary>
        public int totalpage { get; set; }
        /// <summary>
        /// 总数
        /// </summary>
        public int totalnum { get; set; }
        /// <summary>
        /// 项
        /// </summary>
        public List<T> items { get; set; }
    }

    /// <summary>
    /// 分页查询返回值
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class PageParms<T>
    {
        /// <summary>
        /// 当前页码
        /// </summary>
        public int page { get; set; }
        /// <summary>
        /// 总数
        /// </summary>
        public int totalnum { get; set; }
        /// <summary>
        /// 每页显示的数量
        /// </summary>
        public int limit { get; set; }

        /// <summary>
        /// 实体对象
        /// </summary>
        public List<T> Items { get; set; }
        /// <summary>
        /// 总页数
        /// </summary>
        public int totalpage
        {
            get
            {
                return this.totalnum == 0 ? 0 : Convert.ToInt32(Math.Ceiling(totalnum * 1.0 / limit));
            }
        }
    }

    /// <summary>
    /// 分页查询
    /// </summary>
    public class QueryParams
    {
        /// <summary>
        /// 排序方式,asc-正序,desc-倒序
        /// </summary>
        public string order { get; set; } = "desc";
        /// <summary>
        /// 排序字段
        /// </summary>
        public string sort { get; set; } = "createtime";
        /// <summary>
        /// 当前页
        /// </summary>
        public int offset { get; set; }
        /// <summary>
        /// 每页显示的数量
        /// </summary>
        public int limit { get; set; }

        /// <summary>
        /// 多条件查询参数
        /// </summary>
        public List<QueryConditional> queryParam { get; set; }
    }

    /// <summary>
    /// 分页查询的参数
    /// </summary>
    public class ParamQuery
    {
        /// <summary>
        /// 页数
        /// </summary>
        public int page { get; set; } = 1;
        /// <summary>
        /// 每页显示的数量
        /// </summary>
        public int pagesize { get; set; } = 10;

        /// <summary>
        /// 排序方式,asc-正序,desc-倒序
        /// </summary>
        public string order { get; set; } = "desc";
        /// <summary>
        /// 排序字段
        /// </summary>
        public string sort { get; set; } = "createtime";
        /// <summary>
        /// 关键字
        /// </summary>
        public string keyword { get; set; }
        /// <summary>
        /// 小程序appid
        /// </summary>
        public string appid { get; set; } = "";
        /// <summary>
        /// 设备类型
        /// </summary>
        public int devtype { get; set; } = 0;
    }
    /// <summary>
    /// 分页查询返回的值
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class ParamReturnData<T>
    {
        /// <summary>
        /// 当前页码
        /// </summary>
        public int page { get; set; }
        /// <summary>
        /// 总数
        /// </summary>
        public int totalnum { get; set; }
        /// <summary>
        /// 每页显示的数量
        /// </summary>
        public int pagesize { get; set; }

        /// <summary>
        /// 实体对象
        /// </summary>
        public List<T> items { get; set; }
        /// <summary>
        /// 总页数
        /// </summary>
        public int totalpage
        {
            get
            {
                return this.totalnum == 0 ? 0 : Convert.ToInt32(Math.Ceiling(totalnum * 1.0 / pagesize));
            }
        }
    }

}
