|
|
|
@ -485,6 +485,13 @@ export default { |
|
|
|
return db |
|
|
|
} |
|
|
|
|
|
|
|
func (obj *${tableNameLower}Q) where(key string, value interface{}) { |
|
|
|
obj.opts = append(obj.opts, func(db *gorm.DB) *gorm.DB { |
|
|
|
db = db.Where(obj.Repo.PreTableName(key), value) |
|
|
|
return db |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
func (obj *${tableNameLower}Q) Select(strings ...string) *${tableNameLower}Q { |
|
|
|
fn := func(db *gorm.DB) *gorm.DB { |
|
|
|
if len(strings) > 0 { |
|
|
|
@ -617,11 +624,7 @@ export default { |
|
|
|
`; |
|
|
|
optCommon += ` |
|
|
|
func (obj *${tableNameLower}Q) ${skey}In(${skey}s ...${type}) *${tableNameLower}Q { |
|
|
|
fn := func(db *gorm.DB) *gorm.DB { |
|
|
|
db = db.Where(obj.Repo.PreTableName("${key} in (?)"), ${skey}s) |
|
|
|
return db |
|
|
|
} |
|
|
|
obj.opts = append(obj.opts, fn) |
|
|
|
obj.where("${key} in (?)", ${skey}s) |
|
|
|
return obj |
|
|
|
} |
|
|
|
\n |
|
|
|
@ -645,11 +648,7 @@ export default { |
|
|
|
} |
|
|
|
optCommon += ` |
|
|
|
func (obj *${tableNameLower}Q) ${skey}(${skey} ${type}) *${tableNameLower}Q { |
|
|
|
fn := func(db *gorm.DB) *gorm.DB { |
|
|
|
db = db.Where(obj.Repo.PreTableName("${key} = ?"), ${skey}) |
|
|
|
return db |
|
|
|
} |
|
|
|
obj.opts = append(obj.opts, fn) |
|
|
|
obj.where("${key} = ?", ${skey}) |
|
|
|
return obj |
|
|
|
} |
|
|
|
\n |
|
|
|
@ -663,11 +662,7 @@ export default { |
|
|
|
`; |
|
|
|
optCommon += ` |
|
|
|
func (obj *${tableNameLower}Q) ${skey}Like(${skey} ${type}) *${tableNameLower}Q { |
|
|
|
fn := func(db *gorm.DB) *gorm.DB { |
|
|
|
db = db.Where(obj.Repo.PreTableName("${key} like ?"), "%"+${skey}+"%") |
|
|
|
return db |
|
|
|
} |
|
|
|
obj.opts = append(obj.opts, fn) |
|
|
|
obj.where("${key} like ?", "%"+${skey}+"%") |
|
|
|
return obj |
|
|
|
} |
|
|
|
\n |
|
|
|
|