Skip to content

Commit b797312

Browse files
committed
Merge branch 'v2' of github.com:silenceper/wechat into feature/remove-redis
2 parents 7bf2053 + a5e674b commit b797312

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1325
-611
lines changed

Diff for: .github/workflows/go.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Go
22

33
on:
44
push:
5-
branches: [ master,release-*,v2 ]
5+
branches: [ master,release-*,v2,feature/** ]
66
pull_request:
7-
branches: [ master,release-*,v2 ]
7+
branches: [ master,release-*,v2,feature/** ]
88

99
jobs:
1010
golangci:

Diff for: credential/default_access_token.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,22 @@ 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-
val := ak.cache.Get(accessTokenCacheKey)
70-
if accessToken = val.(string); accessToken != "" {
71-
return
69+
70+
if val := ak.cache.Get(accessTokenCacheKey); val != nil {
71+
if accessToken = val.(string); accessToken != "" {
72+
return
73+
}
7274
}
7375

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

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

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

Diff for: doc/api/work.md

+11
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,12 @@ host: https://qyapi.weixin.qq.com/
9090
| 名称 | 请求方式 | URL | 是否已实现 | 使用方法 | 贡献者 |
9191
|:---------:|------|:----------------------------------------| ---------- | ------------------------------- |----------|
9292
| 获取子部门ID列表 | GET | /cgi-bin/department/simplelist | YES | (r *Client) DepartmentSimpleList| MARKWANG |
93+
| 获取部门列表 | GET | /cgi-bin/department/list | YES | (r *Client) DepartmentList| just5325, ourines |
9394
| 获取部门成员 | GET | /cgi-bin/user/simplelist | YES | (r *Client) UserSimpleList | MARKWANG |
9495
| 获取成员ID列表 | Post | /cgi-bin/user/list_id | YES | (r *Client) UserListId | MARKWANG |
9596

9697

98+
9799
## 素材管理
98100
[官方文档](https://developer.work.weixin.qq.com/document/path/91054)
99101

@@ -116,5 +118,14 @@ host: https://qyapi.weixin.qq.com/
116118
| ---------------- | -------- | --------------------- | ---------- | -------------------------- | -------- |
117119
| 群机器人发送消息 | POST | /cgi-bin/webhook/send | YES | (r *Client) RobotBroadcast | chcthink |
118120

121+
## 打卡
122+
123+
[官方文档](https://developer.work.weixin.qq.com/document/path/96497)
124+
125+
| 名称 | 请求方式 | URL | 是否已实现 | 使用方法 | 贡献者 |
126+
|----------| -------- | --------------------- | ---------- | -------------------------- |---------|
127+
| 获取打卡日报数据 | POST | /cgi-bin/checkin/getcheckin_daydata | YES | (r *Client) GetDayData | Thinker |
128+
| 获取打卡月报数据 | POST | /cgi-bin/checkin/getcheckin_monthdata | YES | (r *Client) GetMonthData | Thinker |
129+
119130
## 应用管理
120131
TODO

Diff for: domain/openapi/mgnt.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ package openapi
22

33
import "github.com/silenceper/wechat/v2/util"
44

5-
// GetAPIQuotaParams 查询API调用额度参数
5+
// GetAPIQuotaParams 查询 API 调用额度参数
66
type GetAPIQuotaParams struct {
7-
CgiPath string `json:"cgi_path"` // api的请求地址,例如"/cgi-bin/message/custom/send";不要前缀“https://api.weixin.qq.com” ,也不要漏了"/",否则都会76003的报错
7+
CgiPath string `json:"cgi_path"` // api 的请求地址,例如"/cgi-bin/message/custom/send";不要前缀“https://api.weixin.qq.com” ,也不要漏了"/",否则都会 76003 的报错
88
}
99

10-
// APIQuota API调用额度
10+
// APIQuota API 调用额度
1111
type APIQuota struct {
1212
util.CommonError
1313
Quota struct {
@@ -17,20 +17,20 @@ type APIQuota struct {
1717
} `json:"quota"` // 详情
1818
}
1919

20-
// GetRidInfoParams 查询rid信息参数
20+
// GetRidInfoParams 查询 rid 信息参数
2121
type GetRidInfoParams struct {
22-
Rid string `json:"rid"` // 调用接口报错返回的rid
22+
Rid string `json:"rid"` // 调用接口报错返回的 rid
2323
}
2424

25-
// RidInfo rid信息
25+
// RidInfo rid 信息
2626
type RidInfo struct {
2727
util.CommonError
2828
Request struct {
2929
InvokeTime int64 `json:"invoke_time"` // 发起请求的时间戳
3030
CostInMs int64 `json:"cost_in_ms"` // 请求毫秒级耗时
31-
RequestURL string `json:"request_url"` // 请求的URL参数
32-
RequestBody string `json:"request_body"` // post请求的请求参数
31+
RequestURL string `json:"request_url"` // 请求的 URL 参数
32+
RequestBody string `json:"request_body"` // post 请求的请求参数
3333
ResponseBody string `json:"response_body"` // 接口请求返回参数
34-
ClientIP string `json:"client_ip"` // 接口请求的客户端ip
35-
} `json:"request"` // 该rid对应的请求详情
34+
ClientIP string `json:"client_ip"` // 接口请求的客户端 ip
35+
} `json:"request"` // 该 rid 对应的请求详情
3636
}

Diff for: miniprogram/message/consts.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ const (
2222
MsgTypeMiniProgramPage = "miniprogrampage"
2323
// MsgTypeEvent 事件
2424
MsgTypeEvent MsgType = "event"
25-
// DataTypeXML XML格式数据
25+
// DataTypeXML XML 格式数据
2626
DataTypeXML = "xml"
27-
// DataTypeJSON JSON格式数据
27+
// DataTypeJSON JSON 格式数据
2828
DataTypeJSON = "json"
2929
)
3030

Diff for: miniprogram/message/customer_message.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type MediaText struct {
2828
Content string `json:"content"`
2929
}
3030

31-
// MediaResource 消息使用的临时素材id
31+
// MediaResource 消息使用的临时素材 id
3232
type MediaResource struct {
3333
MediaID string `json:"media_id"`
3434
}
@@ -51,7 +51,7 @@ type MediaLink struct {
5151

5252
// CustomerMessage 客服消息
5353
type CustomerMessage struct {
54-
ToUser string `json:"touser"` // 接受者OpenID
54+
ToUser string `json:"touser"` // 接受者 OpenID
5555
Msgtype MsgType `json:"msgtype"` // 客服消息类型
5656
Text *MediaText `json:"text,omitempty"` // 可选
5757
Image *MediaResource `json:"image,omitempty"` // 可选

0 commit comments

Comments
 (0)