forked from xen0n/go-workwx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dept_info.go
64 lines (55 loc) · 1.33 KB
/
dept_info.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
package workwx
// CreateDept 创建部门
func (c *WorkwxApp) CreateDept(deptInfo *DeptInfo) (deptID int64, err error) {
resp, err := c.execDeptCreate(reqDeptCreate{
DeptInfo: deptInfo,
})
if err != nil {
return 0, err
}
return resp.ID, nil
}
// ListAllDepts 获取全量组织架构。
func (c *WorkwxApp) ListAllDepts() ([]*DeptInfo, error) {
resp, err := c.execDeptList(reqDeptList{
HaveID: false,
ID: 0,
})
if err != nil {
return nil, err
}
return resp.Department, nil
}
// ListDepts 获取指定部门及其下的子部门。
func (c *WorkwxApp) ListDepts(id int64) ([]*DeptInfo, error) {
resp, err := c.execDeptList(reqDeptList{
HaveID: true,
ID: id,
})
if err != nil {
return nil, err
}
return resp.Department, nil
}
// SimpleListAllDepts 获取全量组织架构(简易)。
func (c *WorkwxApp) SimpleListAllDepts() ([]*DeptInfo, error) {
resp, err := c.execDeptSimpleList(reqDeptSimpleList{
HaveID: false,
ID: 0,
})
if err != nil {
return nil, err
}
return resp.DepartmentIDs, nil
}
// SimpleListDepts 获取指定部门及其下的子部门(简易)。
func (c *WorkwxApp) SimpleListDepts(id int64) ([]*DeptInfo, error) {
resp, err := c.execDeptSimpleList(reqDeptSimpleList{
HaveID: true,
ID: id,
})
if err != nil {
return nil, err
}
return resp.DepartmentIDs, nil
}