forked from binarywang/WxJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWxCpUserService.java
More file actions
202 lines (186 loc) · 7.42 KB
/
WxCpUserService.java
File metadata and controls
202 lines (186 loc) · 7.42 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
package me.chanjar.weixin.cp.api;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.bean.WxCpInviteResult;
import me.chanjar.weixin.cp.bean.WxCpUser;
import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactInfo;
import java.util.List;
import java.util.Map;
/**
* <pre>
* 用户管理接口
* Created by BinaryWang on 2017/6/24.
* </pre>
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
public interface WxCpUserService {
/**
* <pre>
* 用在二次验证的时候.
* 企业在员工验证成功后,调用本方法告诉企业号平台该员工关注成功。
* </pre>
*
* @param userId 用户id
* @throws WxErrorException the wx error exception
*/
void authenticate(String userId) throws WxErrorException;
/**
* <pre>
* 获取部门成员详情
* 请求方式:GET(HTTPS)
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/list?access_token=ACCESS_TOKEN&department_id=DEPARTMENT_ID&fetch_child=FETCH_CHILD
*
* 文档地址:https://work.weixin.qq.com/api/doc/90000/90135/90201
* </pre>
*
* @param departId 必填。部门id
* @param fetchChild 非必填。1/0:是否递归获取子部门下面的成员
* @param status 非必填。0获取全部员工,1获取已关注成员列表,2获取禁用成员列表,4获取未关注成员列表。status可叠加
* @return the list
* @throws WxErrorException the wx error exception
*/
List<WxCpUser> listByDepartment(Long departId, Boolean fetchChild, Integer status) throws WxErrorException;
/**
* <pre>
* 获取部门成员.
*
* http://qydev.weixin.qq.com/wiki/index.php?title=管理成员#.E8.8E.B7.E5.8F.96.E9.83.A8.E9.97.A8.E6.88.90.E5.91.98
* </pre>
*
* @param departId 必填。部门id
* @param fetchChild 非必填。1/0:是否递归获取子部门下面的成员
* @param status 非必填。0获取全部员工,1获取已关注成员列表,2获取禁用成员列表,4获取未关注成员列表。status可叠加
* @return the list
* @throws WxErrorException the wx error exception
*/
List<WxCpUser> listSimpleByDepartment(Long departId, Boolean fetchChild, Integer status) throws WxErrorException;
/**
* 新建用户.
*
* @param user 用户对象
* @throws WxErrorException the wx error exception
*/
void create(WxCpUser user) throws WxErrorException;
/**
* 更新用户.
*
* @param user 用户对象
* @throws WxErrorException the wx error exception
*/
void update(WxCpUser user) throws WxErrorException;
/**
* <pre>
* 删除用户/批量删除成员.
* http://qydev.weixin.qq.com/wiki/index.php?title=管理成员#.E6.89.B9.E9.87.8F.E5.88.A0.E9.99.A4.E6.88.90.E5.91.98
* </pre>
*
* @param userIds 员工UserID列表。对应管理端的帐号
* @throws WxErrorException the wx error exception
*/
void delete(String... userIds) throws WxErrorException;
/**
* 获取用户.
*
* @param userid 用户id
* @return the by id
* @throws WxErrorException the wx error exception
*/
WxCpUser getById(String userid) throws WxErrorException;
/**
* <pre>
* 邀请成员.
* 企业可通过接口批量邀请成员使用企业微信,邀请后将通过短信或邮件下发通知。
* 请求方式:POST(HTTPS)
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/batch/invite?access_token=ACCESS_TOKEN
* 文档地址:https://work.weixin.qq.com/api/doc#12543
* </pre>
*
* @param userIds 成员ID列表, 最多支持1000个。
* @param partyIds 部门ID列表,最多支持100个。
* @param tagIds 标签ID列表,最多支持100个。
* @return the wx cp invite result
* @throws WxErrorException the wx error exception
*/
WxCpInviteResult invite(List<String> userIds, List<String> partyIds, List<String> tagIds) throws WxErrorException;
/**
* <pre>
* userid转openid.
* 该接口使用场景为微信支付、微信红包和企业转账。
*
* 在使用微信支付的功能时,需要自行将企业微信的userid转成openid。
* 在使用微信红包功能时,需要将应用id和userid转成appid和openid才能使用。
* 注:需要成员使用微信登录企业微信或者关注微信插件才能转成openid
*
* 文档地址:https://work.weixin.qq.com/api/doc#11279
* </pre>
*
* @param userId 企业内的成员id
* @param agentId 非必填,整型,仅用于发红包。其它场景该参数不要填,如微信支付、企业转账、电子发票
* @return map对象 ,可能包含以下值: - openid 企业微信成员userid对应的openid,若有传参agentid,则是针对该agentid的openid。否则是针对企业微信corpid的openid - appid 应用的appid,若请求包中不包含agentid则不返回appid。该appid在使用微信红包时会用到
* @throws WxErrorException the wx error exception
*/
Map<String, String> userId2Openid(String userId, Integer agentId) throws WxErrorException;
/**
* <pre>
* openid转userid.
*
* 该接口主要应用于使用微信支付、微信红包和企业转账之后的结果查询。
* 开发者需要知道某个结果事件的openid对应企业微信内成员的信息时,可以通过调用该接口进行转换查询。
* 权限说明:
* 管理组需对openid对应的企业微信成员有查看权限。
*
* 文档地址:https://work.weixin.qq.com/api/doc#11279
* </pre>
*
* @param openid 在使用微信支付、微信红包和企业转账之后,返回结果的openid
* @return userid 该openid在企业微信对应的成员userid
* @throws WxErrorException the wx error exception
*/
String openid2UserId(String openid) throws WxErrorException;
/**
* <pre>
*
* 通过手机号获取其所对应的userid。
*
* 请求方式:POST(HTTPS)
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/getuserid?access_token=ACCESS_TOKEN
*
* 文档地址:https://work.weixin.qq.com/api/doc#90001/90143/91693
* </pre>
*
* @param mobile 手机号码。长度为5~32个字节
* @return userid mobile对应的成员userid
* @throws WxErrorException .
*/
String getUserId(String mobile) throws WxErrorException;
/**
* 获取外部联系人详情.
* <pre>
* 企业可通过此接口,根据外部联系人的userid,拉取外部联系人详情。权限说明:
* 企业需要使用外部联系人管理secret所获取的accesstoken来调用
* 第三方应用需拥有“企业客户”权限。
* 第三方应用调用时,返回的跟进人follow_user仅包含应用可见范围之内的成员。
* </pre>
*
* @param userId 外部联系人的userid
* @return 联系人详情 external contact
* @throws WxErrorException .
*/
WxCpExternalContactInfo getExternalContact(String userId) throws WxErrorException;
/**
* <pre>
*
* 获取加入企业二维码。
*
* 请求方式:GET(HTTPS)
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/corp/get_join_qrcode?access_token=ACCESS_TOKEN&size_type=SIZE_TYPE
*
* 文档地址:https://work.weixin.qq.com/api/doc/90000/90135/91714
* </pre>
*
* @param sizeType qrcode尺寸类型,1: 171 x 171; 2: 399 x 399; 3: 741 x 741; 4: 2052 x 2052
* @return join_qrcode 二维码链接,有效期7天
* @throws WxErrorException .
*/
String getJoinQrCode(int sizeType) throws WxErrorException;
}