add models and jwt
This commit is contained in:
30
serializers/pagination.go
Normal file
30
serializers/pagination.go
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
@Time : 2020/7/16 23:44
|
||||
@Author : xuyiqing
|
||||
@File : common.py
|
||||
*/
|
||||
|
||||
package serializers
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type Pager struct {
|
||||
Page int `json:"page" form:"page"`
|
||||
PageSize int `json:"pageSize" form:"pageSize"`
|
||||
OffSet int `json:"-"`
|
||||
Total int `json:"total"`
|
||||
MaxPage int `json:"maxPage"`
|
||||
}
|
||||
|
||||
func (p *Pager) InitPager(ctx *gin.Context) {
|
||||
p.Page, _ = strconv.Atoi(ctx.DefaultQuery("page", "1"))
|
||||
p.PageSize, _ = strconv.Atoi(ctx.DefaultQuery("pageSize", "10"))
|
||||
p.OffSet = (p.Page - 1) * p.PageSize
|
||||
}
|
||||
|
||||
func (p *Pager) GetPager() {
|
||||
p.MaxPage = int(p.Total / p.PageSize) + 1
|
||||
}
|
||||
Reference in New Issue
Block a user