Skip to content

feat: 获取用户敏感信息 #226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions apis.md.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Name|Request Type|Response Type|Access Token|URL|Doc
`execUserJoinQrcode`|`reqUserJoinQrcode`|`respUserJoinQrcode`|+|`GET /cgi-bin/corp/get_join_qrcode`|[获取加入企业二维码](https://developer.work.weixin.qq.com/document/path/91714)
`execUserIDByMobile`|`reqUserIDByMobile`|`respUserIDByMobile`|+|`POST /cgi-bin/user/getuserid`|[手机号获取userid](https://work.weixin.qq.com/api/doc/90001/90143/91693)
`execUserIDByEmail`|`reqUserIDByEmail`|`respUserIDByEmail`|+|`POST /cgi-bin/user/get_userid_by_email`|[邮箱获取userid](https://developer.work.weixin.qq.com/document/path/95895)
`execUserGetDetail`|`reqAuthTicket2UserInfo`|`respUserGet`|+|`POST /cgi-bin/user/getuserdetail`|[获取访问用户敏感信息](https://developer.work.weixin.qq.com/document/path/95833)

# 部门管理

Expand Down
9 changes: 9 additions & 0 deletions models.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,15 @@ type AuthCodeUserInfo struct {
ExternalUserID string `json:"external_userid,omitempty"`
}

// reqAuthTicket2UserInfo 获取访问用户敏感信息
type reqAuthTicket2UserInfo struct {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么不跟随 API 命名,叫 reqGetUserDetail?

UserTicket string `json:"user_ticket,omitempty"`
}

func (x reqAuthTicket2UserInfo) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x)
}

type reqMsgAuditListPermitUser struct {
MsgAuditEdition MsgAuditEdition `json:"type"`
}
Expand Down
14 changes: 14 additions & 0 deletions user_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ func (c *WorkwxApp) GetUser(userid string) (*UserInfo, error) {
return &obj, nil
}

func (c *WorkwxApp) GetUserDetail(ticket string) (*UserInfo, error) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里需要一个注释,因为疼讯官方给 API endpoint 的命名 detail 实在太恶心了,不加注释的话就会觉得是单纯的“获取用户明细”

resp, err := c.execUserGetDetail(reqAuthTicket2UserInfo{
UserTicket: ticket,
})
if err != nil {
return nil, err
}
obj, err := resp.intoUserInfo()
if err != nil {
return nil, err
}
return &obj, nil
}

// UpdateUser 更新成员
func (c *WorkwxApp) UpdateUser(userDetail *UserDetail) error {
_, err := c.execUserUpdate(reqUserUpdate{
Expand Down