Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
commit
396e2cc16f
|
@ -11,10 +11,23 @@ import (
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type PreLogoSearchResult struct {
|
||||||
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // 自增的唯一id
|
||||||
|
LocationCode *string `gorm:"index;default:'';" json:"location_code"` //
|
||||||
|
RestaurantName *string `gorm:"index;default:'';" json:"restaurant_name"` //
|
||||||
|
ResourceUrl *string `gorm:"default:'';" json:"resource_url"` //
|
||||||
|
RestaurantType *string `gorm:"default:'';" json:"restaurant_type"` //
|
||||||
|
Address *string `gorm:"default:'';" json:"address"` //
|
||||||
|
ZipCode *string `gorm:"default:'';" json:"zip_code"` //
|
||||||
|
Phone *string `gorm:"default:'';" json:"phone"` //
|
||||||
|
Website *string `gorm:"default:'';" json:"website"` //
|
||||||
|
IsBranch *int64 `gorm:"default:0;" json:"is_branch"` // 是否分店
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: 使用model的属性做你想做的
|
// TODO: 使用model的属性做你想做的
|
||||||
|
|
||||||
// 搜索建议
|
// 搜索建议
|
||||||
func (p *FsPreprocessLogoModel) PreLogoSearchSuggestions(ctx context.Context, zipcode string, keywordsStr string, count int) (resp []FsPreprocessLogo, err error) {
|
func (p *FsPreprocessLogoModel) PreLogoSearch(ctx context.Context, zipcode string, keywordsStr string, count int) (resp []PreLogoSearchResult, err error) {
|
||||||
keywords := regexp.MustCompile(`\s+`).Split(keywordsStr, -1)
|
keywords := regexp.MustCompile(`\s+`).Split(keywordsStr, -1)
|
||||||
for i, v := range keywords {
|
for i, v := range keywords {
|
||||||
keywords[i] = "+" + v + "*"
|
keywords[i] = "+" + v + "*"
|
||||||
|
|
|
@ -41,7 +41,14 @@ func (l *PreLogoSearchLogic) PreLogoSearch(req *types.PreLogoSearchRequest, user
|
||||||
return resp.SetStatus(basic.CodeSearchZipCodeErr)
|
return resp.SetStatus(basic.CodeSearchZipCodeErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.SetStatus(basic.CodeOK)
|
result, err := l.svcCtx.AllModels.FsPreprocessLogo.PreLogoSearch(l.ctx, req.ZipCode, req.Keywords, 1)
|
||||||
|
if err != nil {
|
||||||
|
return resp.SetStatus(basic.CodeApiErr, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp.SetStatus(basic.CodeOK, map[string]any{
|
||||||
|
"result": result,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||||
|
|
|
@ -41,7 +41,7 @@ func (l *PreLogoSearchSuggestionsLogic) PreLogoSearchSuggestions(req *types.PreL
|
||||||
return resp.SetStatus(basic.CodeSearchZipCodeErr)
|
return resp.SetStatus(basic.CodeSearchZipCodeErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := l.svcCtx.AllModels.FsPreprocessLogo.PreLogoSearchSuggestions(l.ctx, req.ZipCode, req.Keywords, 5)
|
result, err := l.svcCtx.AllModels.FsPreprocessLogo.PreLogoSearch(l.ctx, req.ZipCode, req.Keywords, 5)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return resp.SetStatus(basic.CodeApiErr, err)
|
return resp.SetStatus(basic.CodeApiErr, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user