-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathkf_knowledge.go
74 lines (67 loc) · 2.01 KB
/
kf_knowledge.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
package wework
import (
"github.com/go-laoji/wecom-go-sdk/v2/internal"
)
type KfKnowLedgeAddGroupResponse struct {
internal.BizResponse
GroupId string `json:"group_id"`
}
func (ww *weWork) KfKnowLedgeAddGroup(corpId uint, name string) (resp KfKnowLedgeAddGroupResponse) {
p := H{"name": name}
_, err := ww.getRequest(corpId).SetBody(p).SetResult(&resp).
Post("/cgi-bin/kf/knowledge/add_group")
if err != nil {
resp.ErrCode = 500
resp.ErrorMsg = err.Error()
}
return
}
func (ww *weWork) KfKnowLedgeDelGroup(corpId uint, groupId string) (resp internal.BizResponse) {
p := H{"group_id": groupId}
_, err := ww.getRequest(corpId).SetBody(p).SetResult(&resp).
Post("/cgi-bin/kf/knowledge/del_group")
if err != nil {
resp.ErrCode = 500
resp.ErrorMsg = err.Error()
}
return
}
func (ww *weWork) KfKnowLedgeModGroup(corpId uint, name string, groupId string) (resp internal.BizResponse) {
p := H{"name": name, "group_id": groupId}
_, err := ww.getRequest(corpId).SetBody(p).SetResult(&resp).
Post("/cgi-bin/kf/knowledge/mod_group")
if err != nil {
resp.ErrCode = 500
resp.ErrorMsg = err.Error()
}
return
}
type KfKnowLedgeListGroupFilter struct {
Cursor string `json:"cursor,omitempty"`
Limit uint32 `json:"limit,omitempty" validate:"omitempty,max=1000"`
GroupId string `json:"group_id,omitempty"`
}
type KfKnowLedgeListGroupResponse struct {
internal.BizResponse
NextCursor string `json:"next_cursor"`
HasMore int `json:"has_more"`
GroupList []struct {
GroupID string `json:"group_id"`
Name string `json:"name"`
IsDefault int `json:"is_default"`
} `json:"group_list"`
}
func (ww *weWork) KfKnowLedgeListGroup(corpId uint, filter KfKnowLedgeListGroupFilter) (resp KfKnowLedgeListGroupResponse) {
if ok := validate.Struct(filter); ok != nil {
resp.ErrCode = 500
resp.ErrorMsg = ok.Error()
return
}
_, err := ww.getRequest(corpId).SetBody(filter).SetResult(&resp).
Post("/cgi-bin/kf/knowledge/list_group")
if err != nil {
resp.ErrCode = 500
resp.ErrorMsg = err.Error()
}
return
}