Merge branch 'dev'

pull/87/head
alimy 3 years ago
commit 5089d99643

@ -62,14 +62,14 @@ func (d *dataServant) GetUsersByIDs(ids []int64) ([]*model.User, error) {
func (d *dataServant) GetUsersByKeyword(keyword string) ([]*model.User, error) { func (d *dataServant) 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 *dataServant) GetUsersByKeyword(keyword string) ([]*model.User, error) {
func (d *dataServant) GetTagsByKeyword(keyword string) ([]*model.Tag, error) { func (d *dataServant) 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