|
@@ -12,8 +12,8 @@ func parseCondition(m json.Map, index int) (ICondition, error) {
|
|
|
}
|
|
|
cond := _condition{
|
|
|
field: m.String("field", ""),
|
|
|
- logic: _conditionLogic(m.String("logic", "")),
|
|
|
- operator: _conditionOperator(m.String("operator", "")),
|
|
|
+ logic: ConditionLogic(m.String("logic", "")),
|
|
|
+ operator: ConditionOperator(m.String("operator", "")),
|
|
|
value: m["value"],
|
|
|
}
|
|
|
if !cond.IsValid() {
|
|
@@ -34,11 +34,14 @@ func parseCondition(m json.Map, index int) (ICondition, error) {
|
|
|
|
|
|
type ICondition interface {
|
|
|
Field() string
|
|
|
+ Logic() ConditionLogic
|
|
|
+ Operator() ConditionOperator
|
|
|
+ Value() any
|
|
|
}
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
-type _conditionOperator string
|
|
|
+type ConditionOperator string
|
|
|
|
|
|
const (
|
|
|
OperatorEqual = "="
|
|
@@ -50,7 +53,7 @@ const (
|
|
|
OperatorLike = "like"
|
|
|
)
|
|
|
|
|
|
-func (s _conditionOperator) IsValid() bool {
|
|
|
+func (s ConditionOperator) IsValid() bool {
|
|
|
switch s {
|
|
|
case OperatorEqual:
|
|
|
case OperatorNotEqual:
|
|
@@ -73,9 +76,9 @@ const (
|
|
|
LogicAND = "and"
|
|
|
)
|
|
|
|
|
|
-type _conditionLogic string
|
|
|
+type ConditionLogic string
|
|
|
|
|
|
-func (s _conditionLogic) IsValid() bool {
|
|
|
+func (s ConditionLogic) IsValid() bool {
|
|
|
switch s {
|
|
|
case LogicEmpty:
|
|
|
case LogicOR:
|
|
@@ -90,8 +93,8 @@ func (s _conditionLogic) IsValid() bool {
|
|
|
|
|
|
type _condition struct {
|
|
|
field string
|
|
|
- logic _conditionLogic
|
|
|
- operator _conditionOperator
|
|
|
+ logic ConditionLogic
|
|
|
+ operator ConditionOperator
|
|
|
value any
|
|
|
}
|
|
|
|
|
@@ -99,14 +102,18 @@ func (s *_condition) Field() string {
|
|
|
return s.field
|
|
|
}
|
|
|
|
|
|
-func (s *_condition) Logic() _conditionLogic {
|
|
|
+func (s *_condition) Logic() ConditionLogic {
|
|
|
return s.logic
|
|
|
}
|
|
|
|
|
|
-func (s *_condition) Operator() _conditionOperator {
|
|
|
+func (s *_condition) Operator() ConditionOperator {
|
|
|
return s.operator
|
|
|
}
|
|
|
|
|
|
+func (s *_condition) Value() any {
|
|
|
+ return s.value
|
|
|
+}
|
|
|
+
|
|
|
func (s *_condition) IsValid() bool {
|
|
|
return len(s.field) > 0 && s.logic.IsValid() && s.operator.IsValid()
|
|
|
}
|