Skip to content

Commit 050dafb

Browse files
authored
🆕 #2596 【企业微信】新增通讯录管理-异步批量增量更新成员的接口
1 parent 062eb6c commit 050dafb

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

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

+10-2
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,14 @@ public interface WxCpService extends WxService {
263263
*/
264264
String replaceParty(String mediaId) throws WxErrorException;
265265

266+
/**
267+
* 上传用户列表,增量更新成员
268+
* @param mediaId 媒体id
269+
* @return jobId 异步任务id
270+
* @throws WxErrorException the wx error exception
271+
*/
272+
String syncUser(String mediaId) throws WxErrorException;
273+
266274
/**
267275
* 上传用户列表覆盖企业号上的用户信息
268276
*
@@ -275,11 +283,11 @@ public interface WxCpService extends WxService {
275283
/**
276284
* 获取异步任务结果
277285
*
278-
* @param joinId the join id
286+
* @param jobId 异步任务id
279287
* @return the task result
280288
* @throws WxErrorException the wx error exception
281289
*/
282-
String getTaskResult(String joinId) throws WxErrorException;
290+
String getTaskResult(String jobId) throws WxErrorException;
283291

284292
/**
285293
* 初始化http请求对象

Diff for: weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,15 @@ public String replaceParty(String mediaId) throws WxErrorException {
408408
return post(this.configStorage.getApiUrl(BATCH_REPLACE_PARTY), jsonObject.toString());
409409
}
410410

411+
@Override
412+
public String syncUser(String mediaId) throws WxErrorException {
413+
JsonObject jsonObject = new JsonObject();
414+
jsonObject.addProperty("media_id", mediaId);
415+
String responseContent = post(this.configStorage.getApiUrl(BATCH_SYNC_USER), jsonObject.toString());
416+
JsonObject tmpJson = GsonParser.parse(responseContent);
417+
return tmpJson.get("jobid").getAsString();
418+
}
419+
411420
@Override
412421
public String replaceUser(String mediaId) throws WxErrorException {
413422
JsonObject jsonObject = new JsonObject();
@@ -416,8 +425,8 @@ public String replaceUser(String mediaId) throws WxErrorException {
416425
}
417426

418427
@Override
419-
public String getTaskResult(String joinId) throws WxErrorException {
420-
String url = this.configStorage.getApiUrl(BATCH_GET_RESULT + joinId);
428+
public String getTaskResult(String jobId) throws WxErrorException {
429+
String url = this.configStorage.getApiUrl(BATCH_GET_RESULT + jobId);
421430
return get(url, null);
422431
}
423432

Diff for: weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public interface WxCpApiPathConsts {
1616
String GET_AGENT_CONFIG_TICKET = "/cgi-bin/ticket/get?&type=agent_config";
1717
String GET_CALLBACK_IP = "/cgi-bin/getcallbackip";
1818
String BATCH_REPLACE_PARTY = "/cgi-bin/batch/replaceparty";
19+
String BATCH_SYNC_USER = "/cgi-bin/batch/syncuser";
1920
String BATCH_REPLACE_USER = "/cgi-bin/batch/replaceuser";
2021
String BATCH_GET_RESULT = "/cgi-bin/batch/getresult?jobid=";
2122
String JSCODE_TO_SESSION = "/cgi-bin/miniprogram/jscode2session";

0 commit comments

Comments
 (0)