From 2ecc70288e426c946fffb4812d8c12ef69be9eac Mon Sep 17 00:00:00 2001 From: hoteas <等> Date: Fri, 13 May 2022 09:30:09 +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 --- context.go | 23 ++++++++++++----------- dri/tencent/tencent.go | 4 ++-- example/app/declare.go | 2 +- example/config/config.json | 2 ++ example/main.go | 2 ++ example/provider/salesman.go | 2 ++ example/provider/wechat.go | 2 ++ 7 files changed, 23 insertions(+), 14 deletions(-) diff --git a/context.go b/context.go index 1622045..1dd1f8f 100644 --- a/context.go +++ b/context.go @@ -13,19 +13,18 @@ type Context struct { *Application Resp http.ResponseWriter Req *http.Request - Log Map//日志有则创建 + Log Map //日志有则创建 RouterString []string Config Map Db *HoTimeDB RespData Map - RespFunc func() + RespFunc func() CacheIns SessionIns DataSize int HandlerStr string //复写请求url } - // Mtd 唯一标志 func (that *Context) Mtd(router [3]string) Map { that.Application.Router[router[0]][router[1]][router[2]](that) @@ -61,26 +60,28 @@ func (that *Context) Display(statu int, data interface{}) { } func (that *Context) View() { - if that.RespFunc!=nil { + if that.RespFunc != nil { that.RespFunc() } if that.RespData == nil { return } //创建日志 - if that.Log!=nil{ - that.Log["time"]=time.Now().Unix() - if that.Session("admin_id").Data!=nil{ - that.Log["admin_id"]=that.Session("admin_id").ToCeilInt() + if that.Log != nil { + that.Log["time"] = time.Now().Unix() + if that.Session("admin_id").Data != nil { + that.Log["admin_id"] = that.Session("admin_id").ToCeilInt() } - if that.Session("user_id").Data!=nil{ - that.Log["user_id"]=that.Session("user_id").ToCeilInt() + if that.Session("user_id").Data != nil { + that.Log["user_id"] = that.Session("user_id").ToCeilInt() } - that.Db.Insert("logs",that.Log) + that.Db.Insert("logs", that.Log) } d, err := json.Marshal(that.RespData) if err != nil { + that.Display(1, err.Error()) + that.View() return } that.DataSize = len(d) diff --git a/dri/tencent/tencent.go b/dri/tencent/tencent.go index ebff51c..a76eca9 100644 --- a/dri/tencent/tencent.go +++ b/dri/tencent/tencent.go @@ -24,8 +24,8 @@ func (that *tencent) Init(secretId, secretKey string) { that.secretId = secretId that.secretKey = secretKey that.credential = common.NewCredential( - "AKIDOgT8cKCQksnY7yKATaYO7j9ORJzSYohP", - "GNXgjdN4czA9ya0FNMApVJzTmsmU0KSN", + that.secretId, + that.secretKey, ) } diff --git a/example/app/declare.go b/example/app/declare.go index 52a4df8..5b520fa 100644 --- a/example/app/declare.go +++ b/example/app/declare.go @@ -893,7 +893,7 @@ var DeclareCtr = Ctr{ RecommendDeclare = declare } - matchingDegreePercent := ObjToFloat64(matchingDegree) / ObjToFloat64(matchingDegreeCount) + matchingDegreePercent := ObjToFloat64(ObjToFloat64(matchingDegree) / ObjToFloat64(matchingDegreeCount)) if matchingDegreePercent < 0.5 { matchingDegreePercent = 0.5 + matchingDegreePercent diff --git a/example/config/config.json b/example/config/config.json index 07959f5..eb3e762 100644 --- a/example/config/config.json +++ b/example/config/config.json @@ -50,6 +50,8 @@ "sessionName": "HOTIME", "smsKey": "b0eb4bf0198b9983cffcb85b69fdf4fa", "smsLogin": "【政策通】您的验证码为:{code},请在5分钟内使用,切勿将验证码泄露于他人,如非本人操作请忽略。", + "tencentId": "AKIDOgT8cKCQksnY7yKATaYO7j9ORJzSYohP", + "tencentKey": "GNXgjdN4czA9ya0FNMApVJzTmsmU0KSN", "tpt": "tpt", "wechatAppID": "wxdcc8d6360661a179", "wechatAppNotifyUrl": "https://zcth5.kct.cn/app/vip_order/callback", diff --git a/example/main.go b/example/main.go index f1dce7f..60700ce 100644 --- a/example/main.go +++ b/example/main.go @@ -4,6 +4,7 @@ import ( . "code.hoteas.com/golang/hotime" "code.hoteas.com/golang/hotime/dri/aliyun" "code.hoteas.com/golang/hotime/dri/ddsms" + "code.hoteas.com/golang/hotime/dri/tencent" "code.hoteas.com/golang/hotime/dri/wechat" "code.hoteas.com/golang/hotime/example/app" "code.hoteas.com/golang/hotime/example/provider" @@ -31,6 +32,7 @@ func main() { appIns.Config.GetString("wechatPaySerialNo"), appIns.Config.GetString("wechatPayMApiV3Key"), appIns.Config.GetString("wechatPayPrivateKey")) + tencent.Tencent.Init(appIns.Config.GetString("tencentId"), appIns.Config.GetString("tencentKey")) //用户侧访问前设置 appIns.SetConnectListener(func(that *Context) (isFinished bool) { diff --git a/example/provider/salesman.go b/example/provider/salesman.go index b0f41fd..68f5ce0 100644 --- a/example/provider/salesman.go +++ b/example/provider/salesman.go @@ -132,6 +132,8 @@ var Salesman = Ctr{ } that.Db.Update("wechat", Map{"salesman_id": salesman.GetCeilInt64("id")}, Map{"id": wechat.GetInt64("id")}) + that.Db.Update("salesman", Map{"login_time[#]": "now()", "modify_time[#]": "now()"}, + Map{"id": salesman.GetCeilInt("id")}) wechat["salesman_id"] = salesman.GetCeilInt64("id") that.Session("salesman_id", salesman.GetCeilInt64("id")) diff --git a/example/provider/wechat.go b/example/provider/wechat.go index 2d1b9ee..3a7c222 100644 --- a/example/provider/wechat.go +++ b/example/provider/wechat.go @@ -43,6 +43,8 @@ var Wechat = Ctr{ //有用户直接返回 if wechat.GetCeilInt("salesman_id") != 0 { + that.Db.Update("salesman", Map{"login_time[#]": "now()"}, + Map{"id": wechat.GetCeilInt("salesman_id")}) that.Session("salesman_id", wechat.GetCeilInt("salesman_id")) that.Display(0, "登录成功")