From 050dafbd42468f88fd45dff885008a113c2c9ec4 Mon Sep 17 00:00:00 2001 From: zhongjun Date: Tue, 19 Apr 2022 17:31:31 +0800 Subject: [PATCH] =?UTF-8?q?:new:=20#2596=20=E3=80=90=E4=BC=81=E4=B8=9A?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E3=80=91=E6=96=B0=E5=A2=9E=E9=80=9A=E8=AE=AF?= =?UTF-8?q?=E5=BD=95=E7=AE=A1=E7=90=86-=E5=BC=82=E6=AD=A5=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E5=A2=9E=E9=87=8F=E6=9B=B4=E6=96=B0=E6=88=90=E5=91=98?= =?UTF-8?q?=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/chanjar/weixin/cp/api/WxCpService.java | 12 ++++++++++-- .../weixin/cp/api/impl/BaseWxCpServiceImpl.java | 13 +++++++++++-- .../weixin/cp/constant/WxCpApiPathConsts.java | 1 + 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java index ddb3968c2..76f337f8e 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java @@ -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; + /** * 上传用户列表覆盖企业号上的用户信息 * @@ -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请求对象 diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java index 55ddcf9e2..263fa87a7 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java @@ -408,6 +408,15 @@ public abstract class BaseWxCpServiceImpl implements WxCpService, RequestH 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(); @@ -416,8 +425,8 @@ public abstract class BaseWxCpServiceImpl implements WxCpService, RequestH } @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); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java index cd43d3472..8c45a676e 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java @@ -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";