Merge branch 'master' of git.u8t.cn:open/gosdk
This commit is contained in:
commit
086162dc67
|
|
@ -15,6 +15,7 @@ var (
|
||||||
urlQyWeixinHrGetStaffInfo = "https://qyapi.weixin.qq.com/cgi-bin/hr/get_staff_info"
|
urlQyWeixinHrGetStaffInfo = "https://qyapi.weixin.qq.com/cgi-bin/hr/get_staff_info"
|
||||||
urlQyWeixinHrGetDepartment = "https://qyapi.weixin.qq.com/cgi-bin/department/list"
|
urlQyWeixinHrGetDepartment = "https://qyapi.weixin.qq.com/cgi-bin/department/list"
|
||||||
urlQyWeixinHrGetDepartmentUser = "https://qyapi.weixin.qq.com/cgi-bin/user/list"
|
urlQyWeixinHrGetDepartmentUser = "https://qyapi.weixin.qq.com/cgi-bin/user/list"
|
||||||
|
urlQyWeixinHrGetContactInfo = "https://qyapi.weixin.qq.com/cgi-bin/user/get"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AppHr struct {
|
type AppHr struct {
|
||||||
|
|
@ -44,12 +45,39 @@ type StaffInfo struct {
|
||||||
BankCard string
|
BankCard string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ContactInfo struct {
|
||||||
|
Realname string
|
||||||
|
DirectLeader []string
|
||||||
|
DepartmentId []int64
|
||||||
|
IsDepartmentLeader []int
|
||||||
|
}
|
||||||
|
|
||||||
func NewAppHr(cfg *AppConfig) *AppHr {
|
func NewAppHr(cfg *AppConfig) *AppHr {
|
||||||
return &AppHr{
|
return &AppHr{
|
||||||
App: *NewApp(cfg),
|
App: *NewApp(cfg),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *AppHr) GetContactInfo(userId string) (*ContactInfo, error) {
|
||||||
|
reqUrl := fmt.Sprintf("%s?access_token=%s", urlQyWeixinHrGetContactInfo, h.GetToken())
|
||||||
|
reqBody := make(map[string]interface{})
|
||||||
|
reqBody["userid"] = userId
|
||||||
|
rspBody, err := util.HttpPostJson(reqUrl, nil, []byte(goutil.EncodeJSON(reqBody)))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
contract := new(ContactInfo)
|
||||||
|
result, err := h.GetResult(rspBody)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
contract.Realname = cast.ToString(result["name"])
|
||||||
|
contract.DirectLeader = cast.ToStringSlice(result["direct_leader"])
|
||||||
|
contract.DepartmentId = cast.ToInt64Slice(result["department"])
|
||||||
|
contract.IsDepartmentLeader = cast.ToIntSlice(result["is_leader_in_dept"])
|
||||||
|
return contract, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (h *AppHr) GetStaffInfo(userId string) (*StaffInfo, error) {
|
func (h *AppHr) GetStaffInfo(userId string) (*StaffInfo, error) {
|
||||||
reqUrl := fmt.Sprintf("%s?access_token=%s", urlQyWeixinHrGetStaffInfo, h.GetToken())
|
reqUrl := fmt.Sprintf("%s?access_token=%s", urlQyWeixinHrGetStaffInfo, h.GetToken())
|
||||||
reqBody := make(map[string]interface{})
|
reqBody := make(map[string]interface{})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue