Skip to content

Commit dab9d68

Browse files
committed
Merge branch 'v2' of github.com:silenceper/wechat into feature/remove-redis
2 parents b08cf87 + 9bfebc8 commit dab9d68

File tree

21 files changed

+1503
-71
lines changed

21 files changed

+1503
-71
lines changed

.github/workflows/release.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ issues:
5555
linters-settings:
5656
funlen:
5757
lines: 66
58-
statements: 40
58+
statements: 50
5959

6060
#issues:
6161
# include:

.goreleaser.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

credential/default_access_token.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,19 @@ func (ak *DefaultAccessToken) GetAccessToken() (accessToken string, err error) {
6666
func (ak *DefaultAccessToken) GetAccessTokenContext(ctx context.Context) (accessToken string, err error) {
6767
// 先从cache中取
6868
accessTokenCacheKey := fmt.Sprintf("%s_access_token_%s", ak.cacheKeyPrefix, ak.appID)
69-
if val := ak.cache.Get(accessTokenCacheKey); val != nil {
70-
return val.(string), nil
69+
val := ak.cache.Get(accessTokenCacheKey)
70+
if accessToken = val.(string); accessToken != "" {
71+
return
7172
}
7273

7374
// 加上lock,是为了防止在并发获取token时,cache刚好失效,导致从微信服务器上获取到不同token
7475
ak.accessTokenLock.Lock()
7576
defer ak.accessTokenLock.Unlock()
7677

7778
// 双检,防止重复从微信服务器获取
78-
if val := ak.cache.Get(accessTokenCacheKey); val != nil {
79-
return val.(string), nil
79+
val = ak.cache.Get(accessTokenCacheKey)
80+
if accessToken = val.(string); accessToken != "" {
81+
return
8082
}
8183

8284
// cache失效,从微信服务器获取

miniprogram/config/config.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import (
77

88
// Config .config for 小程序
99
type Config struct {
10-
AppID string `json:"app_id"` // appid
11-
AppSecret string `json:"app_secret"` // appSecret
12-
AppKey string `json:"app_key"` // appKey
13-
OfferID string `json:"offer_id"` // offerId
14-
Cache cache.Cache
10+
AppID string `json:"app_id"` // appid
11+
AppSecret string `json:"app_secret"` // appSecret
12+
AppKey string `json:"app_key"` // appKey
13+
OfferID string `json:"offer_id"` // offerId
14+
Token string `json:"token"` // token
15+
EncodingAESKey string `json:"encoding_aes_key"` // EncodingAESKey
16+
Cache cache.Cache
1517
}

miniprogram/message/consts.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ const (
2020
MsgTypeLink = "link"
2121
// MsgTypeMiniProgramPage 小程序卡片
2222
MsgTypeMiniProgramPage = "miniprogrampage"
23+
// MsgTypeEvent 事件
24+
MsgTypeEvent MsgType = "event"
25+
// DataTypeXML XML格式数据
26+
DataTypeXML = "xml"
27+
// DataTypeJSON JSON格式数据
28+
DataTypeJSON = "json"
2329
)
2430

2531
// CommonToken 消息中通用的结构

0 commit comments

Comments
 (0)