diff --git a/model/gmodel/fs_preprocess_logo_logic.go b/model/gmodel/fs_preprocess_logo_logic.go index c4f77e2b..d1c73eb1 100644 --- a/model/gmodel/fs_preprocess_logo_logic.go +++ b/model/gmodel/fs_preprocess_logo_logic.go @@ -5,6 +5,8 @@ import ( "fmt" "regexp" "strings" + + "github.com/zeromicro/go-zero/core/logx" ) // TODO: 使用model的属性做你想做的 @@ -13,13 +15,14 @@ import ( func (p *FsPreprocessLogoModel) PreLogoSearchSuggestions(ctx context.Context, zipcode string, keywordsStr string, count int) (resp []FsPreprocessLogo, err error) { keywords := regexp.MustCompile(`\s+`).Split(keywordsStr, -1) for i, v := range keywords { - keywords[i] = "+" + v + v + keywords[i] = "+" + v + "*" } - sqlstr := fmt.Sprintf("SELECT * FROM fs_preprocess_logo WHERE MATCH(restaurant_name) AGAINST('?' IN BOOLEAN MODE) limit %d;", count) + sqlstr := fmt.Sprintf("SELECT * FROM fs_preprocess_logo WHERE MATCH(restaurant_name) AGAINST(? IN BOOLEAN MODE) limit %d;", count) tx := p.db.WithContext(ctx).Model(&FsPreprocessLogo{}).Raw(sqlstr, strings.Join(keywords, " ")) err = tx.Scan(&resp).Error if err != nil { + logx.Error(err) return nil, err } return resp, nil