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

fix: whitespace trim #52

Merged
merged 1 commit into from
Jun 4, 2022
Merged

fix: whitespace trim #52

merged 1 commit into from
Jun 4, 2022

Conversation

injet-zhou
Copy link
Contributor

No description provided.

@@ -62,14 +62,14 @@ func (d *Dao) GetUsersByIDs(ids []int64) ([]*model.User, error) {
func (d *Dao) GetUsersByKeyword(keyword string) ([]*model.User, error) {
user := &model.User{}

if strings.Trim(keyword, "") == "" {
if strings.Trim(keyword, " ") == "" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggust prepare fixed keyword:

	keyword = strings.Trim(keyword, " ") + "%"
	if keyword == "%" {
		return user.List(d.engine, &model.ConditionsT{
			"ORDER": "id ASC",
		}, 0, 6)
	} else {
		return user.List(d.engine, &model.ConditionsT{
			"username LIKE ?": keyword,
		}, 0, 6)
	}

@@ -78,14 +78,14 @@ func (d *Dao) GetUsersByKeyword(keyword string) ([]*model.User, error) {
func (d *Dao) GetTagsByKeyword(keyword string) ([]*model.Tag, error) {
tag := &model.Tag{}

if strings.Trim(keyword, "") == "" {
if strings.Trim(keyword, " ") == "" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto suggest:

        keyword = "%" + strings.Trim(keyword, " ") + "%"
	if keyword == "%%" {
		return tag.List(d.engine, &model.ConditionsT{
			"ORDER": "quote_num DESC",
		}, 0, 6)
	} else {
		return tag.List(d.engine, &model.ConditionsT{
			"tag LIKE ?": keyword,
			"ORDER":      "quote_num DESC",
		}, 0, 6)
	}

@rocboss rocboss merged commit adee4f8 into rocboss:dev Jun 4, 2022
alimy added a commit that referenced this pull request Jun 11, 2022
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

Successfully merging this pull request may close these issues.

3 participants