hotime/example/app/company.go
2022-05-05 00:29:30 +08:00

41 lines
764 B
Go

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{
"search": func(that *Context) {
keywords := that.Req.FormValue("keywords")
if keywords == "" {
keywords = that.Req.FormValue("company_name")
}
if keywords == "" {
keywords = that.Req.FormValue("name")
}
if len(keywords) < 2 {
that.Display(0, Slice{})
return
}
res, err := aliyun.Company.GetCompanyList(keywords)
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"))
},
}