package page

import "math"

type PageInfo struct {
	LatestId int64
	Current  int
	PageSize int
	Total    int64
}
type PageResult struct {
	Page Page
	Data interface{}
}
type Page struct {
	LatestId  int64 `json:"latestId,omitempty"`
	Current   int   `json:"current"`
	PageSize  int   `json:"pageSize"`
	Total     int64 `json:"total"`
	TotalPage int   `json:"totalPage"`
}

func StartIndex(page, pagesize int) int {
	if page > 1 {
		return (page - 1) * pagesize
	}
	return 0
}

func TotalPages(total int64, pagesize int) int {
	return int(math.Ceil(float64(total) / float64(pagesize)))
}
func (p *PageInfo) Reset() {
	p.Current = 0
	p.PageSize = 0
	p.LatestId = 0
}
