mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-05 05:07:46 +08:00
#358 针对微信网页授权为snsapi_userinfo时,WxMpUser类中增加privilege字段
This commit is contained in:
parent
7118255be7
commit
ff3cdb1487
@ -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));
|
||||
|
@ -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);
|
||||
|
@ -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("男");
|
||||
|
Loading…
Reference in New Issue
Block a user