fix: white space trim

pull/52/head
injet-zhou 3 years ago
parent 755cc07f9a
commit c826520e89

@ -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, " ") == "" {
return user.List(d.engine, &model.ConditionsT{
"ORDER": "id ASC",
}, 0, 6)
} else {
return user.List(d.engine, &model.ConditionsT{
"username LIKE ?": strings.Trim(keyword, "") + "%",
"username LIKE ?": strings.Trim(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, " ") == "" {
return tag.List(d.engine, &model.ConditionsT{
"ORDER": "quote_num DESC",
}, 0, 6)
} else {
return tag.List(d.engine, &model.ConditionsT{
"tag LIKE ?": "%" + strings.Trim(keyword, "") + "%",
"tag LIKE ?": "%" + strings.Trim(keyword, " ") + "%",
"ORDER": "quote_num DESC",
}, 0, 6)
}

Loading…
Cancel
Save