增加删除标签的接口

This commit is contained in:
BinaryWang 2016-09-13 19:54:03 +08:00
parent ede249643c
commit f13dcaa1fc
3 changed files with 37 additions and 0 deletions

View File

@ -45,4 +45,14 @@ public interface WxMpUserTagService {
*/
Boolean tagUpdate(Integer id, String name) throws WxErrorException;
/**
* <pre>
* 删除标签
* 详情请见<a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140837&token=&lang=zh_CN">用户标签管理</a>
* 接口url格式 https://api.weixin.qq.com/cgi-bin/tags/delete?access_token=ACCESS_TOKEN
* </pre>
*
*/
Boolean tagDelete(Integer id) throws WxErrorException;
}

View File

@ -72,4 +72,24 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService {
throw new WxErrorException(wxError);
}
@Override
public Boolean tagDelete(Integer id) throws WxErrorException {
String url = API_URL_PREFIX + "/delete";
JsonObject json = new JsonObject();
JsonObject tagJson = new JsonObject();
tagJson.addProperty("id", id);
json.add("tag", tagJson);
String responseContent = this.wxMpService.post(url, json.toString());
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, json.toString(),
responseContent);
WxError wxError = WxError.fromJson(responseContent);
if (wxError.getErrorCode() == 0) {
return true;
}
throw new WxErrorException(wxError);
}
}

View File

@ -48,4 +48,11 @@ public class WxMpUserTagServiceImplTest {
Assert.assertTrue(res);
}
@Test(dependsOnMethods = { "testTagCreate" })
public void testTagDelete() throws Exception {
Boolean res = this.wxService.getUserTagService().tagDelete(this.tagId);
System.out.println(res);
Assert.assertTrue(res);
}
}