2022-05-11 18:47:31 -04:00
|
|
|
package model
|
|
|
|
|
|
|
|
// PageInfo is the model used by Api Handlers and passed on to other parts
|
|
|
|
// of the application
|
|
|
|
type PageInfo struct {
|
2023-05-25 21:04:43 -04:00
|
|
|
Sort []Sort `json:"sort"`
|
|
|
|
Offset int `json:"offset"`
|
|
|
|
Limit int `json:"limit"`
|
|
|
|
Expand []string `json:"expand"`
|
2022-05-11 18:47:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Sort holds the sorting data
|
|
|
|
type Sort struct {
|
|
|
|
Field string `json:"field"`
|
|
|
|
Direction string `json:"direction"`
|
|
|
|
}
|
2023-05-29 00:19:17 -04:00
|
|
|
|
2023-07-18 21:52:47 -04:00
|
|
|
// GetSort ...
|
2023-05-29 00:19:17 -04:00
|
|
|
func (p *PageInfo) GetSort(def Sort) []Sort {
|
|
|
|
if p.Sort == nil {
|
|
|
|
return []Sort{def}
|
|
|
|
}
|
|
|
|
return p.Sort
|
|
|
|
}
|