Files
HouYunFei 472bf8b732 first commit
Co-Authored-By: Codex <noreply@openai.com>
2026-05-19 19:50:36 +08:00

30 lines
437 B
Go

package model
const MaxPageSize = 500
// Query 列表筛选和分页参数。
type Query struct {
Keyword string
Tags []string
Category string
Type string
Page int
PageSize int
}
func (q *Query) Normalize() {
if q.Page < 1 {
q.Page = 1
}
if q.PageSize < 1 {
q.PageSize = 20
}
if q.PageSize > MaxPageSize {
q.PageSize = MaxPageSize
}
}
func (q *Query) Offset() int {
return (q.Page - 1) * q.PageSize
}