1 Star 1 Fork 0

窦雪峰 / go-utils

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
page.go 645 Bytes
一键复制 编辑 原始数据 按行查看 历史
窦雪峰 提交于 2021-02-26 18:45 . carbon time add new page multidb
/**
* @User: douxuefeng
* @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)))
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/douxuefeng/go-utils.git
git@gitee.com:douxuefeng/go-utils.git
douxuefeng
go-utils
go-utils
v0.1.5

搜索帮助

344bd9b3 5694891 D2dac590 5694891