Skip to content

Commit

Permalink
🆕 #2596 【企业微信】新增通讯录管理-异步批量增量更新成员的接口
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongjun96 authored Apr 19, 2022
1 parent 062eb6c commit 050dafb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,14 @@ public interface WxCpService extends WxService {
*/
String replaceParty(String mediaId) throws WxErrorException;

/**
* 上传用户列表,增量更新成员
* @param mediaId 媒体id
* @return jobId 异步任务id
* @throws WxErrorException the wx error exception
*/
String syncUser(String mediaId) throws WxErrorException;

/**
* 上传用户列表覆盖企业号上的用户信息
*
Expand All @@ -275,11 +283,11 @@ public interface WxCpService extends WxService {
/**
* 获取异步任务结果
*
* @param joinId the join id
* @param jobId 异步任务id
* @return the task result
* @throws WxErrorException the wx error exception
*/
String getTaskResult(String joinId) throws WxErrorException;
String getTaskResult(String jobId) throws WxErrorException;

/**
* 初始化http请求对象
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,15 @@ public String replaceParty(String mediaId) throws WxErrorException {
return post(this.configStorage.getApiUrl(BATCH_REPLACE_PARTY), jsonObject.toString());
}

@Override
public String syncUser(String mediaId) throws WxErrorException {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("media_id", mediaId);
String responseContent = post(this.configStorage.getApiUrl(BATCH_SYNC_USER), jsonObject.toString());
JsonObject tmpJson = GsonParser.parse(responseContent);
return tmpJson.get("jobid").getAsString();
}

@Override
public String replaceUser(String mediaId) throws WxErrorException {
JsonObject jsonObject = new JsonObject();
Expand All @@ -416,8 +425,8 @@ public String replaceUser(String mediaId) throws WxErrorException {
}

@Override
public String getTaskResult(String joinId) throws WxErrorException {
String url = this.configStorage.getApiUrl(BATCH_GET_RESULT + joinId);
public String getTaskResult(String jobId) throws WxErrorException {
String url = this.configStorage.getApiUrl(BATCH_GET_RESULT + jobId);
return get(url, null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public interface WxCpApiPathConsts {
String GET_AGENT_CONFIG_TICKET = "/cgi-bin/ticket/get?&type=agent_config";
String GET_CALLBACK_IP = "/cgi-bin/getcallbackip";
String BATCH_REPLACE_PARTY = "/cgi-bin/batch/replaceparty";
String BATCH_SYNC_USER = "/cgi-bin/batch/syncuser";
String BATCH_REPLACE_USER = "/cgi-bin/batch/replaceuser";
String BATCH_GET_RESULT = "/cgi-bin/batch/getresult?jobid=";
String JSCODE_TO_SESSION = "/cgi-bin/miniprogram/jscode2session";
Expand Down

0 comments on commit 050dafb

Please sign in to comment.