diff --git a/internal/dao/user.go b/internal/dao/user.go index d6cbe471..c49f7000 100644 --- a/internal/dao/user.go +++ b/internal/dao/user.go @@ -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) }