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