Skip to content

Commit 6ce418a

Browse files
jinxiaoyijinxiaoyi
andauthored
🎨【企业微信】获取客服账号列表接口增加分页支持
Co-authored-by: jinxiaoyi <jinxiaoyi@gaohua-tech.cn>
1 parent 3952fcd commit 6ce418a

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpKfService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,12 @@ public interface WxCpKfService {
4747

4848
/**
4949
* 获取客服帐号列表,包括所有的客服帐号的客服ID、名称和头像。
50-
*
50+
* @param offset 分页,偏移量, 默认为0
51+
* @param limit 分页,预期请求的数据量,默认为100,取值范围 1 ~ 100
5152
* @return 客服帐号列表
5253
* @throws WxErrorException 异常
5354
*/
54-
WxCpKfAccountListResp listAccount() throws WxErrorException;
55+
WxCpKfAccountListResp listAccount(Integer offset,Integer limit) throws WxErrorException;
5556

5657
/**
5758
* 企业可通过此接口获取带有不同参数的客服链接,不同客服帐号对应不同的客服链接。获取后,企业可将链接嵌入到网页等场景中,

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpKfServiceImpl.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,16 @@ public WxCpBaseResp delAccount(WxCpKfAccountDel del) throws WxErrorException {
4949
}
5050

5151
@Override
52-
public WxCpKfAccountListResp listAccount() throws WxErrorException {
52+
public WxCpKfAccountListResp listAccount(Integer offset,Integer limit) throws WxErrorException {
5353
String url = cpService.getWxCpConfigStorage().getApiUrl(ACCOUNT_LIST);
54-
String responseContent = cpService.post(url, "{}");
54+
JsonObject json = new JsonObject();
55+
if (offset != null) {
56+
json.addProperty("offset", offset);
57+
}
58+
if (limit != null) {
59+
json.addProperty("limit", limit);
60+
}
61+
String responseContent = cpService.post(url, json.toString());
5562
return WxCpKfAccountListResp.fromJson(responseContent);
5663
}
5764

weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpKfServiceImplTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void testAccountUpd() throws Exception {
5858

5959
@Test(priority = 3)
6060
public void testAccountList() throws Exception {
61-
WxCpKfAccountListResp resp = this.wxService.getKfService().listAccount();
61+
WxCpKfAccountListResp resp = this.wxService.getKfService().listAccount(0,10);
6262
System.out.println(resp);
6363
}
6464

0 commit comments

Comments
 (0)