From 9330f7f5eaffbcc5ca84e7c556e13f9629160b33 Mon Sep 17 00:00:00 2001 From: michael <1558431322@qq.com> Date: Sat, 7 May 2022 20:47:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20bug=20=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E9=A2=86=E5=9F=9F=E4=BF=A1=E6=81=AF=E6=B2=A1?= =?UTF-8?q?=E5=AD=98=E8=B5=B7=E6=9D=A5=EF=BC=8C=E9=AB=98=E5=B1=82=E6=AC=A1?= =?UTF-8?q?=E4=BA=BA=E6=89=8D=E5=8D=95=E9=80=89=E7=9A=84=E5=BD=A2=E5=BC=8F?= =?UTF-8?q?=E5=AD=98=E5=82=A8=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/app/declare.go | 29 ++++++++++++++- example/provider/company.go | 70 +++++++++++++++++++++++++++++++++++-- 2 files changed, 95 insertions(+), 4 deletions(-) diff --git a/example/app/declare.go b/example/app/declare.go index 2382d5f..0ef9f83 100644 --- a/example/app/declare.go +++ b/example/app/declare.go @@ -108,14 +108,41 @@ var DeclareCtr = Ctr{ delete(company, "create_time") delete(company, "modify_time") data := Map{} + //for k, _ := range company { + // if that.Req.Form[k] != nil { + // if k == "technology_center_flag" || k == "engineering_center_flag" || k == "engineering_laboratory_flag" || k == "key_laboratory_flag" || k == "industrial_design_center_flag" { + // data[k] = ObjToStr(that.Req.Form[k]) + // } else { + // data[k] = that.Req.FormValue(k) + // } + // + // } + //} + for k, _ := range company { + // 前端传传值不规范 + if k == "high_level_talents_flag" { + that.Req.Form[k] = that.Req.Form["highLevel_talents_flag"] + } if that.Req.Form[k] != nil { if k == "technology_center_flag" || k == "engineering_center_flag" || k == "engineering_laboratory_flag" || k == "key_laboratory_flag" || k == "industrial_design_center_flag" { data[k] = ObjToStr(that.Req.Form[k]) + } else if k == "tags" || k == "high_level_talents_flag" { + keyObj := that.Req.Form[k] + if keyObj != nil && ObjToStr(keyObj) != "" { + tagsStr := "" + for k2, v2 := range keyObj { + if k == "tags" && k2 < len(keyObj)-1 { + tagsStr = tagsStr + v2 + "," + } else { + tagsStr += v2 + } + } + data[k] = tagsStr + } } else { data[k] = that.Req.FormValue(k) } - } } diff --git a/example/provider/company.go b/example/provider/company.go index 38f5d69..03c6d5f 100644 --- a/example/provider/company.go +++ b/example/provider/company.go @@ -3,6 +3,8 @@ package provider import ( . "code.hoteas.com/golang/hotime" . "code.hoteas.com/golang/hotime/common" + "code.hoteas.com/golang/hotime/dri/aliyun" + "fmt" ) var CompanyCtr = Ctr{ @@ -35,6 +37,7 @@ var CompanyCtr = Ctr{ 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_flag"] = ObjToSlice(res["high_level_talents_flag"]) that.Display(0, res) }, @@ -61,20 +64,81 @@ var CompanyCtr = Ctr{ delete(company, "create_time") delete(company, "modify_time") data := Map{} + //for k, _ := range company { + // if that.Req.Form[k] != nil { + // if k == "technology_center_flag" || k == "engineering_center_flag" || k == "engineering_laboratory_flag" || k == "key_laboratory_flag" || k == "industrial_design_center_flag" { + // data[k] = ObjToStr(that.Req.Form[k]) + // } else { + // data[k] = that.Req.FormValue(k) + // } + // + // } + //} for k, _ := range company { + // 前端传传值不规范 + if k == "high_level_talents_flag" { + that.Req.Form[k] = that.Req.Form["highLevel_talents_flag"] + } + if k == "attendee" { + continue + } if that.Req.Form[k] != nil { if k == "technology_center_flag" || k == "engineering_center_flag" || k == "engineering_laboratory_flag" || k == "key_laboratory_flag" || k == "industrial_design_center_flag" { data[k] = ObjToStr(that.Req.Form[k]) + } else if k == "tags" || k == "high_level_talents_flag" { + keyObj := that.Req.Form[k] + if keyObj != nil && ObjToStr(keyObj) != "" { + tagsStr := "" + for k2, v2 := range keyObj { + if k == "tags" && k2 < len(keyObj)-1 { + tagsStr = tagsStr + v2 + "," + } else { + tagsStr += v2 + } + } + data[k] = tagsStr + } } else { - data[k] = that.Req.FormValue(k) + fmt.Println(that.Req.FormValue(k)) + if that.Req.FormValue(k) != "" { + data[k] = that.Req.FormValue(k) + } } - } } - that.Db.Update("company", company, Map{"id": id}) + data["modify_time[#]"] = "NOW()" + that.Db.Update("company", data, Map{"id": id}) that.Display(0, "更新成功") }, + "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")) + }, } -- 2.45.2