forked from golang/hotime
83 lines
2.3 KiB
Go
83 lines
2.3 KiB
Go
package provider
|
|
|
|
import (
|
|
. "code.hoteas.com/golang/hotime"
|
|
. "code.hoteas.com/golang/hotime/common"
|
|
)
|
|
|
|
var CompanyCtr = Ctr{
|
|
"info": func(that *Context) {
|
|
if that.Session("salesman_id").Data == nil {
|
|
that.Display(2, "没有登录")
|
|
return
|
|
}
|
|
|
|
id := ObjToInt(that.Req.FormValue("id"))
|
|
|
|
if id == 0 {
|
|
that.Display(3, "请求参数异常")
|
|
return
|
|
}
|
|
|
|
res := that.Db.Get("company", "*", Map{"id": 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"] = 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)
|
|
},
|
|
"edit": func(that *Context) {
|
|
if that.Session("salesman_id").Data == nil {
|
|
that.Display(2, "没有登录")
|
|
return
|
|
}
|
|
|
|
id := ObjToInt(that.Req.FormValue("id"))
|
|
|
|
if id == 0 {
|
|
that.Display(3, "请求参数异常")
|
|
return
|
|
}
|
|
|
|
company := that.Db.Get("company", "*", Map{"id": id})
|
|
delete(company, "id")
|
|
delete(company, "salesman_id")
|
|
delete(company, "provider_id")
|
|
delete(company, "user_id")
|
|
delete(company, "del_flag")
|
|
delete(company, "state")
|
|
delete(company, "create_time")
|
|
delete(company, "modify_time")
|
|
data := Map{}
|
|
for k, _ := range company {
|
|
if that.Req.Form[k] != nil {
|
|
if k == "tags" || k == "high_level_talents_flag1" || k == "technology_center_flag" || k == "engineering_center_flag" || k == "engineering_laboratory_flag" || k == "key_laboratory_flag" || k == "industrial_design_center_flag" {
|
|
data[k] = arrayToStr(ObjToSlice(that.Req.Form[k]))
|
|
} else {
|
|
data[k] = that.Req.FormValue(k)
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
that.Db.Update("company", company, Map{"id": id})
|
|
|
|
that.Display(0, "更新成功")
|
|
|
|
},
|
|
}
|