feat:完成首页搜索功能
This commit is contained in:
30
app/api/website/controller/search/instance.go
Normal file
30
app/api/website/controller/search/instance.go
Normal file
@ -0,0 +1,30 @@
|
||||
package search
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
type Instance struct{}
|
||||
|
||||
type InstanceHandle func() *Instance
|
||||
|
||||
var instanceHandle = map[int]func(int, int, string, string, map[string]interface{}) (interface{}, error){
|
||||
1: searchCompany, 2: achievementSearch, 3: searchLaboratory,
|
||||
4: searchPatent, 5: searchExpert, 6: searchDemand,
|
||||
}
|
||||
|
||||
// Launch 发起搜索
|
||||
func (c *Instance) Launch(mode int, keyword, industry string, params map[string]interface{}, page, pageSize int) (interface{}, error) {
|
||||
handle, has := instanceHandle[mode]
|
||||
|
||||
if !has {
|
||||
return nil, errors.New("操作错误,未知的搜索模式")
|
||||
}
|
||||
return handle(page, pageSize, keyword, industry, params)
|
||||
}
|
||||
|
||||
func NewInstance() InstanceHandle {
|
||||
return func() *Instance {
|
||||
return &Instance{}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user