Skip to content

Commit 97dff44

Browse files
committed
issue #78 删除接口支持批量操作
1 parent b8dd366 commit 97dff44

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,17 @@ WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream i
249249
*/
250250
void userDelete(String userid) throws WxErrorException;
251251

252+
/**
253+
* <pre>
254+
* 批量删除成员
255+
*
256+
* 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
257+
* </pre>
258+
* @param userids 员工UserID列表。对应管理端的帐号
259+
* @throws WxErrorException
260+
*/
261+
void userDelete(String[] userids) throws WxErrorException;
262+
252263
/**
253264
* 获取用户
254265
*

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,18 @@ public void userDelete(String userid) throws WxErrorException {
219219
get(url, null);
220220
}
221221

222+
@Override
223+
public void userDelete(String[] userids) throws WxErrorException {
224+
String url = "https://qyapi.weixin.qq.com/cgi-bin/user/batchdelete";
225+
JsonObject jsonObject = new JsonObject();
226+
JsonArray jsonArray = new JsonArray();
227+
for (int i = 0; i < userids.length; i++) {
228+
jsonArray.add(new JsonPrimitive(userids[i]));
229+
}
230+
jsonObject.add("useridlist", jsonArray);
231+
post(url, jsonObject.toString());
232+
}
233+
222234
@Override
223235
public WxCpUser userGet(String userid) throws WxErrorException {
224236
String url = "https://qyapi.weixin.qq.com/cgi-bin/user/get?userid=" + userid;

0 commit comments

Comments
 (0)