Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2023-10-09 12:13:31 +08:00
commit 8a245a31ba

View file

@ -111,6 +111,24 @@ func (value *Value) Compare(other *Value) int {
return 0
}
}
if nil != value.Created && nil != other.Created {
if value.Created.Content > other.Created.Content {
return 1
} else if value.Created.Content < other.Created.Content {
return -1
} else {
return 0
}
}
if nil != value.Updated && nil != other.Updated {
if value.Updated.Content > other.Updated.Content {
return 1
} else if value.Updated.Content < other.Updated.Content {
return -1
} else {
return 0
}
}
if nil != value.MSelect && nil != other.MSelect {
var v1 string
@ -245,6 +263,62 @@ func (value *Value) CompareOperator(other *Value, operator FilterOperator) bool
}
}
if nil != value.Created && nil != other.Created {
switch operator {
case FilterOperatorIsEqual:
return value.Created.Content == other.Created.Content
case FilterOperatorIsNotEqual:
return value.Created.Content != other.Created.Content
case FilterOperatorIsGreater:
return value.Created.Content > other.Created.Content
case FilterOperatorIsGreaterOrEqual:
return value.Created.Content >= other.Created.Content
case FilterOperatorIsLess:
return value.Created.Content < other.Created.Content
case FilterOperatorIsLessOrEqual:
return value.Created.Content <= other.Created.Content
case FilterOperatorIsBetween:
start := value.Created.Content >= other.Created.Content
end := value.Created.Content <= other.Created.Content2
return start && end
case FilterOperatorIsEmpty:
return !value.Created.IsNotEmpty
case FilterOperatorIsNotEmpty:
return value.Created.IsNotEmpty
case FilterOperatorIsRelativeToToday:
// TODO: date filter (relative to today)
return value.Date.Content >= other.Date.Content && value.Date.Content <= other.Date.Content2
}
}
if nil != value.Updated && nil != other.Updated {
switch operator {
case FilterOperatorIsEqual:
return value.Updated.Content == other.Updated.Content
case FilterOperatorIsNotEqual:
return value.Updated.Content != other.Updated.Content
case FilterOperatorIsGreater:
return value.Updated.Content > other.Updated.Content
case FilterOperatorIsGreaterOrEqual:
return value.Updated.Content >= other.Updated.Content
case FilterOperatorIsLess:
return value.Updated.Content < other.Updated.Content
case FilterOperatorIsLessOrEqual:
return value.Updated.Content <= other.Updated.Content
case FilterOperatorIsBetween:
start := value.Updated.Content >= other.Updated.Content
end := value.Updated.Content <= other.Updated.Content2
return start && end
case FilterOperatorIsEmpty:
return !value.Updated.IsNotEmpty
case FilterOperatorIsNotEmpty:
return value.Updated.IsNotEmpty
case FilterOperatorIsRelativeToToday:
// TODO: date filter (relative to today)
return value.Date.Content >= other.Date.Content && value.Date.Content <= other.Date.Content2
}
}
if nil != value.MSelect && nil != other.MSelect && 0 < len(value.MSelect) && 0 < len(other.MSelect) {
switch operator {
case FilterOperatorIsEqual, FilterOperatorContains: