add missing file
This commit is contained in:
parent
80c06919f8
commit
0977cd3b1f
1 changed files with 15 additions and 0 deletions
15
internal/common/pagination.go
Normal file
15
internal/common/pagination.go
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
package common
|
||||||
|
|
||||||
|
type Pagination struct {
|
||||||
|
Page *int `json:"page"`
|
||||||
|
PerPage *int `json:"perPage"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p Pagination) OffsetPerPage(perPageDefault int) (offset int32, perPage int32) {
|
||||||
|
page := int32(DefaultIfNilOrZero(p.Page, 1))
|
||||||
|
perPage = int32(DefaultIfNilOrZero(p.PerPage, perPageDefault))
|
||||||
|
|
||||||
|
offset = (page - 1) * perPage
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
Loading…
Reference in a new issue