forked from shenghui0779/sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
department.go
40 lines (33 loc) · 1003 Bytes
/
department.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
package linkedcorp
import (
"encoding/json"
"fmt"
"github.com/chenghonour/wechat-sdk/urls"
"github.com/chenghonour/wechat-sdk/wx"
)
type ParamsDepartmentList struct {
DepartmentID string `json:"department_id"`
}
type DepartmentListData struct {
DepartmentID string `json:"department_id"`
DepartmentName string `json:"department_name"`
ParentID string `json:"parentid"`
Order int `json:"order"`
}
type ResultDepartmentList struct {
DepartmentList []*DepartmentListData `json:"department_list"`
}
// ListDeparment 获取互联企业部门列表
func ListDeparment(linkedID, departmentID string, result *ResultDepartmentList) wx.Action {
params := &ParamsDepartmentList{
DepartmentID: fmt.Sprintf("%s/%s", linkedID, departmentID),
}
return wx.NewPostAction(urls.CorpLinkedcorpDepartmentList,
wx.WithBody(func() ([]byte, error) {
return wx.MarshalNoEscapeHTML(params)
}),
wx.WithDecode(func(b []byte) error {
return json.Unmarshal(b, result)
}),
)
}