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 ¶
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 ¶
TimeWindowQuery 是 HTTP 层 binding form。 handler 嵌入它即可自动绑定 ?start=&end=。
func (TimeWindowQuery) ToTimeWindow ¶
func (q TimeWindowQuery) ToTimeWindow() TimeWindow
ToTimeWindow 把 query 形式适配回 DAO 形式。
Click to show internal directories.
Click to hide internal directories.