Merge pull request #52 from injet-zhou/dev

fix: whitespace trim
pull/87/head
ROC 3 years ago committed by GitHub
commit adee4f8381
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -62,14 +62,14 @@ func (d *Dao) GetUsersByIDs(ids []int64) ([]*model.User, error) {
func (d *Dao) GetUsersByKeyword(keyword string) ([]*model.User, error) { func (d *Dao) GetUsersByKeyword(keyword string) ([]*model.User, error) {
user := &model.User{} user := &model.User{}
if strings.Trim(keyword, "") == "" { if strings.Trim(keyword, " ") == "" {
return user.List(d.engine, &model.ConditionsT{ return user.List(d.engine, &model.ConditionsT{
"ORDER": "id ASC", "ORDER": "id ASC",
}, 0, 6) }, 0, 6)
} else { } else {
return user.List(d.engine, &model.ConditionsT{ return user.List(d.engine, &model.ConditionsT{
"username LIKE ?": strings.Trim(keyword, "") + "%", "username LIKE ?": strings.Trim(keyword, " ") + "%",
}, 0, 6) }, 0, 6)
} }
} }
@ -78,14 +78,14 @@ func (d *Dao) GetUsersByKeyword(keyword string) ([]*model.User, error) {
func (d *Dao) GetTagsByKeyword(keyword string) ([]*model.Tag, error) { func (d *Dao) GetTagsByKeyword(keyword string) ([]*model.Tag, error) {
tag := &model.Tag{} tag := &model.Tag{}
if strings.Trim(keyword, "") == "" { if strings.Trim(keyword, " ") == "" {
return tag.List(d.engine, &model.ConditionsT{ return tag.List(d.engine, &model.ConditionsT{
"ORDER": "quote_num DESC", "ORDER": "quote_num DESC",
}, 0, 6) }, 0, 6)
} else { } else {
return tag.List(d.engine, &model.ConditionsT{ return tag.List(d.engine, &model.ConditionsT{
"tag LIKE ?": "%" + strings.Trim(keyword, "") + "%", "tag LIKE ?": "%" + strings.Trim(keyword, " ") + "%",
"ORDER": "quote_num DESC", "ORDER": "quote_num DESC",
}, 0, 6) }, 0, 6)
} }

Loading…
Cancel
Save