-
Notifications
You must be signed in to change notification settings - Fork 151
/
client.go
79 lines (60 loc) · 2.24 KB
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package journal
import (
"context"
"fmt"
"github.com/ArtisanCloud/PowerLibs/v3/object"
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel"
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel/power"
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa/journal/response"
)
type Client struct {
BaseClient *kernel.BaseClient
}
func NewClient(app kernel.ApplicationInterface) (*Client, error) {
baseClient, err := kernel.NewBaseClient(&app, nil)
if err != nil {
return nil, err
}
return &Client{
baseClient,
}, nil
}
// 批量获取汇报记录单号
// https://developer.work.weixin.qq.com/document/path/93393
func (comp *Client) GetRecordList(ctx context.Context, startTime int, endTime int, nextCursor int, size int, filters []*power.StringMap) (*response.ResponseJournalGetRecordList, error) {
result := &response.ResponseJournalGetRecordList{}
if size > 100 {
size = 100
}
options := &object.HashMap{
"starttime": fmt.Sprintf("%d", startTime),
"endtime": fmt.Sprintf("%d", endTime),
"cursor": fmt.Sprintf("%d", nextCursor),
"limit": size,
"filters": filters,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/oa/journal/get_record_list", options, nil, nil, result)
return result, err
}
// 获取汇报记录详情
// https://developer.work.weixin.qq.com/document/path/93394
func (comp *Client) GetRecordDetail(ctx context.Context, JournalUUID string) (*response.ResponseJournalGetRecordDetail, error) {
result := &response.ResponseJournalGetRecordDetail{}
options := &object.HashMap{
"journaluuid": JournalUUID,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/oa/journal/get_record_detail", options, nil, nil, result)
return result, err
}
// 获取汇报记录详情
// https://developer.work.weixin.qq.com/document/path/93395
func (comp *Client) GetStatList(ctx context.Context, templateID string, startTime int, endTime int) (*response.ResponseJournalGetStatList, error) {
result := &response.ResponseJournalGetStatList{}
options := &object.HashMap{
"template_id": templateID,
"starttime": fmt.Sprintf("%d", startTime),
"endtime": fmt.Sprintf("%d", endTime),
}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/oa/journal/get_stat_list", options, nil, nil, result)
return result, err
}