-
Notifications
You must be signed in to change notification settings - Fork 10
/
api_role_caller.go
82 lines (77 loc) · 2.29 KB
/
api_role_caller.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
80
81
82
package sdk
import (
"github.com/polaris-team/dingtalk-sdk-golang/http"
"github.com/polaris-team/dingtalk-sdk-golang/json"
"strconv"
)
//Desc: 获取角色列表
//Doc: https://open-doc.dingtalk.com/microapp/serverapi3/qydf9c
func (client *DingTalkClient) GetRoleList(offset int, size int) (GetRoleListResp, error) {
params := map[string]string{
"access_token": client.AccessToken,
}
if offset > -1 {
params["offset"] = strconv.Itoa(offset)
}
if size > 0 {
params["size"] = strconv.Itoa(size)
}
body, err := http.Get("https://oapi.dingtalk.com/topapi/role/list", params)
resp := GetRoleListResp{}
if err != nil {
return resp, err
}
json.FromJson(body, &resp)
return resp, err
}
//Desc: 获取角色下的员工列表
//Doc: https://open-doc.dingtalk.com/microapp/serverapi3/qydf9c
func (client *DingTalkClient) GetUsersInRole(roleId int64, offset int, size int) (GetUsersInRoleResp, error) {
params := map[string]string{
"access_token": client.AccessToken,
"role_id": strconv.FormatInt(roleId, 10),
}
if offset > -1 {
params["offset"] = strconv.Itoa(offset)
}
if size > 0 {
params["size"] = strconv.Itoa(size)
}
body, err := http.Get("https://oapi.dingtalk.com/topapi/role/simplelist", params)
resp := GetUsersInRoleResp{}
if err != nil {
return resp, err
}
json.FromJson(body, &resp)
return resp, err
}
//Desc: 获取角色组
//Doc: https://open-doc.dingtalk.com/microapp/serverapi3/qydf9c
func (client *DingTalkClient) GetRoleGroup(groupId int64) (GetRoleGroupResp, error) {
params := map[string]string{
"access_token": client.AccessToken,
"group_id": strconv.FormatInt(groupId, 10),
}
body, err := http.Get("https://oapi.dingtalk.com/topapi/role/getrolegroup", params)
resp := GetRoleGroupResp{}
if err != nil {
return resp, err
}
json.FromJson(body, &resp)
return resp, err
}
//Desc: 获取角色详情
//Doc: https://open-doc.dingtalk.com/microapp/serverapi3/qydf9c
func (client *DingTalkClient) GetRoleDetail(roleId int64) (GetRoleDetailResp, error) {
params := map[string]string{
"access_token": client.AccessToken,
"roleId": strconv.FormatInt(roleId, 10),
}
body, err := http.Get("https://oapi.dingtalk.com/topapi/role/getrole", params)
resp := GetRoleDetailResp{}
if err != nil {
return resp, err
}
json.FromJson(body, &resp)
return resp, err
}