From 6ce418a7193482a651a958278a096698eb9f5c39 Mon Sep 17 00:00:00 2001 From: jinxiaoyi <34831856+jinxiaoyi@users.noreply.github.com> Date: Sun, 5 Jun 2022 22:35:56 +0800 Subject: [PATCH] =?UTF-8?q?:art:=E3=80=90=E4=BC=81=E4=B8=9A=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E3=80=91=E8=8E=B7=E5=8F=96=E5=AE=A2=E6=9C=8D=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=88=86=E9=A1=B5=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: jinxiaoyi --- .../java/me/chanjar/weixin/cp/api/WxCpKfService.java | 5 +++-- .../chanjar/weixin/cp/api/impl/WxCpKfServiceImpl.java | 11 +++++++++-- .../weixin/cp/api/impl/WxCpKfServiceImplTest.java | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpKfService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpKfService.java index 0795fb724..ed8e00dc5 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpKfService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpKfService.java @@ -47,11 +47,12 @@ public interface WxCpKfService { /** * 获取客服帐号列表,包括所有的客服帐号的客服ID、名称和头像。 - * + * @param offset 分页,偏移量, 默认为0 + * @param limit 分页,预期请求的数据量,默认为100,取值范围 1 ~ 100 * @return 客服帐号列表 * @throws WxErrorException 异常 */ - WxCpKfAccountListResp listAccount() throws WxErrorException; + WxCpKfAccountListResp listAccount(Integer offset,Integer limit) throws WxErrorException; /** * 企业可通过此接口获取带有不同参数的客服链接,不同客服帐号对应不同的客服链接。获取后,企业可将链接嵌入到网页等场景中, diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpKfServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpKfServiceImpl.java index 26afa1d64..8598afc52 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpKfServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpKfServiceImpl.java @@ -49,9 +49,16 @@ public class WxCpKfServiceImpl implements WxCpKfService { } @Override - public WxCpKfAccountListResp listAccount() throws WxErrorException { + public WxCpKfAccountListResp listAccount(Integer offset,Integer limit) throws WxErrorException { String url = cpService.getWxCpConfigStorage().getApiUrl(ACCOUNT_LIST); - String responseContent = cpService.post(url, "{}"); + JsonObject json = new JsonObject(); + if (offset != null) { + json.addProperty("offset", offset); + } + if (limit != null) { + json.addProperty("limit", limit); + } + String responseContent = cpService.post(url, json.toString()); return WxCpKfAccountListResp.fromJson(responseContent); } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpKfServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpKfServiceImplTest.java index 09a4f568c..d45fba83f 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpKfServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpKfServiceImplTest.java @@ -58,7 +58,7 @@ public class WxCpKfServiceImplTest { @Test(priority = 3) public void testAccountList() throws Exception { - WxCpKfAccountListResp resp = this.wxService.getKfService().listAccount(); + WxCpKfAccountListResp resp = this.wxService.getKfService().listAccount(0,10); System.out.println(resp); }