121 lines
1.6 KiB
Go
121 lines
1.6 KiB
Go
package sharding
|
|
|
|
const (
|
|
ValueOperaEqual = iota + 0x10
|
|
ValueOperaGreater
|
|
ValueOperaLess
|
|
ValueOperaRange
|
|
|
|
ValueTypeString = iota + 0x30
|
|
ValueTypeNumber
|
|
ValueTypeBoolean
|
|
ValueTypeNull
|
|
ValueTypeAny
|
|
)
|
|
|
|
type (
|
|
ColumnCondition struct {
|
|
Name string `json:"name"`
|
|
Value CondValue `json:"value"`
|
|
}
|
|
|
|
CondValue interface {
|
|
Type() int
|
|
Opera() int
|
|
Value() any
|
|
}
|
|
|
|
equalValue struct {
|
|
vType int
|
|
vData any
|
|
}
|
|
|
|
rangeValue struct {
|
|
vType int
|
|
vData any
|
|
}
|
|
|
|
greaterValue struct {
|
|
vType int
|
|
vData any
|
|
}
|
|
|
|
lessValue struct {
|
|
vType int
|
|
vData any
|
|
}
|
|
)
|
|
|
|
func (v *lessValue) Type() int {
|
|
return v.vType
|
|
}
|
|
|
|
func (v *lessValue) Opera() int {
|
|
return ValueOperaLess
|
|
}
|
|
|
|
func (v *lessValue) Value() any {
|
|
return v.vData
|
|
}
|
|
|
|
func (v *greaterValue) Type() int {
|
|
return v.vType
|
|
}
|
|
|
|
func (v *greaterValue) Opera() int {
|
|
return ValueOperaGreater
|
|
}
|
|
|
|
func (v *greaterValue) Value() any {
|
|
return v.vData
|
|
}
|
|
|
|
func (v *rangeValue) Type() int {
|
|
return v.vType
|
|
}
|
|
|
|
func (v *rangeValue) Opera() int {
|
|
return ValueOperaRange
|
|
}
|
|
|
|
func (v *rangeValue) Value() any {
|
|
return v.vData
|
|
}
|
|
|
|
func (v *equalValue) Type() int {
|
|
return v.vType
|
|
}
|
|
|
|
func (v *equalValue) Opera() int {
|
|
return ValueOperaEqual
|
|
}
|
|
|
|
func (v *equalValue) Value() any {
|
|
return v.vData
|
|
}
|
|
|
|
func newCondValue(vType int, op int, value any) CondValue {
|
|
switch op {
|
|
case ValueOperaGreater:
|
|
return &greaterValue{
|
|
vType: vType,
|
|
vData: value,
|
|
}
|
|
case ValueOperaLess:
|
|
return &lessValue{
|
|
vType: vType,
|
|
vData: value,
|
|
}
|
|
case ValueOperaRange:
|
|
return &rangeValue{
|
|
vType: vType,
|
|
vData: value,
|
|
}
|
|
default:
|
|
return &equalValue{
|
|
vType: vType,
|
|
vData: value,
|
|
}
|
|
}
|
|
}
|