30 lines
624 B
Go
30 lines
624 B
Go
package crud
|
|
|
|
type ListData struct {
|
|
Limit int `json:"limit,omitempty;query:limit"`
|
|
Page int `json:"page,omitempty;query:page"`
|
|
TotalRows int64 `json:"total_rows"`
|
|
TotalPages int `json:"total_pages"`
|
|
Rows interface{} `json:"rows"`
|
|
Order string `json:"order"`
|
|
Sort string `json:"sort"`
|
|
}
|
|
|
|
func (p *ListData) GetOffset() int {
|
|
return (p.GetPage() - 1) * p.GetLimit()
|
|
}
|
|
|
|
func (p *ListData) GetLimit() int {
|
|
if p.Limit == 0 {
|
|
p.Limit = 10
|
|
}
|
|
return p.Limit
|
|
}
|
|
|
|
func (p *ListData) GetPage() int {
|
|
if p.Page == 0 {
|
|
p.Page = 1
|
|
}
|
|
|
|
return p.Page
|
|
}
|