From 5fc3e236e4fb81cd5418becdcd1b7bcf16317d05 Mon Sep 17 00:00:00 2001 From: wenzl Date: Thu, 26 Oct 2017 15:10:39 +0800 Subject: [PATCH 1/9] =?UTF-8?q?redis=20IdleTimeout=20=E4=BD=BF=E7=94=A8sec?= =?UTF-8?q?ond?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cache/redis.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cache/redis.go b/cache/redis.go index 31438c9..9d102b0 100644 --- a/cache/redis.go +++ b/cache/redis.go @@ -14,12 +14,12 @@ type Redis struct { //RedisOpts redis 连接属性 type RedisOpts struct { - Host string - Password string - Database int - MaxIdle int - MaxActive int - IdleTimeout time.Duration //second + Host string `yml:"host" json:"host"` + Password string `yml:"password" json:"password"` + Database int `yml:"database" json:"database"` + MaxIdle int `yml:"max_idle" json:"max_idle"` + MaxActive int `yml:"max_active" json:"max_active"` + IdleTimeout int32 `yml:"idle_timeout" json:"idle_timeout"` //second } //NewRedis 实例化 @@ -27,7 +27,7 @@ func NewRedis(opts *RedisOpts) *Redis { pool := &redis.Pool{ MaxActive: opts.MaxActive, MaxIdle: opts.MaxIdle, - IdleTimeout: opts.IdleTimeout, + IdleTimeout: time.Second * time.Duration(opts.IdleTimeout), Dial: func() (redis.Conn, error) { return redis.Dial("tcp", opts.Host, redis.DialDatabase(opts.Database), From 1867a9d3df623fe1bae4515c06bbb34a9f89d53c Mon Sep 17 00:00:00 2001 From: wenzl Date: Sat, 4 Nov 2017 13:10:05 +0800 Subject: [PATCH 2/9] export GetTicket --- js/js.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/js.go b/js/js.go index a8bdaa9..80f43bb 100644 --- a/js/js.go +++ b/js/js.go @@ -44,7 +44,7 @@ func NewJs(context *context.Context) *Js { func (js *Js) GetConfig(uri string) (config *Config, err error) { config = new(Config) var ticketStr string - ticketStr, err = js.getTicket() + ticketStr, err = js.GetTicket() if err != nil { return } @@ -61,8 +61,8 @@ func (js *Js) GetConfig(uri string) (config *Config, err error) { return } -//getTicket 获取jsapi_tocket全局缓存 -func (js *Js) getTicket() (ticketStr string, err error) { +//GetTicket 获取jsapi_tocket +func (js *Js) GetTicket() (ticketStr string, err error) { js.GetJsAPITicketLock().Lock() defer js.GetJsAPITicketLock().Unlock() From cdf37c17dba8e73bf03a1dc67d932c224fa963ef Mon Sep 17 00:00:00 2001 From: silenceper Date: Sat, 4 Nov 2017 13:13:46 +0800 Subject: [PATCH 3/9] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 4620277..73ecf84 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: go go: + - 1.9 - 1.8 - 1.7 - 1.6 From 4202446800f48d8f4dd79a6b088b89cd18b0852f Mon Sep 17 00:00:00 2001 From: wenzl Date: Mon, 6 Nov 2017 17:22:02 +0800 Subject: [PATCH 4/9] handle err --- context/access_token.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/context/access_token.go b/context/access_token.go index 3b3d263..a7f7810 100644 --- a/context/access_token.go +++ b/context/access_token.go @@ -55,6 +55,9 @@ func (ctx *Context) GetAccessTokenFromServer() (resAccessToken ResAccessToken, e url := fmt.Sprintf("%s?grant_type=client_credential&appid=%s&secret=%s", AccessTokenURL, ctx.AppID, ctx.AppSecret) var body []byte body, err = util.HTTPGet(url) + if err != nil { + return + } err = json.Unmarshal(body, &resAccessToken) if err != nil { return From ca249f133fe7f84bea516dd764ceee1937af49d6 Mon Sep 17 00:00:00 2001 From: wenzl Date: Tue, 7 Nov 2017 17:17:13 +0800 Subject: [PATCH 5/9] change int32 to int64 --- template/template.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/template/template.go b/template/template.go index cbd07bb..e0c15f1 100644 --- a/template/template.go +++ b/template/template.go @@ -47,11 +47,11 @@ type DataItem struct { type resTemplateSend struct { util.CommonError - MsgID int32 `json:"msgid"` + MsgID int64 `json:"msgid"` } //Send 发送模板消息 -func (tpl *Template) Send(msg *Message) (msgID int32, err error) { +func (tpl *Template) Send(msg *Message) (msgID int64, err error) { var accessToken string accessToken, err = tpl.GetAccessToken() if err != nil { From 7e80674b7f1ceb4bfcd8cdbd05f0091d975e3048 Mon Sep 17 00:00:00 2001 From: wenzl Date: Thu, 16 Nov 2017 09:28:27 +0800 Subject: [PATCH 6/9] add return field --- message/message.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/message/message.go b/message/message.go index 42a22f4..60a236e 100644 --- a/message/message.go +++ b/message/message.go @@ -58,6 +58,8 @@ const ( EventPicWeixin = "pic_weixin" //EventLocationSelect 弹出地理位置选择器的事件推送 EventLocationSelect = "location_select" + //EventTemplateSendJobFinish 发送模板消息推送通知 + EventTemplateSendJobFinish = "TEMPLATESENDJOBFINISH" ) //MixMessage 存放所有微信发送过来的消息和事件 @@ -87,6 +89,7 @@ type MixMessage struct { Longitude string `xml:"Longitude"` Precision string `xml:"Precision"` MenuID string `xml:"MenuId"` + Status string `xml:"Status"` ScanCodeInfo struct { ScanType string `xml:"ScanType"` From 2afc43adb9bb177691ff83475f149baaab1dfd63 Mon Sep 17 00:00:00 2001 From: JL <41369927@qq.com> Date: Tue, 9 Jan 2018 14:58:05 +0800 Subject: [PATCH 7/9] add sessionFrom for mini program custom message --- message/message.go | 1 + 1 file changed, 1 insertion(+) diff --git a/message/message.go b/message/message.go index 60a236e..b426a7f 100644 --- a/message/message.go +++ b/message/message.go @@ -90,6 +90,7 @@ type MixMessage struct { Precision string `xml:"Precision"` MenuID string `xml:"MenuId"` Status string `xml:"Status"` + SessionFrom string `xml:"SessionFrom"` ScanCodeInfo struct { ScanType string `xml:"ScanType"` From 9e0115d98c6910c675c1779930915b0da6b2065f Mon Sep 17 00:00:00 2001 From: wenzl Date: Mon, 29 Jan 2018 14:43:42 +0800 Subject: [PATCH 8/9] =?UTF-8?q?fix=20oauth.Redirect=20=E7=BC=BA=E5=B0=91re?= =?UTF-8?q?quest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oauth/oauth.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/oauth/oauth.go b/oauth/oauth.go index 5e49e60..6b2b710 100644 --- a/oauth/oauth.go +++ b/oauth/oauth.go @@ -38,13 +38,12 @@ func (oauth *Oauth) GetRedirectURL(redirectURI, scope, state string) (string, er } //Redirect 跳转到网页授权 -func (oauth *Oauth) Redirect(writer http.ResponseWriter, redirectURI, scope, state string) error { +func (oauth *Oauth) Redirect(writer http.ResponseWriter, req *http.Request, redirectURI, scope, state string) error { location, err := oauth.GetRedirectURL(redirectURI, scope, state) if err != nil { return err } - //location 为完整地址,所以不需要request - http.Redirect(writer, nil, location, 302) + http.Redirect(writer, req, location, 302) return nil } From 48c5ea5aa7633eb54ca34fb6512fcf54ca009499 Mon Sep 17 00:00:00 2001 From: wenzl Date: Wed, 7 Feb 2018 16:45:15 +0800 Subject: [PATCH 9/9] fix spelling --- js/js.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/js.go b/js/js.go index 80f43bb..d6b93f4 100644 --- a/js/js.go +++ b/js/js.go @@ -61,7 +61,7 @@ func (js *Js) GetConfig(uri string) (config *Config, err error) { return } -//GetTicket 获取jsapi_tocket +//GetTicket 获取jsapi_ticket func (js *Js) GetTicket() (ticketStr string, err error) { js.GetJsAPITicketLock().Lock() defer js.GetJsAPITicketLock().Unlock()