2022-05-11 22:47:31 +00: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-26 01:04:43 +00:00
|
|
|
Sort []Sort `json:"sort"`
|
|
|
|
Offset int `json:"offset"`
|
|
|
|
Limit int `json:"limit"`
|
|
|
|
Expand []string `json:"expand"`
|
2022-05-11 22:47:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Sort holds the sorting data
|
|
|
|
type Sort struct {
|
|
|
|
Field string `json:"field"`
|
|
|
|
Direction string `json:"direction"`
|
|
|
|
}
|
2023-05-29 04:19:17 +00:00
|
|
|
|
|
|
|
// TableName overrides the table name used by gorm
|
|
|
|
func (p *PageInfo) GetSort(def Sort) []Sort {
|
|
|
|
if p.Sort == nil {
|
|
|
|
return []Sort{def}
|
|
|
|
}
|
|
|
|
return p.Sort
|
|
|
|
}
|