FrontToBackend

master
nikkiing 2 years ago
parent ada4207336
commit 1e2868c77c
  1. 2
      pagination/v1/pagination.go
  2. 32
      pagination/v1/pagination_front.go

@ -4,6 +4,8 @@ import (
"math"
)
// 服务端用
const (
DefaultPage = 1
MinPageSize = 10

@ -0,0 +1,32 @@
package page
// 服务端用
const (
DefaultFrontPage = 1
MinFrontPageSize = 10
MaxFrontPageSize = 100
)
type PaginationFront struct {
Page int32 `json:"page"`
PerPage int32 `json:"per_page"`
Total int32 `json:"total"`
}
func FrontToBackend[T Integer](frontPage, frontPerPage T) (page, pageSize T) {
if frontPage < DefaultFrontPage {
frontPage = DefaultPage
}
if frontPerPage <= MinFrontPageSize {
frontPerPage = MinFrontPageSize
}
if frontPerPage >= MaxFrontPageSize {
frontPerPage = MaxPageSize
}
page = frontPage
pageSize = frontPerPage
return
}
Loading…
Cancel
Save