Browse Source

:new: #2181【企业微信】增加支持传入groupId参数的获取企业标签库接口实现

wrinkle 3 years ago
parent
commit
568d02c25e

+ 14 - 0
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpExternalContactService.java

@@ -457,6 +457,20 @@ public interface WxCpExternalContactService {
 
   /**
    * <pre>
+   * 企业可通过此接口获取企业客户标签详情。
+   * 若tag_id和group_id均为空,则返回所有标签。
+   * 同时传递tag_id和group_id时,忽略tag_id,仅以group_id作为过滤条件。
+   * </pre>
+   *
+   * @param tagId the tag id
+   * @param groupId the tagGroup id
+   * @return corp tag list
+   * @throws WxErrorException the wx error exception
+   */
+  WxCpUserExternalTagGroupList getCorpTagList(String[] tagId, String[] groupId) throws WxErrorException;
+
+  /**
+   * <pre>
    * 企业可通过此接口向客户标签库中添加新的标签组和标签,每个企业最多可配置3000个企业标签。
    * 暂不支持第三方调用。
    * </pre>

+ 14 - 0
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImpl.java

@@ -335,6 +335,20 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
   }
 
   @Override
+  public WxCpUserExternalTagGroupList getCorpTagList(String[] tagId, String[] groupId) throws WxErrorException {
+    JsonObject json = new JsonObject();
+    if (ArrayUtils.isNotEmpty(tagId)) {
+      json.add("tag_id", new Gson().toJsonTree(tagId).getAsJsonArray());
+    }
+    if (ArrayUtils.isNotEmpty(groupId)) {
+      json.add("group_id", new Gson().toJsonTree(groupId).getAsJsonArray());
+    }
+    final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CORP_TAG_LIST);
+    final String result = this.mainService.post(url, json.toString());
+    return WxCpUserExternalTagGroupList.fromJson(result);
+  }
+
+  @Override
   public WxCpUserExternalTagGroupInfo addCorpTag(WxCpUserExternalTagGroupInfo tagGroup) throws WxErrorException {
 
     final String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_CORP_TAG);