打印影响延迟优化

This commit is contained in:
hoteas 2022-05-12 18:27:01 +08:00
parent c9f33eefec
commit ce95cdc021
2 changed files with 70 additions and 11 deletions

View File

@ -2,14 +2,11 @@ package main
import ( import (
. "code.hoteas.com/golang/hotime" . "code.hoteas.com/golang/hotime"
"code.hoteas.com/golang/hotime/common"
"code.hoteas.com/golang/hotime/dri/aliyun" "code.hoteas.com/golang/hotime/dri/aliyun"
"code.hoteas.com/golang/hotime/dri/ddsms" "code.hoteas.com/golang/hotime/dri/ddsms"
"code.hoteas.com/golang/hotime/dri/wechat" "code.hoteas.com/golang/hotime/dri/wechat"
"code.hoteas.com/golang/hotime/example/app" "code.hoteas.com/golang/hotime/example/app"
"code.hoteas.com/golang/hotime/example/provider" "code.hoteas.com/golang/hotime/example/provider"
"net/url"
//. "code.hoteas.com/golang/hotime/common" //. "code.hoteas.com/golang/hotime/common"
"fmt" "fmt"
"time" "time"
@ -38,13 +35,13 @@ func main() {
//用户侧访问前设置 //用户侧访问前设置
appIns.SetConnectListener(func(that *Context) (isFinished bool) { appIns.SetConnectListener(func(that *Context) (isFinished bool) {
//发送短信校验 //发送短信校验
that.RespFunc = func() { //that.RespFunc = func() {
go func(Form url.Values, RespData common.Map) { // go func(Form url.Values, RespData common.Map) {
fmt.Println(Form) // fmt.Println(Form)
fmt.Println(RespData) // fmt.Println(RespData)
}(that.Req.Form, that.RespData) // }(that.Req.Form, that.RespData)
//
} //}
return isFinished return isFinished
}) })

View File

@ -3,9 +3,71 @@ package provider
import ( import (
. "code.hoteas.com/golang/hotime" . "code.hoteas.com/golang/hotime"
. "code.hoteas.com/golang/hotime/common" . "code.hoteas.com/golang/hotime/common"
"code.hoteas.com/golang/hotime/dri/aliyun"
"fmt"
) )
var CompanyCtr = Ctr{ 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) { "info": func(that *Context) {
if that.Session("salesman_id").Data == nil { if that.Session("salesman_id").Data == nil {
that.Display(2, "没有登录") 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, "更新成功") that.Display(0, "更新成功")