listfilter

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRangeOutOfBounds = errors.New("range out of bounds")

ErrRangeOutOfBounds 在窗口超出 maxDays 时返回。 API 层翻译为 400 RangeOutOfBounds。

Functions

This section is empty.

Types

type TimeWindow

type TimeWindow struct {
	Start int64 // unix sec, inclusive; 0 = no lower bound
	End   int64 // unix sec, exclusive; 0 = no upper bound
}

TimeWindow 是事件型 DAO 共享的时间范围。Start/End 都是 unix 秒。 0 表示该侧未设置(no bound)。

func (TimeWindow) Apply

func (w TimeWindow) Apply(db *gorm.DB, col string) *gorm.DB

Apply 把 TimeWindow 应用到 gorm query 上的时间列 col。 Start=0 或 End=0 跳过对应的 WHERE clause(no-op)。

func (TimeWindow) Days

func (w TimeWindow) Days() int

Days 返回 [Start, End) 跨多少天,向上取整。End ≤ Start 返回 0。

func (TimeWindow) Validate

func (w TimeWindow) Validate(maxDays int) error

Validate 检查窗口是否超过 maxDays。maxDays ≤ 0 表示不限。

type TimeWindowQuery

type TimeWindowQuery struct {
	Start int64 `form:"start"`
	End   int64 `form:"end"`
}

TimeWindowQuery 是 HTTP 层 binding form。 handler 嵌入它即可自动绑定 ?start=&end=。

func (TimeWindowQuery) ToTimeWindow

func (q TimeWindowQuery) ToTimeWindow() TimeWindow

ToTimeWindow 把 query 形式适配回 DAO 形式。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL