修改方法返回类型,保证标签Id与其他地方一致

This commit is contained in:
BinaryWang 2016-10-13 09:11:15 +08:00
parent e8d368f212
commit cd026278c2
3 changed files with 18 additions and 14 deletions

View File

@ -94,8 +94,8 @@ public interface WxMpUserTagService {
* 详情请见<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/getidlist?access_token=ACCESS_TOKEN
* </pre>
*
* @return 标签Id的列表
*/
List<Integer> userTagList(String openid) throws WxErrorException;
List<Long> userTagList(String openid) throws WxErrorException;
}

View File

@ -1,9 +1,14 @@
package me.chanjar.weixin.mp.api.impl;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.reflect.TypeToken;
import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
@ -11,9 +16,6 @@ import me.chanjar.weixin.mp.api.WxMpUserTagService;
import me.chanjar.weixin.mp.bean.tag.WxTagListUser;
import me.chanjar.weixin.mp.bean.tag.WxUserTag;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
/**
*
@ -144,7 +146,7 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService {
}
@Override
public List<Integer> userTagList(String openid) throws WxErrorException {
public List<Long> userTagList(String openid) throws WxErrorException {
String url = API_URL_PREFIX + "/getidlist";
JsonObject json = new JsonObject();
@ -154,7 +156,7 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService {
return WxMpGsonBuilder.create().fromJson(
new JsonParser().parse(responseContent).getAsJsonObject().get("tagid_list"),
new TypeToken<List<Integer>>() {
new TypeToken<List<Long>>() {
}.getType());
}
}

View File

@ -1,15 +1,17 @@
package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.mp.api.ApiTestModule;
import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage;
import me.chanjar.weixin.mp.bean.tag.WxTagListUser;
import me.chanjar.weixin.mp.bean.tag.WxUserTag;
import java.util.List;
import org.testng.Assert;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import java.util.List;
import com.google.inject.Inject;
import me.chanjar.weixin.mp.api.ApiTestModule;
import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage;
import me.chanjar.weixin.mp.bean.tag.WxTagListUser;
import me.chanjar.weixin.mp.bean.tag.WxUserTag;
/**
*
@ -80,7 +82,7 @@ public class WxMpUserTagServiceImplTest {
@Test
public void testUserTagList() throws Exception {
List<Integer> res = this.wxService.getUserTagService().userTagList(
List<Long> res = this.wxService.getUserTagService().userTagList(
((WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage()).getOpenid());
System.out.println(res);
Assert.assertNotNull(res);