diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImpl.java index f9058f0179..b38c6b868c 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImpl.java @@ -239,7 +239,7 @@ public WxCpUserExternalTagGroupList getCorpTagList(String[] tagId) throws WxErro public WxCpUserExternalTagGroupInfo addCorpTag(WxCpUserExternalTagGroupInfo tagGroup) throws WxErrorException{ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_CORP_TAG); - final String result = this.mainService.post(url,tagGroup.toJson()); + final String result = this.mainService.post(url,tagGroup.getTagGroup().toJson()); return WxCpUserExternalTagGroupInfo.fromJson(result); } @@ -262,7 +262,7 @@ public WxCpBaseResp delCorpTag(String[] tagId, String[] groupId) throws WxErrorE json.add("tag_id",new Gson().toJsonTree(tagId).getAsJsonArray()); } if(ArrayUtils.isNotEmpty(groupId)){ - json.add("group_id",new Gson().toJsonTree(tagId).getAsJsonArray()); + json.add("group_id",new Gson().toJsonTree(groupId).getAsJsonArray()); } final String url = this.mainService.getWxCpConfigStorage().getApiUrl(DEL_CORP_TAG); diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUserExternalTagGroupInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUserExternalTagGroupInfo.java index 16d20d7eca..d0aa9fe327 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUserExternalTagGroupInfo.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUserExternalTagGroupInfo.java @@ -15,24 +15,35 @@ @Setter public class WxCpUserExternalTagGroupInfo extends WxCpBaseResp { - @SerializedName("group_id") - private String groupId; + @SerializedName("tag_group") + private TagGroup tagGroup; - @SerializedName("group_name") - private String groupName; + @Getter + @Setter + public static class TagGroup { + + @SerializedName("group_id") + private String groupId; + + @SerializedName("group_name") + private String groupName; - @SerializedName("create_time") - private Long createTime; + @SerializedName("create_time") + private Long createTime; - @SerializedName("order") - private Integer order; + @SerializedName("order") + private Integer order; - @SerializedName("deleted") - private Boolean deleted; + @SerializedName("deleted") + private Boolean deleted; + @SerializedName("tag") + private List tag; - @SerializedName("tag") - private List tag; + public String toJson() { + return WxGsonBuilder.create().toJson(this); + } + } @Getter @Setter diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImplTest.java index 2c63496f3f..df086037a5 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImplTest.java @@ -117,20 +117,20 @@ public void testAddCorpTag() throws WxErrorException { List list = new ArrayList<>(); WxCpUserExternalTagGroupInfo.Tag tag = new WxCpUserExternalTagGroupInfo.Tag(); - tag.setName("测试标签2"); + tag.setName("测试标签20"); tag.setOrder(1); list.add(tag); - WxCpUserExternalTagGroupInfo tagGroup = new WxCpUserExternalTagGroupInfo(); + WxCpUserExternalTagGroupInfo tagGroupInfo = new WxCpUserExternalTagGroupInfo(); + WxCpUserExternalTagGroupInfo.TagGroup tagGroup = new WxCpUserExternalTagGroupInfo.TagGroup(); tagGroup.setGroupName("其他"); tagGroup.setOrder(1); tagGroup.setTag(list); + tagGroupInfo.setTagGroup(tagGroup); - WxCpUserExternalTagGroupInfo result = this.wxCpService.getExternalContactService().addCorpTag(tagGroup); + WxCpUserExternalTagGroupInfo result = this.wxCpService.getExternalContactService().addCorpTag(tagGroupInfo); - - - System.out.println(result); + System.out.println(result.toJson()); assertNotNull(result); } @@ -146,8 +146,8 @@ public void testEditCorpTag() throws WxErrorException { @Test public void testDelCorpTag() throws WxErrorException { - String tagId[] = {"et2omCCwAA6PtGsfeEOQMENl3Ub1FA6A"}; - String groupId[] = {}; + String tagId[] = {}; + String groupId[] = {"et2omCCwAAM3WzL00QpK9xARab3HGkAg"}; WxCpBaseResp result = this.wxCpService.getExternalContactService().delCorpTag(tagId,groupId);