2022-05-03 00:09:25 +00:00
|
|
|
package app
|
|
|
|
|
|
|
|
import (
|
|
|
|
. "code.hoteas.com/golang/hotime"
|
|
|
|
. "code.hoteas.com/golang/hotime/common"
|
|
|
|
"code.hoteas.com/golang/hotime/dri/aliyun"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
var CompanyCtr = Ctr{
|
2022-05-03 07:17:27 +00:00
|
|
|
|
|
|
|
"search": func(that *Context) {
|
|
|
|
keywords := that.Req.FormValue("keywords")
|
2022-05-04 16:29:30 +00:00
|
|
|
if keywords == "" {
|
|
|
|
keywords = that.Req.FormValue("company_name")
|
|
|
|
}
|
|
|
|
if keywords == "" {
|
|
|
|
keywords = that.Req.FormValue("name")
|
|
|
|
}
|
|
|
|
|
2022-05-03 07:17:27 +00:00
|
|
|
if len(keywords) < 2 {
|
2022-05-03 00:09:25 +00:00
|
|
|
that.Display(0, Slice{})
|
|
|
|
return
|
|
|
|
}
|
2022-05-03 07:17:27 +00:00
|
|
|
|
|
|
|
res, err := aliyun.Company.GetCompanyList(keywords)
|
2022-05-03 00:09:25 +00:00
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
that.Display(0, Slice{})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if res.GetCeilInt64("status") != 200 {
|
|
|
|
fmt.Println(err)
|
|
|
|
that.Display(0, Slice{})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
that.Display(0, res.GetMap("data").GetSlice("list"))
|
|
|
|
},
|
|
|
|
}
|