maolinc/gencode

repair searchPlusScope

Tension-Z opened this issue · 4 comments

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
					}

You're right, thank you. Currently, searchPlusScope is not perfect and can be rewritten using your own scenario,welcome to share

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
}

repaired and update searchPlusScope

repaired and update searchPlusScope

this's a great repaired