计划升级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

22
base.go
View File

@ -192,11 +192,6 @@ func (b *BaseDao) setTxCondition(tx *gorm.DB, optionFuncList ...SetOption) *gorm
tx = tx.Model(o.Model)
}
// 设置where条件
if nil != o.Where && len(o.Where) > 0 {
tx = tx.Where(o.Where)
}
// 设置 limit offset
if o.Limit > 0 {
tx = tx.Limit(o.Limit)
@ -205,6 +200,11 @@ func (b *BaseDao) setTxCondition(tx *gorm.DB, optionFuncList ...SetOption) *gorm
}
}
// 设置where条件
if nil != o.Where && len(o.Where) > 0 {
tx = tx.Where(o.Where)
}
// in 语句
if nil != o.In {
tx = tx.Where(o.In)
@ -251,17 +251,7 @@ func (b *BaseDao) setTxCondition(tx *gorm.DB, optionFuncList ...SetOption) *gorm
}
// or 语句
if nil != o.OR {
expression := ""
valList := make([]any, 0)
for _, o := range o.OR {
if len(expression) > 0 {
expression = expression + " OR "
}
expression = expression + " " + o.Express
valList = append(valList, o.Value)
}
tx = tx.Where(expression, valList...)
if len(o.OR) > 0 {
}
return tx
}