Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repair searchPlusScope #2

Open
Tension-Z opened this issue Mar 27, 2023 · 4 comments
Open

repair searchPlusScope #2

Tension-Z opened this issue Mar 27, 2023 · 4 comments

Comments

@Tension-Z
Copy link

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
Copy link
Owner

maolinc commented Mar 27, 2023

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

@Tension-Z
Copy link
Author

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
Copy link
Owner

maolinc commented Mar 29, 2023

repaired and update searchPlusScope

@Tension-Z
Copy link
Author

Tension-Z commented Apr 3, 2023

repaired and update searchPlusScope

this's a great repaired

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants