f5/pagequery.go
2023-08-20 10:58:44 +08:00

133 lines
2.1 KiB
Go

package f5
/*
import (
"fmt"
)
*/
type LinkOp int32
const (
LK_AND LinkOp = iota
LK_OR
)
type QueryCond int32
const (
QC_LIKE QueryCond = iota
QC_EQ
QC_LT
QC_LE
QC_GT
QC_GE
QC_CUSTOM
)
type pageQuery struct {
}
type PageQueryFilter interface {
And() PageQueryFilter
Or() PageQueryFilter
Not() PageQueryFilter
GenSql() string
}
type PageQueryOne struct {
linkOp LinkOp
not bool
fieldName string
cond QueryCond
ignoreEmpty bool
val string
}
type PageQueryComp struct {
linkOp LinkOp
not bool
subFilters []*PageQueryOne
}
type PageQueryParam struct {
Filter []PageQueryFilter
OrderBy string
}
func (this *PageQueryParam) genSql() string {
sql := " "
/*
for _, field := range this.Filter {
}*/
sql += " " + this.OrderBy + " "
return sql
}
func (this *pageQuery) Like(fieldName string, val string) *PageQueryOne {
f := &PageQueryOne{
cond: QC_LIKE,
fieldName: fieldName,
val: val}
return f
}
func (this *pageQuery) EQ(fieldName string, val string) *PageQueryOne {
f := &PageQueryOne{
cond: QC_EQ,
fieldName: fieldName,
val: val}
return f
}
func (this *pageQuery) LT(fieldName string, val string) *PageQueryOne {
f := &PageQueryOne{
cond: QC_LT,
fieldName: fieldName,
val: val}
return f
}
func (this *pageQuery) LE(fieldName string, val string) *PageQueryOne {
f := &PageQueryOne{
cond: QC_LE,
fieldName: fieldName,
val: val}
return f
}
func (this *pageQuery) GT(fieldName string, val string) *PageQueryOne {
f := &PageQueryOne{
cond: QC_GT,
fieldName: fieldName,
val: val}
return f
}
func (this *pageQuery) GE(fieldName string, val string) *PageQueryOne {
f := &PageQueryOne{
cond: QC_GE,
fieldName: fieldName,
val: val}
return f
}
func (this *pageQuery) Custom(fieldName string, val string) *PageQueryOne {
f := &PageQueryOne{
cond: QC_CUSTOM,
fieldName: fieldName,
val: val}
return f
}
func (this *pageQuery) Comp(subFilters []*PageQueryOne) *PageQueryComp {
f := &PageQueryComp{
subFilters: subFilters}
return f
}
func (this *PageQueryOne) IgnoreEmpy() *PageQueryOne {
this.ignoreEmpty = true
return this
}