interface -> any

This commit is contained in:
2024-08-09 17:17:20 +08:00
parent ca811dbdf4
commit ce2f962784
7 changed files with 55 additions and 55 deletions

View File

@ -24,8 +24,8 @@ type SetOption func(o *Option)
//
// Date : 20:07 2022/7/23
type ORCondition struct {
Express string `json:"express"` // 表达式
Value interface{} `json:"value"` // 绑定值
Express string `json:"express"` // 表达式
Value any `json:"value"` // 绑定值
}
// Option 扩展选项
@ -34,20 +34,20 @@ type ORCondition struct {
//
// Date : 8:05 下午 2021/8/8
type Option struct {
Model interface{} `json:"-"` // 操作model
Table string `json:"table"` // 查询的数据表
Limit int `json:"limit"` // 限制数量
Offset int `json:"offset"` // 偏移量
In map[string]interface{} `json:"in"` // in语句
NotIn map[string]interface{} `json:"not_in"` // not in语句
Where map[string]interface{} `json:"where"` // where 条件
Start map[string]interface{} `json:"start"` // >= 条件
End map[string]interface{} `json:"end"` // < 条件
Like map[string]string `json:"like"` // like 语句
NotLike map[string]string `json:"not_like"` // not like 语句
NotEqual map[string]interface{} `json:"not_equal"` // != 语句
Order []string `json:"order"` // 排序规则
OR []*ORCondition `json:"or"` // or 语句, or 和其他属性 and 关系, 内部 OR 关系
Model any `json:"-"` // 操作model
Table string `json:"table"` // 查询的数据表
Limit int `json:"limit"` // 限制数量
Offset int `json:"offset"` // 偏移量
In map[string]any `json:"in"` // in语句
NotIn map[string]any `json:"not_in"` // not in语句
Where map[string]any `json:"where"` // where 条件
Start map[string]any `json:"start"` // >= 条件
End map[string]any `json:"end"` // < 条件
Like map[string]string `json:"like"` // like 语句
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 关系
}
// WithModel ...
@ -55,7 +55,7 @@ type Option struct {
// Author : go_developer@163.com<白茶清欢>
//
// Date : 15:18 2024/1/15
func WithModel(model interface{}) SetOption {
func WithModel(model any) SetOption {
return func(o *Option) {
o.Model = model
}
@ -80,7 +80,7 @@ func WithTable(tableName string) SetOption {
func WithWhere[T op_type.BaseType](where map[string]T) SetOption {
return func(o *Option) {
if nil == o.Where {
o.Where = make(map[string]interface{})
o.Where = make(map[string]any)
}
for field, value := range where {
o.Where[field] = value
@ -131,7 +131,7 @@ func WithIn[T op_type.Array](field string, value T) SetOption {
return
}
if nil == o.In {
o.In = make(map[string]interface{})
o.In = make(map[string]any)
}
o.In[field] = value
}
@ -145,7 +145,7 @@ func WithIn[T op_type.Array](field string, value T) SetOption {
func WithBatchIn[T op_type.Array](batchIn map[string]T) SetOption {
return func(o *Option) {
if nil == o.In {
o.In = make(map[string]interface{})
o.In = make(map[string]any)
}
for field, value := range batchIn {
WithIn(field, value)
@ -161,7 +161,7 @@ func WithBatchIn[T op_type.Array](batchIn map[string]T) SetOption {
func WithNotIn[T op_type.Array](field string, value T) SetOption {
return func(o *Option) {
if nil == o.NotIn {
o.NotIn = make(map[string]interface{})
o.NotIn = make(map[string]any)
}
if value == nil || len(value) == 0 {
return
@ -178,7 +178,7 @@ func WithNotIn[T op_type.Array](field string, value T) SetOption {
func WithBatchNotIn[T op_type.Array](data map[string]T) SetOption {
return func(o *Option) {
if nil == o.NotIn {
o.NotIn = make(map[string]interface{})
o.NotIn = make(map[string]any)
}
for field, value := range data {
if value == nil || len(value) == 0 {
@ -194,10 +194,10 @@ func WithBatchNotIn[T op_type.Array](data map[string]T) SetOption {
// Author : go_developer@163.com<白茶清欢>
//
// Date : 17:01 2022/5/15
func WithStart(field string, value interface{}) SetOption {
func WithStart(field string, value any) SetOption {
return func(o *Option) {
if nil == o.Start {
o.Start = make(map[string]interface{})
o.Start = make(map[string]any)
}
o.Start[field] = value
}
@ -208,10 +208,10 @@ func WithStart(field string, value interface{}) SetOption {
// Author : go_developer@163.com<白茶清欢>
//
// Date : 17:03 2022/5/15
func WithBatchStart(data map[string]interface{}) SetOption {
func WithBatchStart(data map[string]any) SetOption {
return func(o *Option) {
if nil == o.Start {
o.Start = make(map[string]interface{})
o.Start = make(map[string]any)
}
for field, value := range data {
o.Start[field] = value
@ -224,10 +224,10 @@ func WithBatchStart(data map[string]interface{}) SetOption {
// Author : go_developer@163.com<白茶清欢>
//
// Date : 17:07 2022/5/15
func WithEnd(field string, value interface{}) SetOption {
func WithEnd(field string, value any) SetOption {
return func(o *Option) {
if nil == o.End {
o.End = make(map[string]interface{})
o.End = make(map[string]any)
}
o.End[field] = value
}
@ -238,10 +238,10 @@ func WithEnd(field string, value interface{}) SetOption {
// Author : go_developer@163.com<白茶清欢>
//
// Date : 17:10 2022/5/15
func WithBatchEnd(data map[string]interface{}) SetOption {
func WithBatchEnd(data map[string]any) SetOption {
return func(o *Option) {
if nil == o.End {
o.End = make(map[string]interface{})
o.End = make(map[string]any)
}
for field, value := range data {
o.End[field] = value
@ -329,7 +329,7 @@ func WithBatchNotLike(data map[string]string) SetOption {
func WithNotEqual[T op_type.BaseType](field string, value T) SetOption {
return func(o *Option) {
if nil == o.NotEqual {
o.NotEqual = make(map[string]interface{})
o.NotEqual = make(map[string]any)
}
o.NotEqual[field] = value
}
@ -343,7 +343,7 @@ func WithNotEqual[T op_type.BaseType](field string, value T) SetOption {
func WithBatchNotEqual[T op_type.BaseType](data map[string]T) SetOption {
return func(o *Option) {
if nil == o.NotEqual {
o.NotEqual = make(map[string]interface{})
o.NotEqual = make(map[string]any)
}
for field, value := range data {
o.NotEqual[field] = value