mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-04-24 08:57:16 +08:00
issue #90 WxMpUser添加sexId字段,和微信返回的性别字段保持一致
This commit is contained in:
parent
4dc297c5ed
commit
6d383fa90e
@ -20,7 +20,11 @@ public class WxMpUser {
|
||||
protected String headImgUrl;
|
||||
protected Long subscribeTime;
|
||||
protected String unionId;
|
||||
|
||||
protected Integer sexId;
|
||||
|
||||
public Boolean getSubscribe() {
|
||||
return subscribe;
|
||||
}
|
||||
public Boolean isSubscribe() {
|
||||
return subscribe;
|
||||
}
|
||||
@ -87,7 +91,16 @@ public class WxMpUser {
|
||||
public void setUnionId(String unionId) {
|
||||
this.unionId = unionId;
|
||||
}
|
||||
|
||||
|
||||
public Integer getSexId() {
|
||||
|
||||
return sexId;
|
||||
}
|
||||
|
||||
public void setSexId(Integer sexId) {
|
||||
this.sexId = sexId;
|
||||
}
|
||||
|
||||
public static WxMpUser fromJson(String json) {
|
||||
return WxMpGsonBuilder.INSTANCE.create().fromJson(json, WxMpUser.class);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public class WxMpGsonBuilder {
|
||||
INSTANCE.registerTypeAdapter(WxMpMassGroupMessage.class, new WxMpMassGroupMessageGsonAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxMpMassOpenIdsMessage.class, new WxMpMassOpenIdsMessageGsonAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxMpGroup.class, new WxMpGroupGsonAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxMpUser.class, new WxUserGsonAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxMpUser.class, new WxMpUserGsonAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxMpUserList.class, new WxUserListGsonAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxMpMassVideo.class, new WxMpMassVideoAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxMpMassSendResult.class, new WxMpMassSendResultAdapter());
|
||||
|
@ -14,7 +14,7 @@ import me.chanjar.weixin.mp.bean.result.WxMpUser;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
public class WxUserGsonAdapter implements JsonDeserializer<WxMpUser> {
|
||||
public class WxMpUserGsonAdapter implements JsonDeserializer<WxMpUser> {
|
||||
|
||||
public WxMpUser deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
JsonObject o = json.getAsJsonObject();
|
||||
@ -29,10 +29,11 @@ public class WxUserGsonAdapter implements JsonDeserializer<WxMpUser> {
|
||||
wxMpUser.setProvince(GsonHelper.getString(o, "province"));
|
||||
wxMpUser.setSubscribeTime(GsonHelper.getLong(o, "subscribe_time"));
|
||||
wxMpUser.setUnionId(GsonHelper.getString(o, "unionid"));
|
||||
Integer sex = GsonHelper.getInteger(o, "sex");
|
||||
if(new Integer(1).equals(sex)) {
|
||||
Integer sexId = GsonHelper.getInteger(o, "sex");
|
||||
wxMpUser.setSexId(sexId);
|
||||
if(new Integer(1).equals(sexId)) {
|
||||
wxMpUser.setSex("男");
|
||||
} else if (new Integer(2).equals(sex)) {
|
||||
} else if (new Integer(2).equals(sexId)) {
|
||||
wxMpUser.setSex("女");
|
||||
} else {
|
||||
wxMpUser.setSex("未知");
|
Loading…
Reference in New Issue
Block a user