@@ -129,6 +129,19 @@ public class GsonHelper { | |||||
return result.toArray(new Integer[0]); | 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) { | public static Long[] getLongArray(JsonObject o, String string) { | ||||
JsonArray jsonArray = getAsJsonArray(o.getAsJsonArray(string)); | JsonArray jsonArray = getAsJsonArray(o.getAsJsonArray(string)); | ||||
@@ -44,6 +44,10 @@ public class WxMpUser implements Serializable { | |||||
private String remark; | private String remark; | ||||
private Integer groupId; | private Integer groupId; | ||||
private Long[] tagIds; | private Long[] tagIds; | ||||
/** | |||||
* 用户特权信息,json 数组,如微信沃卡用户为(chinaunicom) | |||||
*/ | |||||
private String[] privileges; | |||||
public static WxMpUser fromJson(String json) { | public static WxMpUser fromJson(String json) { | ||||
return WxMpGsonBuilder.INSTANCE.create().fromJson(json, WxMpUser.class); | return WxMpGsonBuilder.INSTANCE.create().fromJson(json, WxMpUser.class); | ||||
@@ -37,6 +37,7 @@ public class WxMpUserGsonAdapter implements JsonDeserializer<WxMpUser> { | |||||
wxMpUser.setRemark(GsonHelper.getString(o, "remark")); | wxMpUser.setRemark(GsonHelper.getString(o, "remark")); | ||||
wxMpUser.setGroupId(GsonHelper.getInteger(o, "groupid")); | wxMpUser.setGroupId(GsonHelper.getInteger(o, "groupid")); | ||||
wxMpUser.setTagIds(GsonHelper.getLongArray(o, "tagid_list")); | wxMpUser.setTagIds(GsonHelper.getLongArray(o, "tagid_list")); | ||||
wxMpUser.setPrivileges(GsonHelper.getStringArray(o, "privilege")); | |||||
wxMpUser.setSexId(sexId); | wxMpUser.setSexId(sexId); | ||||
if (new Integer(1).equals(sexId)) { | if (new Integer(1).equals(sexId)) { | ||||
wxMpUser.setSex("男"); | wxMpUser.setSex("男"); | ||||