Files
rootandClaude Opus 5 8679200f41 Initial commit
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 13:57:10 +08:00

58 lines
810 B
Go

package searcher
// Opter Opter
type Opter interface {
SetSkip(v int64) Opter
Skip() int64
SetLimit(v int64) Opter
Limit() int64
SetSort(key string, v int64) Opter
Sort() D
}
type Option struct {
skip *int64
limit *int64
sort D
}
const MaxLimit = 50
const MinLimit = 1
func (o *Option) Skip() int64 {
if o.skip == nil {
return 0
}
return *o.skip
}
func (o *Option) SetSkip(v int64) Opter {
o.skip = &v
return o
}
func (o *Option) Limit() int64 {
if o.limit == nil {
return MinLimit
}
if *o.limit > MaxLimit {
return MaxLimit
}
return *o.limit
}
func (o *Option) SetLimit(v int64) Opter {
o.limit = &v
return o
}
func (o *Option) Sort() D {
return o.sort
}
func (o *Option) SetSort(key string, v int64) Opter {
o.sort = append(o.sort, E{Key: key, Value: v})
return o
}