mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-24 19:38:35 +08:00
【修改】k8s 配置
This commit is contained in:
28
apps/devops/services/k8s/dataselect/pagination.go
Normal file
28
apps/devops/services/k8s/dataselect/pagination.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package dataselect
|
||||
|
||||
// By default backend pagination will not be applied.
|
||||
var NoPagination = NewPaginationQuery(-1, -1)
|
||||
|
||||
// No items will be returned
|
||||
var EmptyPagination = NewPaginationQuery(0, 0)
|
||||
|
||||
// Returns 10 items from page 1
|
||||
var DefaultPagination = NewPaginationQuery(10, 0)
|
||||
|
||||
// NewPaginationQuery return pagination query structure based on given parameters
|
||||
func NewPaginationQuery(itemsPerPage, page int) *PaginationQuery {
|
||||
return &PaginationQuery{itemsPerPage, page}
|
||||
}
|
||||
|
||||
// GetPaginationSettings based on number of items and pagination query parameters returns start
|
||||
// and end index that can be used to return paginated list of items.
|
||||
func (p *PaginationQuery) GetPaginationSettings(itemsCount int) (startIndex int, endIndex int) {
|
||||
startIndex = p.ItemsPerPage * p.Page
|
||||
endIndex = startIndex + p.ItemsPerPage
|
||||
|
||||
if endIndex > itemsCount {
|
||||
endIndex = itemsCount
|
||||
}
|
||||
|
||||
return startIndex, endIndex
|
||||
}
|
||||
Reference in New Issue
Block a user