计划升级or语句支持

This commit is contained in:
2024-08-09 17:24:47 +08:00
parent ce2f962784
commit 88f9e831d8
2 changed files with 10 additions and 30 deletions

View File

@ -18,16 +18,6 @@ import (
// Date : 11:46 2022/5/15
type SetOption func(o *Option)
// ORCondition OR 条件
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 20:07 2022/7/23
type ORCondition struct {
Express string `json:"express"` // 表达式
Value any `json:"value"` // 绑定值
}
// Option 扩展选项
//
// Author : go_developer@163.com<白茶清欢>
@ -47,7 +37,7 @@ type Option struct {
NotLike map[string]string `json:"not_like"` // not like 语句
NotEqual map[string]any `json:"not_equal"` // != 语句
Order []string `json:"order"` // 排序规则
OR []*ORCondition `json:"or"` // or 语句, or 和其他属性 and 关系, 内部 OR 关系
OR [][]SetOption `json:"or"` // or 语句, or 和其他属性 and 关系, 内部 OR 关系
}
// WithModel ...
@ -356,12 +346,12 @@ func WithBatchNotEqual[T op_type.BaseType](data map[string]T) SetOption {
// Author : go_developer@163.com<白茶清欢>
//
// Date : 20:03 2022/7/23
func WithOR(orConditionList ...*ORCondition) SetOption {
func WithOR(orConditionList ...SetOption) SetOption {
return func(o *Option) {
if nil == o.OR {
o.OR = make([]*ORCondition, 0)
o.OR = make([][]SetOption, 0)
}
o.OR = append(o.OR, orConditionList...)
o.OR = append(o.OR, orConditionList)
}
}