Skip to content

Commit 754e15b

Browse files
authored
Merge pull request #626 from ArtisanCloud/develop
feat(work): add oa wedoc and change name webdriver to wedriver
2 parents 20376ee + 6430494 commit 754e15b

35 files changed

+221
-100
lines changed

src/work/application.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ import (
5555
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa/meetingroom"
5656
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa/pstncc"
5757
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa/schedule"
58-
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa/webdrive"
58+
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa/wedoc"
59+
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa/wedrive"
5960
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oauth"
6061
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/server"
6162
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/user"
@@ -130,7 +131,8 @@ type Work struct {
130131
OAMeetingRoom *meetingroom.Client
131132
OAPSTNCC *pstncc.Client
132133
OASchedule *schedule.Client
133-
OAWebDrive *webdrive.Client
134+
OAWeDoc *wedoc.Client
135+
OAWeDrive *wedrive.Client
134136
OAApproval *approval.Client
135137

136138
MsgAudit *msgaudit.Client
@@ -347,7 +349,8 @@ func NewWork(config *UserConfig) (*Work, error) {
347349
app.OAMeetingRoom,
348350
app.OAPSTNCC,
349351
app.OASchedule,
350-
app.OAWebDrive,
352+
app.OAWeDoc,
353+
app.OAWeDrive,
351354
app.OAApproval,
352355
err = oa.RegisterProvider(app)
353356
if err != nil {
@@ -491,8 +494,10 @@ func (app *Work) GetComponent(name string) interface{} {
491494
return app.OAPSTNCC
492495
case "OASchedule":
493496
return app.OASchedule
494-
case "OAWebDrive":
495-
return app.OAWebDrive
497+
case "OAWeDoc":
498+
return app.OAWeDoc
499+
case "OAWeDrive":
500+
return app.OAWeDrive
496501
case "OAApproval":
497502
return app.OAApproval
498503

src/work/oa/provider.go

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import (
1111
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa/meetingroom"
1212
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa/pstncc"
1313
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa/schedule"
14-
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa/webdrive"
14+
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa/wedoc"
15+
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa/wedrive"
1516
)
1617

1718
func RegisterProvider(app kernel.ApplicationInterface) (*Client,
@@ -23,7 +24,8 @@ func RegisterProvider(app kernel.ApplicationInterface) (*Client,
2324
*meetingroom.Client,
2425
*pstncc.Client,
2526
*schedule.Client,
26-
*webdrive.Client,
27+
*wedoc.Client,
28+
*wedrive.Client,
2729
*approval.Client,
2830
error,
2931

@@ -32,47 +34,51 @@ func RegisterProvider(app kernel.ApplicationInterface) (*Client,
3234

3335
Client, err := NewClient(app)
3436
if err != nil {
35-
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
37+
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
3638
}
3739
Calendar, err := calendar.NewClient(app)
3840
if err != nil {
39-
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
41+
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
4042
}
4143
Dial, err := dial.NewClient(app)
4244
if err != nil {
43-
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
45+
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
4446
}
4547
Journal, err := journal.NewClient(app)
4648
if err != nil {
47-
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
49+
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
4850
}
4951
Living, err := living.NewClient(app)
5052
if err != nil {
51-
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
53+
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
5254
}
5355
Meeting, err := meeting.NewClient(app)
5456
if err != nil {
55-
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
57+
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
5658
}
5759
MeetingRoom, err := meetingroom.NewClient(app)
5860
if err != nil {
59-
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
61+
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
6062
}
6163
PSTNCC, err := pstncc.NewClient(app)
6264
if err != nil {
63-
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
65+
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
6466
}
6567
Schedule, err := schedule.NewClient(app)
6668
if err != nil {
67-
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
69+
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
6870
}
69-
WebDrive, err := webdrive.NewClient(app)
71+
WeDoc, err := wedoc.NewClient(app)
7072
if err != nil {
71-
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
73+
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
74+
}
75+
WeDrive, err := wedrive.NewClient(app)
76+
if err != nil {
77+
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
7278
}
7379
Approval, err := approval.NewClient(app)
7480
if err != nil {
75-
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
81+
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
7682
}
7783
return Client,
7884
Calendar,
@@ -83,7 +89,8 @@ func RegisterProvider(app kernel.ApplicationInterface) (*Client,
8389
MeetingRoom,
8490
PSTNCC,
8591
Schedule,
86-
WebDrive,
92+
WeDoc,
93+
WeDrive,
8794
Approval,
8895
nil
8996

src/work/oa/wedoc/client.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package wedoc
2+
3+
import (
4+
"context"
5+
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel"
6+
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa/wedoc/request"
7+
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa/wedoc/response"
8+
)
9+
10+
type Client struct {
11+
BaseClient *kernel.BaseClient
12+
}
13+
14+
func NewClient(app kernel.ApplicationInterface) (*Client, error) {
15+
baseClient, err := kernel.NewBaseClient(app, nil)
16+
if err != nil {
17+
return nil, err
18+
}
19+
return &Client{
20+
baseClient,
21+
}, nil
22+
}
23+
24+
// 创建收集表
25+
// https://developer.work.weixin.qq.com/document/path/97462
26+
func (comp *Client) CreateForm(ctx context.Context, options *request.RequestWeDocCreateForm) (*response.ResponseWeDocCreateForm, error) {
27+
28+
result := &response.ResponseWeDocCreateForm{}
29+
30+
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/wedoc/create_form", options, nil, nil, result)
31+
32+
return result, err
33+
}

src/work/oa/wedoc/request/request.go

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package request
2+
3+
type FormQuestionItemOption struct {
4+
Key int `json:"key"`
5+
Value string `json:"value"`
6+
Status int `json:"status"`
7+
}
8+
9+
type FormQuestionItem struct {
10+
QuestionId int `json:"question_id"`
11+
Title string `json:"title"`
12+
Pos int `json:"pos"`
13+
Status int `json:"status"`
14+
ReplyType int `json:"reply_type"`
15+
MustReply bool `json:"must_reply"`
16+
Note string `json:"note"`
17+
OptionItem []FormQuestionItemOption `json:"option_item"`
18+
Placeholder string `json:"placeholder"`
19+
QuestionExtendSetting interface{} `json:"question_extend_setting"`
20+
}
21+
22+
type FormQuestion struct {
23+
Items []FormQuestionItem `json:"items"`
24+
}
25+
26+
type FormSettingFillRange struct {
27+
UserIds []string `json:"userids"`
28+
DepartmentIds []int `json:"departmentids"`
29+
}
30+
31+
type FormSettingManagerRange struct {
32+
UserIds []string `json:"userids"`
33+
}
34+
35+
type FormSettingTimedRepeatInfo struct {
36+
Enable bool `json:"enable"`
37+
WeekFlag int `json:"week_flag"`
38+
RemindTime int `json:"remind_time"`
39+
RepeatType int `json:"repeat_type"`
40+
SkipHoliday bool `json:"skip_holiday"`
41+
DayOfMonth int `json:"day_of_month"`
42+
ForkFinishType int `json:"fork_finish_type"`
43+
}
44+
45+
type FormSetting struct {
46+
FillOutAuth int `json:"fill_out_auth"`
47+
FillInRange FormSettingFillRange `json:"fill_in_range"`
48+
SettingManagerRange FormSettingManagerRange `json:"setting_manager_range"`
49+
TimedRepeatInfo FormSettingTimedRepeatInfo `json:"timed_repeat_info"`
50+
AllowMultiFill bool `json:"allow_multi_fill"`
51+
TimedFinish int `json:"timed_finish"`
52+
CanAnonymous bool `json:"can_anonymous"`
53+
CanNotifySubmit bool `json:"can_notify_submit"`
54+
}
55+
56+
type FormInfo struct {
57+
FormTitle string `json:"form_title"`
58+
FormDesc string `json:"form_desc"`
59+
FormHeader string `json:"form_header"`
60+
FormQuestion FormQuestion `json:"form_question"`
61+
FormSetting FormSetting `json:"form_setting"`
62+
}
63+
64+
type RequestWeDocCreateForm struct {
65+
SpaceId string `json:"spaceid"`
66+
FatherId string `json:"fatherid"`
67+
FormInfo FormInfo `json:"form_info"`
68+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package response
2+
3+
import "github.com/ArtisanCloud/PowerWeChat/v3/src/kernel/response"
4+
5+
type ResponseWeDocCreateForm struct {
6+
response.ResponseWork
7+
FormId string `json:"formid"`
8+
}

0 commit comments

Comments
 (0)