feat: init repo

This commit is contained in:
Rogee
2025-01-09 19:11:01 +08:00
parent b9cc63fe8a
commit 1c7b603769
149 changed files with 20066 additions and 10 deletions

View File

@@ -0,0 +1,30 @@
package requests
import "github.com/samber/lo"
type Pager struct {
Pagination `json:",inline"`
Total int64 `json:"total"`
Items interface{} `json:"items"`
}
type Pagination struct {
Page int `json:"page" form:"page" query:"page"`
Limit int `json:"limit" form:"limit" query:"limit"`
}
func (filter *Pagination) Offset() int {
return (filter.Page - 1) * filter.Limit
}
func (filter *Pagination) Format() *Pagination {
if filter.Page <= 0 {
filter.Page = 1
}
if !lo.Contains([]int{10, 20, 50, 100}, filter.Limit) {
filter.Limit = 10
}
return filter
}