120 lines
3.2 KiB
Go
120 lines
3.2 KiB
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) {
|
|
if that.Session("user_id").Data == nil {
|
|
that.Display(2, "没有登录")
|
|
return
|
|
}
|
|
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"))
|
|
},
|
|
"search_info": func(that *Context) {
|
|
if that.Session("user_id").Data == nil {
|
|
that.Display(2, "没有登录")
|
|
return
|
|
}
|
|
name := that.Req.FormValue("name")
|
|
|
|
if len(name) < 2 {
|
|
that.Display(3, "找不到企业")
|
|
return
|
|
}
|
|
|
|
res, err := aliyun.Company.GetCompanyBaseInfo(name)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
that.Display(4, "查询失败")
|
|
return
|
|
}
|
|
if res.GetBool("status") != true {
|
|
fmt.Println(err)
|
|
that.Display(4, "查询失败")
|
|
return
|
|
}
|
|
|
|
that.Display(0, res.GetMap("data"))
|
|
},
|
|
"info": func(that *Context) {
|
|
if that.Session("user_id").Data == nil {
|
|
that.Display(2, "没有登录")
|
|
return
|
|
}
|
|
id := ObjToInt(that.Req.FormValue("id"))
|
|
|
|
if id == 0 {
|
|
that.Display(3, "请求参数异常")
|
|
return
|
|
}
|
|
|
|
user := that.Db.Get("user", "*", Map{"id": that.Session("user_id").Data})
|
|
if user == nil {
|
|
that.Display(4, "找不到用户")
|
|
return
|
|
}
|
|
|
|
res := that.Db.Get("company", "*", Map{"id": user.GetCeilInt("company_id")})
|
|
if res == nil {
|
|
that.Display(4, "找不到企业")
|
|
return
|
|
}
|
|
//先不做限制
|
|
//if res.GetCeilInt("salesman_id")!=that.Session("salesman_id").ToCeilInt(){
|
|
// that.Display(4,"不是你的企业")
|
|
// return
|
|
//}
|
|
|
|
//res["technology_center_flag"] = ObjToSlice(res["technology_center_flag"])
|
|
//res["engineering_center_flag"] = ObjToSlice(res["engineering_center_flag"])
|
|
//res["engineering_laboratory_flag"] = ObjToSlice(res["engineering_laboratory_flag"])
|
|
//res["key_laboratory_flag"] = ObjToSlice(res["key_laboratory_flag"])
|
|
//res["industrial_design_center_flag"] = ObjToSlice(res["industrial_design_center_flag"])
|
|
//
|
|
//res["high_level_talents_flag1"] = ObjToSlice(res["high_level_talents_flag1"])
|
|
//
|
|
//res["tags"] = ObjToSlice(res["tags"])
|
|
|
|
res["technology_center_flag"] = strToArray(res.GetString("technology_center_flag"))
|
|
res["engineering_center_flag"] = strToArray(res.GetString("engineering_center_flag"))
|
|
res["engineering_laboratory_flag"] = strToArray(res.GetString("engineering_laboratory_flag"))
|
|
res["key_laboratory_flag"] = strToArray(res.GetString("key_laboratory_flag"))
|
|
res["industrial_design_center_flag"] = strToArray(res.GetString("industrial_design_center_flag"))
|
|
res["high_level_talents_flag1"] = strToArray(res.GetString("high_level_talents_flag1"))
|
|
res["tags"] = strToArray(res.GetString("tags"))
|
|
|
|
that.Display(0, res)
|
|
},
|
|
}
|