♻️ Refactor av data structure

This commit is contained in:
Daniel 2023-07-13 23:34:13 +08:00
parent 7f097f3b99
commit 19fcd1a034
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -207,29 +207,34 @@ func (value *Value) CompareOperator(other *Value, operator FilterOperator) bool
if nil != value.MSelect && nil != other.MSelect && 0 < len(value.MSelect) && 0 < len(other.MSelect) { if nil != value.MSelect && nil != other.MSelect && 0 < len(value.MSelect) && 0 < len(other.MSelect) {
switch operator { switch operator {
case FilterOperatorIsEqual: case FilterOperatorIsEqual:
return value.MSelect[0].Content == other.MSelect[0].Content contains := false
for _, v := range value.MSelect {
for _, v2 := range other.MSelect {
if v.Content == v2.Content {
contains = true
break
}
}
}
return contains
case FilterOperatorIsNotEqual: case FilterOperatorIsNotEqual:
return value.MSelect[0].Content != other.MSelect[0].Content contains := false
case FilterOperatorContains:
for _, v := range value.MSelect { for _, v := range value.MSelect {
if v.Content == other.MSelect[0].Content { for _, v2 := range other.MSelect {
return true if v.Content == v2.Content {
contains = true
break
} }
} }
case FilterOperatorDoesNotContain:
for _, v := range value.MSelect {
if v.Content == other.MSelect[0].Content {
return false
} }
} return !contains
return true
case FilterOperatorIsEmpty: case FilterOperatorIsEmpty:
return 0 == len(value.MSelect) return 0 == len(value.MSelect)
case FilterOperatorIsNotEmpty: case FilterOperatorIsNotEmpty:
return 0 != len(value.MSelect) return 0 != len(value.MSelect)
} }
} }
return false return true
} }
// Table 描述了表格实例的结构。 // Table 描述了表格实例的结构。