Skip to content

Commit 7d42206

Browse files
bors[bot]w3xse7en
andauthored
Merge #57
57: feat: add GetOATemplateDetail ApplyOAEvent GetOAApprovalInfo GetOAApprovalDetail EventSysApprovalChange r=xen0n a=w3xse7en GetOATemplateDetail doc: https://open.work.weixin.qq.com/api/doc/90000/90135/91982 ApplyOAEvent doc: https://open.work.weixin.qq.com/api/doc/90000/90135/91853 GetOAApprovalInfo doc: https://open.work.weixin.qq.com/api/doc/90000/90135/91816 GetOAApprovalDetail doc: https://open.work.weixin.qq.com/api/doc/90000/90135/91983 EventSysApprovalChange doc: https://open.work.weixin.qq.com/api/doc/90000/90135/91815 Co-authored-by: w3xse7en <w3xse7en@outlook.com>
2 parents 84f32a3 + 4a205fd commit 7d42206

File tree

13 files changed

+1460
-6
lines changed

13 files changed

+1460
-6
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ in at least 2 of Qiniu's internal systems.
6565
* [x] 消息发送 (除修改群聊会话外全部支持)
6666
* [x] 消息接收 (**接口尚不稳定,极有可能做出不兼容改动,先不要用**)
6767
* [x] 素材管理 (**支持上传**, 见下)
68+
* [ ] OA
6869
* [ ] 会话内容存档
6970
* [x] 企业微信登录接口 (code2Session)
7071

@@ -111,7 +112,6 @@ in at least 2 of Qiniu's internal systems.
111112
<details>
112113
<summary>外部联系人管理 API</summary>
113114

114-
115115
* [x] 成员对外信息
116116
* [x] 客户管理
117117
- [x] 获取客户列表
@@ -190,6 +190,20 @@ in at least 2 of Qiniu's internal systems.
190190

191191
</details>
192192

193+
<details>
194+
<summary>OA API</summary>
195+
196+
* [ ] 审批
197+
- [x] 获取审批模板详情
198+
- [x] 提交审批申请
199+
- [x] 审批申请状态变化回调通知
200+
- [x] 批量获取审批单号
201+
- [x] 获取审批申请详情
202+
- [ ] 获取企业假期管理配置
203+
- [ ] 修改成员假期余额
204+
205+
</details>
206+
193207
<details>
194208
<summary>会话内容存档 API</summary>
195209

apis.md.go

Lines changed: 56 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/apis.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ Name|Request Type|Response Type|Access Token|URL|Doc
149149

