2024-08-07 19:16:40 +00:00
|
|
|
package filters
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2024-08-29 19:10:29 +00:00
|
|
|
"l12.xyz/x/dal/pkg/utils"
|
2024-08-07 19:16:40 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type NotBetween struct {
|
|
|
|
NotBetween []interface{} `json:"$nbetween"`
|
|
|
|
}
|
|
|
|
|
2024-08-08 17:26:29 +00:00
|
|
|
func (f NotBetween) FromJSON(data interface{}) IFilter {
|
2024-08-07 19:16:40 +00:00
|
|
|
return FromJson[NotBetween](data)
|
|
|
|
}
|
|
|
|
|
2024-08-12 18:21:34 +00:00
|
|
|
func (f NotBetween) ToSQLPart(ctx Dialect) (string, Values) {
|
2024-08-07 19:16:40 +00:00
|
|
|
if f.NotBetween == nil {
|
2024-08-12 18:21:34 +00:00
|
|
|
return "", nil
|
2024-08-07 19:16:40 +00:00
|
|
|
}
|
|
|
|
name := ctx.GetFieldName()
|
|
|
|
values := utils.Map(f.NotBetween, ctx.NormalizeValue)
|
2024-08-12 18:21:34 +00:00
|
|
|
placeholders := utils.Map(values, ValueOrPlaceholder)
|
|
|
|
condition := fmt.Sprintf("%s AND %s", placeholders[0], placeholders[1])
|
|
|
|
return fmt.Sprintf("%s NOT BETWEEN %v", name, condition), values
|
2024-08-07 19:16:40 +00:00
|
|
|
}
|