|
@@ -60,3 +60,30 @@ type Condition struct {
|
|
func (s *Condition) IsValid() bool {
|
|
func (s *Condition) IsValid() bool {
|
|
return len(s.Field) > 0 && s.Logic.IsValid() && s.Operator.IsValid()
|
|
return len(s.Field) > 0 && s.Logic.IsValid() && s.Operator.IsValid()
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+//////////////////////////////////////////////////////////////////////////////
|
|
|
|
+
|
|
|
|
+type ConditionList []*Condition
|
|
|
|
+
|
|
|
|
+func (s *ConditionList) FieldExists(name string) bool {
|
|
|
|
+ for _, v := range *s {
|
|
|
|
+ if v.Field == name {
|
|
|
|
+ return true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return false
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (s *ConditionList) FieldsRemove(toRemove []string) {
|
|
|
|
+ toRemoveMap := make(map[string]struct{})
|
|
|
|
+ for _, item := range toRemove {
|
|
|
|
+ toRemoveMap[item] = struct{}{}
|
|
|
|
+ }
|
|
|
|
+ var result ConditionList
|
|
|
|
+ for _, item := range *s {
|
|
|
|
+ if _, found := toRemoveMap[item.Field]; !found {
|
|
|
|
+ result = append(result, item)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ *s = result
|
|
|
|
+}
|