diff --git a/model/gmodel/fs_preprocess_logo_logic.go b/model/gmodel/fs_preprocess_logo_logic.go index aee1dbee..be1dce38 100644 --- a/model/gmodel/fs_preprocess_logo_logic.go +++ b/model/gmodel/fs_preprocess_logo_logic.go @@ -11,10 +11,23 @@ import ( "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的属性做你想做的 // 搜索建议 -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) for i, v := range keywords { keywords[i] = "+" + v + "*" diff --git a/server/info/internal/logic/prelogosearchlogic.go b/server/info/internal/logic/prelogosearchlogic.go index 650a1599..36b8f433 100644 --- a/server/info/internal/logic/prelogosearchlogic.go +++ b/server/info/internal/logic/prelogosearchlogic.go @@ -41,7 +41,14 @@ func (l *PreLogoSearchLogic) PreLogoSearch(req *types.PreLogoSearchRequest, user 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 必须重新处理 diff --git a/server/info/internal/logic/prelogosearchsuggestionslogic.go b/server/info/internal/logic/prelogosearchsuggestionslogic.go index 372510fb..5c2586d8 100644 --- a/server/info/internal/logic/prelogosearchsuggestionslogic.go +++ b/server/info/internal/logic/prelogosearchsuggestionslogic.go @@ -41,7 +41,7 @@ func (l *PreLogoSearchSuggestionsLogic) PreLogoSearchSuggestions(req *types.PreL 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 { return resp.SetStatus(basic.CodeApiErr, err) }