150150
Name|Request Type|Response Type|Access Token|URL|Doc
151151
:---|------------|-------------|------------|:--|:--
152-
`execCorpGetOpenApprovalData`|TODO|TODO|+|`POST /cgi-bin/corp/getopenapprovaldata`|[查询自建应用审批单当前状态](https://work.weixin.qq.com/api/doc#90000/90135/90269)
152+
`execOAGetTemplateDetail`|`reqOAGetTemplateDetail`|`respOAGetTemplateDetail`|+|`POST /cgi-bin/oa/gettemplatedetail`|[获取审批模板详情](https://work.weixin.qq.com/api/doc/90000/90135/91982)
153+
`execOAApplyEvent`|`reqOAApplyEvent`|`respOAApplyEvent`|+|`POST /cgi-bin/oa/applyevent`|[提交审批申请](https://work.weixin.qq.com/api/doc/90000/90135/91853)
154+
`execOAGetApprovalInfo`|`reqOAGetApprovalInfo`|`respOAGetApprovalInfo`|+|`POST /cgi-bin/oa/getapprovalinfo`|[批量获取审批单号](https://work.weixin.qq.com/api/doc/90000/90135/91816)
155+
`execOAGetApprovalDetail`|`reqOAGetApprovalDetail`|`respOAGetApprovalDetail`|+|`POST /cgi-bin/oa/getapprovaldetail`|[获取审批申请详情](https://work.weixin.qq.com/api/doc/90000/90135/91983)
153156

154157
# 企业支付
155158

docs/oa.md

Lines changed: 372 additions & 0 deletions
Large diffs are not rendered by default.

docs/rx_msg.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ const EventTypeChangeExternalContact EventType = "change_external_contact"
4848
// EventTypeChangeExternalChat 客户群变更事件
4949
const EventTypeChangeExternalChat EventType = "change_external_chat"
5050

51+
// EventTypeSysApprovalChange 审批申请状态变化回调通知
52+
const EventTypeSysApprovalChange EventType = "sys_approval_change"
53+
5154
// ChangeType 变更类型
5255
type ChangeType string
5356

@@ -173,3 +176,9 @@ Name|XML|Type|Doc
173176
`FromUserName`|`FromUserName`|`string`|此事件该值固定为sys,表示该消息由系统生成
174177
`FailReason`|`FailReason`|`string`|接替失败的原因, customer_refused-客户拒绝, customer_limit_exceed-接替成员的客户数达到上限
175178
`ChatID`|`ChatId`|`string`|群ID
179+
180+
### `rxEventSysApprovalChange` 接收的事件消息,审批申请状态变化回调通知
181+
182+
Name|XML|Type|Doc
183+
:---|:--|:---|:--
184+
`ApprovalInfo`|`ApprovalInfo`|`OAApprovalInfo`|审批信息、

dummy_for_generate.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ package workwx
55
//go:generate go run --tags sdkcodegen ./internal/sdkcodegen ./docs/dept_info.md ./dept_info.md.go
66
//go:generate go run --tags sdkcodegen ./internal/sdkcodegen ./docs/external_contact.md ./external_contact.md.go
77
//go:generate go run --tags sdkcodegen ./internal/sdkcodegen ./docs/user_info.md ./user_info.md.go
8+
//go:generate go run --tags sdkcodegen ./internal/sdkcodegen ./docs/oa.md ./oa.md.go
89
//go:generate go run --tags sdkcodegen ./internal/sdkcodegen ./docs/rx_msg.md ./rx_msg.md.go
910
//go:generate go run --tags sdkcodegen ./internal/errcodegen ./errcodes/mod.go

example_test.go

Lines changed: 231 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@ package workwx_test
22

33
import (
44
"net/http"
5+
"strconv"
6+
"time"
57

68
"github.com/xen0n/go-workwx"
79
)
810

11+
const (
12+
corpID = "your_corpid"
13+
corpSecret = "your_corpsecret"
14+
)
15+
916
func ExampleWorkwx() {
10-
corpID := "your_corpid"
11-
corpSecret := "your_corpsecret"
1217
agentID := int64(1234567)
1318

1419
client := workwx.New(corpID)
@@ -28,8 +33,6 @@ func ExampleWorkwx() {
2833
}
2934

3035
func ExampleWorkwxApp_SendTextMessage() {
31-
corpID := "your_corpid"
32-
corpSecret := "your_corpsecret"
3336
agentID := int64(1234567)
3437

3538
client := workwx.New(corpID)
@@ -68,3 +71,227 @@ func ExampleWorkwxApp_SendTextMessage() {
6871
}
6972
_ = app.SendTextMessage(&to5, "send to chatid", false)
7073
}
74+
75+
func ExampleWorkwxApp_ApplyOAEvent() {
76+
agentID := int64(1234567)
77+
78+
client := workwx.New(corpID)
79+
80+
app := client.WithApp(corpSecret, agentID)
81+
app.SpawnAccessTokenRefresher()
82+
83+
appInfo := workwx.OAApplyEvent{
84+
CreatorUserID: "your_userid",
85+
TemplateID: "your_templateid",
86+
UseTemplateApprover: 1,
87+
ApplyData: workwx.OAContents{
88+
Contents: []workwx.OAContent{
89+
{
90+
Control: workwx.OAControlText,
91+
ID: "Text-1608628829793",
92+
Value: workwx.OAContentValue{
93+
Text: "文本",
94+
},
95+
},
96+
{
97+
Control: workwx.OAControlTextarea,
98+
ID: "Textarea-1608628832640",
99+
Value: workwx.OAContentValue{
100+
Text: "多行文本\n可换行",
101+
},
102+
},
103+
{
104+
Control: workwx.OAControlNumber,
105+
ID: "Number-1608632495498",
106+
Value: workwx.OAContentValue{
107+
Number: "123.45",
108+
},
109+
},
110+
{
111+
Control: workwx.OAControlMoney,
112+
ID: "Money-1608632497034",
113+
Value: workwx.OAContentValue{
114+
Money: "678.90",
115+
},
116+
},
117+
{
118+
Control: workwx.OAControlFormula,
119+
ID: "Formula-1608632498148",
120+
Value: workwx.OAContentValue{
121+
Formula: workwx.OAContentFormula{Value: "5.0"},
122+
},
123+
},
124+
{
125+
Control: workwx.OAControlDate,
126+
ID: "Date-1608632499227",
127+
Value: workwx.OAContentValue{
128+
Date: workwx.OAContentDate{Type: "day", Timestamp: strconv.FormatInt(time.Now().Unix(), 10)},
129+
},
130+
},
131+
{
132+
Control: workwx.OAControlDate,
133+
ID: "Date-1608632500394",
134+
Value: workwx.OAContentValue{
135+
Date: workwx.OAContentDate{Type: "hour", Timestamp: strconv.FormatInt(time.Now().Unix(), 10)},
136+
},
137+
},
138+
{
139+
Control: workwx.OAControlDateRange,
140+
ID: "DateRange-1608632502131",
141+
Value: workwx.OAContentValue{
142+
DateRange: workwx.OAContentDateRange{
143+
NewBegin: int(time.Now().Unix()),
144+
NewEnd: int(time.Now().Add(time.Hour * 24).Unix()),
145+
NewDuration: 60 * 60 * 24,
146+
},
147+
},
148+
},
149+
{
150+
Control: workwx.OAControlSelector,
151+
ID: "Selector-1608632503203",
152+
Value: workwx.OAContentValue{
153+
Selector: workwx.OAContentSelector{
154+
Type: "single",
155+
Options: []workwx.OAContentSelectorOption{
156+
{Key: "option-1608632503204"},
157+
},
158+
},
159+
},
160+
},
161+
{
162+
Control: workwx.OAControlSelector,
163+
ID: "Selector-1608632504330",
164+
Value: workwx.OAContentValue{
165+
Selector: workwx.OAContentSelector{
166+
Type: "multi",
167+
Options: []workwx.OAContentSelectorOption{
168+
{Key: "option-1608632504330"},
169+
{Key: "option-1608632504331"},
170+
},
171+
},
172+
},
173+
},
174+
{
175+
Control: workwx.OAControlContact,
176+
ID: "Contact-1608632505579",
177+
Value: workwx.OAContentValue{
178+
Members: []workwx.OAContentMember{{
179+
UserID: "your_userid",
180+
Name: "your_name",
181+
}},
182+
},
183+
},
184+
{
185+
Control: workwx.OAControlContact,
186+
ID: "Contact-1608632506635",
187+
Value: workwx.OAContentValue{
188+
Departments: []workwx.OAContentDepartment{{
189+
OpenAPIID: "39",
190+
Name: "xx部门1",
191+
}, {
192+
OpenAPIID: "40",
193+
Name: "xx部门2",
194+
}},
195+
},
196+
},
197+
{
198+
Control: workwx.OAControlLocation,
199+
ID: "Location-1608632507748",
200+
Value: workwx.OAContentValue{
201+
Location: workwx.OAContentLocation{
202+
Latitude: "30.547239",
203+
Longitude: "104.063291",
204+
Title: "腾讯科技(成都)有限公司(腾讯成都大厦)",
205+
Address: "四川省成都市武侯区天府三街198号腾讯成都大厦A座",
206+
Time: int(time.Now().Unix()),
207+
},
208+
},
209+
},
210+
{
211+
Control: workwx.OAControlRelatedApproval,
212+
ID: "RelatedApproval-1608632509930",
213+
Value: workwx.OAContentValue{
214+
RelatedApproval: []workwx.OAContentRelatedApproval{
215+
{SpNo: "202012220021"},
216+
},
217+
},
218+
},
219+
{
220+
Control: workwx.OAControlTable,
221+
ID: "Table-1608632511066",
222+
Value: workwx.OAContentValue{
223+
Table: []workwx.OAContentTableList{
224+
{
225+
List: []workwx.OAContent{
226+
{
227+
Control: workwx.OAControlText,
228+
ID: "Text-1608632519610",
229+
Value: workwx.OAContentValue{
230+
Text: "第一行第一列",
231+
},
232+
}, {
233+
Control: workwx.OAControlText,
234+
ID: "Text-1608632521106",
235+
Value: workwx.OAContentValue{
236+
Text: "第一行第二列",
237+
},
238+
},
239+
},
240+
},
241+
{
242+
List: []workwx.OAContent{
243+
{
244+
Control: workwx.OAControlText,
245+
ID: "Text-1608632519610",
246+
Value: workwx.OAContentValue{
247+
Text: "第二行第一列",
248+
},
249+
}, {
250+
Control: workwx.OAControlText,
251+
ID: "Text-1608632521106",
252+
Value: workwx.OAContentValue{
253+
Text: "第二行第二列",
254+
},
255+
},
256+
},
257+
},
258+
},
259+
},
260+
},
261+
{
262+
Control: workwx.OAControlVacation,
263+
ID: "Vacation-1608715577151",
264+
Value: workwx.OAContentValue{
265+
Vacation: workwx.OAContentVacation{
266+
Selector: workwx.OAContentSelector{
267+
Type: "single",
268+
Options: []workwx.OAContentSelectorOption{
269+
{
270+
Key: "3",
271+
},
272+
},
273+
},
274+
Attendance: workwx.OAContentVacationAttendance{
275+
DateRange: workwx.OAContentVacationAttendanceDateRange{
276+
Type: "hour",
277+
OAContentDateRange: workwx.OAContentDateRange{
278+
NewBegin: int(time.Now().Unix()),
279+
NewEnd: int(time.Now().Add(time.Hour * 72).Unix()),
280+
NewDuration: 60 * 60 * 72,
281+
},
282+
},
283+
Type: 1,
284+
},
285+
},
286+
},
287+
},
288+
},
289+
},
290+
SummaryList: []workwx.OASummaryList{{SummaryInfo: []workwx.OAText{{
291+
Text: "摘要第1行",
292+
}}}, {SummaryInfo: []workwx.OAText{{
293+
Text: "摘要第2行",
294+
}}}},
295+
}
296+
_, _ = app.ApplyOAEvent(appInfo)
297+
}

0 commit comments

Comments
 (0)