支持OR语句
This commit is contained in:
14
base.go
14
base.go
@ -157,5 +157,19 @@ func (b *BaseDao) setTxCondition(tx *gorm.DB, table string, optionFuncList ...Se
|
||||
tx = tx.Where(field+" < ?", value)
|
||||
}
|
||||
}
|
||||
|
||||
// or 语句
|
||||
if nil != o.OR {
|
||||
expression := ""
|
||||
valList := make([]interface{}, 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...)
|
||||
}
|
||||
return tx
|
||||
}
|
||||
|
Reference in New Issue
Block a user