Files
leanote/app/info/common.go

23 lines
436 B
Go
Raw Normal View History

2014-05-07 13:06:24 +08:00
package info
import (
"math"
2014-05-07 13:06:24 +08:00
)
// 分页数据
type Page struct {
2015-11-13 17:58:41 +08:00
CurPage int // 当前页码
TotalPage int // 总页
2014-11-12 17:32:03 +08:00
PerPageSize int
2015-11-13 17:58:41 +08:00
Count int // 总记录数
List interface{}
}
func NewPage(page, perPageSize, count int, list interface{}) Page {
totalPage := 0
if count > 0 {
totalPage = int(math.Ceil(float64(count) / float64(perPageSize)))
}
2014-11-12 17:32:03 +08:00
return Page{page, totalPage, perPageSize, count, list}
}