1 Star 0 Fork 1

Yietion / go-utils

forked from 可乐烛光烟 / go-utils 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
page.go 687 Bytes
一键复制 编辑 原始数据 按行查看 历史
可乐烛光烟 提交于 2022-11-09 00:21 . Initial commit
/**
* @User: rysa
* @Created:2021/2/9 12:01 上午
* @File: page
* @Desc:
*/
package go_utils
import "math"
type Page struct {
Total int64 `json:"total"`
CurrentPage int `json:"current_page"`
PerPage int `json:"per_page"`
LastPage int `json:"last_page"`
Data interface{} `json:"data"`
}
func NewPage(total int64, currentPage, perPage int, data interface{}) *Page {
return &Page{
Total: total,
CurrentPage: currentPage,
PerPage: perPage,
LastPage: lastPage(total, perPage),
Data: data,
}
}
func lastPage(total int64, perPage int) int {
return int(math.Ceil(float64(total) / float64(perPage)))
}
1
https://gitee.com/yietion/go-utils.git
git@gitee.com:yietion/go-utils.git
yietion
go-utils
go-utils
master

搜索帮助