From ce95cdc021204a9db54712467c04bba0c6051623 Mon Sep 17 00:00:00 2001 From: hoteas <等> Date: Thu, 12 May 2022 18:27:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8D=B0=E5=BD=B1=E5=93=8D=E5=BB=B6?= =?UTF-8?q?=E8=BF=9F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/main.go | 17 ++++------ example/provider/company.go | 64 ++++++++++++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 11 deletions(-) diff --git a/example/main.go b/example/main.go index 2c37904..f1dce7f 100644 --- a/example/main.go +++ b/example/main.go @@ -2,14 +2,11 @@ package main import ( . "code.hoteas.com/golang/hotime" - "code.hoteas.com/golang/hotime/common" "code.hoteas.com/golang/hotime/dri/aliyun" "code.hoteas.com/golang/hotime/dri/ddsms" "code.hoteas.com/golang/hotime/dri/wechat" "code.hoteas.com/golang/hotime/example/app" "code.hoteas.com/golang/hotime/example/provider" - "net/url" - //. "code.hoteas.com/golang/hotime/common" "fmt" "time" @@ -38,13 +35,13 @@ func main() { //用户侧访问前设置 appIns.SetConnectListener(func(that *Context) (isFinished bool) { //发送短信校验 - that.RespFunc = func() { - go func(Form url.Values, RespData common.Map) { - fmt.Println(Form) - fmt.Println(RespData) - }(that.Req.Form, that.RespData) - - } + //that.RespFunc = func() { + // go func(Form url.Values, RespData common.Map) { + // fmt.Println(Form) + // fmt.Println(RespData) + // }(that.Req.Form, that.RespData) + // + //} return isFinished }) diff --git a/example/provider/company.go b/example/provider/company.go index 98443c5..fc00461 100644 --- a/example/provider/company.go +++ b/example/provider/company.go @@ -3,9 +3,71 @@ 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{ + + "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("salesman_id").Data == nil { that.Display(2, "没有登录") @@ -74,7 +136,7 @@ var CompanyCtr = Ctr{ } } - that.Db.Update("company", company, Map{"id": id}) + that.Db.Update("company", data, Map{"id": id}) that.Display(0, "更新成功")