#358 针对微信网页授权为snsapi_userinfo时,WxMpUser类中增加privilege字段

This commit is contained in:
Binary Wang 2017-12-16 13:47:44 +08:00
parent 7118255be7
commit ff3cdb1487
3 changed files with 18 additions and 0 deletions

View File

@ -129,6 +129,19 @@ public class GsonHelper {
return result.toArray(new Integer[0]);
}
public static String[] getStringArray(JsonObject o, String string) {
JsonArray jsonArray = getAsJsonArray(o.getAsJsonArray(string));
if (jsonArray == null) {
return null;
}
List<String> result = Lists.newArrayList();
for (int i = 0; i < jsonArray.size(); i++) {
result.add(jsonArray.get(i).getAsString());
}
return result.toArray(new String[0]);
}
public static Long[] getLongArray(JsonObject o, String string) {
JsonArray jsonArray = getAsJsonArray(o.getAsJsonArray(string));

View File

@ -44,6 +44,10 @@ public class WxMpUser implements Serializable {
private String remark;
private Integer groupId;
private Long[] tagIds;
/**
* 用户特权信息json 数组如微信沃卡用户为chinaunicom
*/
private String[] privileges;
public static WxMpUser fromJson(String json) {
return WxMpGsonBuilder.INSTANCE.create().fromJson(json, WxMpUser.class);

View File

@ -37,6 +37,7 @@ public class WxMpUserGsonAdapter implements JsonDeserializer<WxMpUser> {
wxMpUser.setRemark(GsonHelper.getString(o, "remark"));
wxMpUser.setGroupId(GsonHelper.getInteger(o, "groupid"));
wxMpUser.setTagIds(GsonHelper.getLongArray(o, "tagid_list"));
wxMpUser.setPrivileges(GsonHelper.getStringArray(o, "privilege"));
wxMpUser.setSexId(sexId);
if (new Integer(1).equals(sexId)) {
wxMpUser.setSex("");