Documentation
¶
Index ¶
- Constants
- type BaseInfoFilter
- type Filter
- type FilterGroup
- type FindOption
- func (fo *FindOption) WithBusinessId(id string) *FindOption
- func (fo *FindOption) WithCacheTTL(ttl time.Duration) *FindOption
- func (fo *FindOption) WithExcludeFields(fields ...string) *FindOption
- func (fo *FindOption) WithIncludeFields(fields ...string) *FindOption
- func (fo *FindOption) WithNoCache() *FindOption
- func (fo *FindOption) WithShopId(id string) *FindOption
- func (fo *FindOption) WithTablePrefix(prefix string) *FindOption
- type Operator
- type OrderBy
- type PageBean
- type Param
- func (p *Param) AddEQ(field string, value interface{}) *Param
- func (p *Param) AddEndsWith(field string, value string) *Param
- func (p *Param) AddFilter(field string, operator Operator, value interface{}) *Param
- func (p *Param) AddFindInSet(field string, values ...string) *Param
- func (p *Param) AddGT(field string, value interface{}) *Param
- func (p *Param) AddGTE(field string, value interface{}) *Param
- func (p *Param) AddHaving(clause string) *Param
- func (p *Param) AddIn(field string, values ...interface{}) *Param
- func (p *Param) AddLT(field string, value interface{}) *Param
- func (p *Param) AddLTE(field string, value interface{}) *Param
- func (p *Param) AddLike(field string, value string) *Param
- func (p *Param) AddNEQ(field string, value interface{}) *Param
- func (p *Param) AddOrEQ(field string, value interface{}) *Param
- func (p *Param) AddOrFilter(field string, operator Operator, value interface{}) *Param
- func (p *Param) AddOrGT(field string, value interface{}) *Param
- func (p *Param) AddOrGTE(field string, value interface{}) *Param
- func (p *Param) AddOrIn(field string, values ...interface{}) *Param
- func (p *Param) AddOrLT(field string, value interface{}) *Param
- func (p *Param) AddOrLTE(field string, value interface{}) *Param
- func (p *Param) AddOrLike(field string, value string) *Param
- func (p *Param) AddOrNEQ(field string, value interface{}) *Param
- func (p *Param) AddOrder(field string, order string) *Param
- func (p *Param) AddOrderAsc(field string) *Param
- func (p *Param) AddOrderDesc(field string) *Param
- func (p *Param) AddStartsWith(field string, value string) *Param
- func (p *Param) AddTimeRange(field string, startTime, endTime interface{}) *Param
- func (p *Param) BuildWhereClause() (string, []interface{})
- func (p *Param) SetDistinct(distinct bool) *Param
- func (p *Param) SetPage(page int, pageSize int) *Param
- func (p *Param) SetSelectFields(fields ...string) *Param
Constants ¶
View Source
const ( QP_LT = "lt" // 小于 QP_GT = "gt" // 大于 QP_LTE = "lte" // 小于等于 QP_GTE = "gte" // 大于等于 QP_EQ = "eq" // 等于 QP_NEQ = "neq" // 不等于 QP_LK = "lk" // LIKE )
比较操作符常量(兼容 go-core)
View Source
const ( QP_PD = "pd" // 降序(descending) QP_PA = "pa" // 升序(ascending) )
排序操作符常量(兼容 go-core)
View Source
const ( QP_ORLK = "orlk" // OR LIKE QP_ORLT = "orlt" // OR LT QP_ORGT = "orgt" // OR GT )
或条件操作符常量(兼容 go-core)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseInfoFilter ¶
type BaseInfoFilter struct {
DBField string // 数据库字段名
Values []interface{} // 过滤值列表
ExactMatch bool // 是否精确匹配(默认 false 表示 LIKE)
AllRegex bool // 是否全部匹配正则(所有值都包含)
}
BaseInfoFilter 基础过滤信息 - 借鉴 go-core 设计
func NewBaseInfoFilter ¶
func NewBaseInfoFilter(field string, values []interface{}) *BaseInfoFilter
NewBaseInfoFilter 创建基础过滤信息
type Filter ¶
type Filter struct {
Field string // 字段名
Operator Operator // 操作符
Value interface{} // 值(可能是单个值或数组)
Logic string // AND / OR
}
Filter 单个过滤条件
type FilterGroup ¶
type FilterGroup struct {
Filters []*Filter
Groups []*FilterGroup
Logic string // AND / OR
}
FilterGroup 过滤组(支持嵌套)
type FindOption ¶
type FindOption struct {
BusinessId string // 业务 ID
ShopId string // 店铺 ID
TablePrefix string // 表名前缀
ExcludeField bool // 是否排除字段
ExcludeFields []string // 排除字段列表
IncludeFields []string // 包含字段列表
NoCache bool // 是否不使用缓存
CacheTTL time.Duration // 缓存过期时间
}
FindOption 查询选项 - 借鉴 go-core 设计
func (*FindOption) WithBusinessId ¶
func (fo *FindOption) WithBusinessId(id string) *FindOption
WithBusinessId 设置业务 ID
func (*FindOption) WithCacheTTL ¶
func (fo *FindOption) WithCacheTTL(ttl time.Duration) *FindOption
WithCacheTTL 设置缓存 TTL
func (*FindOption) WithExcludeFields ¶
func (fo *FindOption) WithExcludeFields(fields ...string) *FindOption
WithExcludeFields 设置排除字段
func (*FindOption) WithIncludeFields ¶
func (fo *FindOption) WithIncludeFields(fields ...string) *FindOption
WithIncludeFields 设置包含字段
func (*FindOption) WithShopId ¶
func (fo *FindOption) WithShopId(id string) *FindOption
WithShopId 设置店铺 ID
func (*FindOption) WithTablePrefix ¶
func (fo *FindOption) WithTablePrefix(prefix string) *FindOption
WithTablePrefix 设置表名前缀
type Operator ¶
type Operator string
Operator 查询操作符
const ( OP_EQ Operator = "=" // 等于 OP_NEQ Operator = "!=" // 不等于 OP_GT Operator = ">" // 大于 OP_GTE Operator = ">=" // 大于等于 OP_LT Operator = "<" // 小于 OP_LTE Operator = "<=" // 小于等于 OP_LIKE Operator = "LIKE" // 模糊匹配 OP_IN Operator = "IN" // 包含 OP_BETWEEN Operator = "BETWEEN" // 范围 OP_IS_NULL Operator = "IS NULL" // 为空 OP_FIND_IN_SET Operator = "FIND_IN_SET" // MySQL FIND_IN_SET )
type PageBean ¶
type PageBean struct {
Page int `json:"page"` // 当前页码
PageSize int `json:"page_size"` // 每页数量
Total int64 `json:"total"` // 总数
Pages int `json:"pages"` // 总页数
Rows interface{} `json:"rows"` // 数据行
}
PageBean 分页响应 - 借鉴 go-core 设计
type Param ¶
type Param struct {
Filters []*Filter // 过滤条件
FilterGroups []*FilterGroup // 过滤组(支持 AND/OR 混合)
TimeRanges map[string][2]interface{} // 时间范围 field -> [startTime, endTime]
FindInSets map[string][]string // FIND_IN_SET 条件
Orders []*OrderBy // 排序条件
Page int // 页码(从 1 开始)
PageSize int // 每页数量
Offset int // 偏移量(与 Page 互斥)
Limit int // 限制数量
Distinct bool // 是否去重
SelectFields []string // 指定查询字段
HavingClauses []string // HAVING 子句
}
Param 高级查询参数 - 支持复杂过滤、排序、分页
func (*Param) AddEndsWith ¶
AddEndsWith 添加后缀匹配 LIKE 过滤
func (*Param) AddFindInSet ¶
AddFindInSet 添加 FIND_IN_SET 过滤(MySQL 特定)
func (*Param) AddOrFilter ¶
AddOrFilter 添加 OR 过滤条件
func (*Param) AddStartsWith ¶
AddStartsWith 添加前缀匹配 LIKE 过滤
func (*Param) AddTimeRange ¶
AddTimeRange 添加时间范围过滤
func (*Param) BuildWhereClause ¶
BuildWhereClause 构建 WHERE 子句 - 返回 WHERE SQL 片段和参数
func (*Param) SetSelectFields ¶
SetSelectFields 设置查询字段
Click to show internal directories.
Click to hide internal directories.