From 88ac9f4c18b80d38e2321688ad0670d7867134d6 Mon Sep 17 00:00:00 2001 From: zhongjun Date: Mon, 18 Apr 2022 17:14:54 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat(=E4=BC=81=E4=B8=9A=E5=BE=AE=E4=BF=A1):?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=80=9A=E8=AE=AF=E5=BD=95=E7=AE=A1=E7=90=86?= =?UTF-8?q?-=E5=BC=82=E6=AD=A5=E6=89=B9=E9=87=8F=E6=8E=A5=E5=8F=A3-?= =?UTF-8?q?=E5=A2=9E=E9=87=8F=E6=9B=B4=E6=96=B0=E6=88=90=E5=91=98=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/me/chanjar/weixin/cp/api/WxCpService.java | 8 ++++++++ .../chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java | 7 +++++++ .../me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java | 1 + 3 files changed, 16 insertions(+) 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 ddb3968c22..47188ba5a8 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 + * @throws WxErrorException the wx error exception + */ + String syncUser(String mediaId) throws WxErrorException; + /** * 上传用户列表覆盖企业号上的用户信息 * 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 55ddcf9e23..d9a80937e4 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,13 @@ 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); + return post(this.configStorage.getApiUrl(BATCH_SYNC_USER), jsonObject.toString()); + } + @Override public String replaceUser(String mediaId) throws WxErrorException { JsonObject jsonObject = new JsonObject(); 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 cd43d3472d..8c45a676e4 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"; From 81c84be40f533c10f78313122581fc0a12a362a3 Mon Sep 17 00:00:00 2001 From: zhongjun Date: Mon, 18 Apr 2022 17:19:34 +0800 Subject: [PATCH 2/4] update params name --- .../src/main/java/me/chanjar/weixin/cp/api/WxCpService.java | 4 ++-- .../me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java | 4 ++-- 2 files changed, 4 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 47188ba5a8..b6b6afbf5c 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 @@ -283,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 d9a80937e4..c6d6c79c8f 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 @@ -423,8 +423,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); } From 9377377fe6712e158b90d8bf735b25ff1db8914c Mon Sep 17 00:00:00 2001 From: zhongjun Date: Mon, 18 Apr 2022 18:27:12 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=BF=94=E5=9B=9EjobId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/me/chanjar/weixin/cp/api/WxCpService.java | 2 +- .../me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java | 5 ++++- 2 files changed, 5 insertions(+), 2 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 b6b6afbf5c..76f337f8e2 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 @@ -266,7 +266,7 @@ public interface WxCpService extends WxService { /** * 上传用户列表,增量更新成员 * @param mediaId 媒体id - * @return jobId + * @return jobId 异步任务id * @throws WxErrorException the wx error exception */ String syncUser(String mediaId) throws WxErrorException; 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 c6d6c79c8f..bd1a4c6798 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 @@ -18,6 +18,7 @@ import me.chanjar.weixin.common.util.RandomUtils; import me.chanjar.weixin.common.util.crypto.SHA1; import me.chanjar.weixin.common.util.http.*; +import me.chanjar.weixin.common.util.json.GsonHelper; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.api.*; import me.chanjar.weixin.cp.bean.WxCpAgentJsapiSignature; @@ -412,7 +413,9 @@ public String replaceParty(String mediaId) throws WxErrorException { public String syncUser(String mediaId) throws WxErrorException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("media_id", mediaId); - return post(this.configStorage.getApiUrl(BATCH_SYNC_USER), jsonObject.toString()); + String responseContent = post(this.configStorage.getApiUrl(BATCH_SYNC_USER), jsonObject.toString()); + JsonObject tmpJson = GsonParser.parse(responseContent); + return tmpJson.get("jobid").getAsString(); } @Override From e27f1807a75728425843342b80ea95d7e71f705b Mon Sep 17 00:00:00 2001 From: zhongjun Date: Mon, 18 Apr 2022 18:33:20 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E6=9C=AA=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java | 1 - 1 file changed, 1 deletion(-) 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 bd1a4c6798..263fa87a76 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 @@ -18,7 +18,6 @@ import me.chanjar.weixin.common.util.RandomUtils; import me.chanjar.weixin.common.util.crypto.SHA1; import me.chanjar.weixin.common.util.http.*; -import me.chanjar.weixin.common.util.json.GsonHelper; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.cp.api.*; import me.chanjar.weixin.cp.bean.WxCpAgentJsapiSignature;