Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
laodaming 2023-10-20 14:10:28 +08:00
commit c523a5a7c6

View File

@ -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