repair searchPlusScope
Tension-Z opened this issue · 4 comments
Tension-Z commented
question
Condition cannot be output correctly
repair
case "string":
if operator == "包含" {
v = fmt.Sprintf("%%%v%%", value)
} else if operator == "不包含" {
v = fmt.Sprintf("%%%v%%", value)
} else {
v = value
}
maolinc commented
You're right, thank you. Currently, searchPlusScope is not perfect and can be rewritten using your own scenario,welcome to share
Tension-Z commented
Fix that the count cannot be output correctly
repair
func (m *default{{.CamelName}}Model) Count(ctx context.Context, cond *{{.CamelName}}Query) (total int64, err error) {
err = m.conn(ctx).Scopes(
searchPlusScope(cond.SearchPlus, m.table),
).Where(cond.{{.CamelName}}).Count(&total).Error
return total, err
}
maolinc commented
repaired and update searchPlusScope
Tension-Z commented
repaired and update searchPlusScope
this's a great repaired