Browse Source

WxMenuButton增加缺失的media_id字段

master
BinaryWang 8 years ago
parent
commit
184e6d785a
2 changed files with 15 additions and 3 deletions
  1. +13
    -3
      weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuButton.java
  2. +2
    -0
      weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxMenuGsonAdapter.java

+ 13
- 3
weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuButton.java View File

@@ -12,9 +12,16 @@ public class WxMenuButton {
private String name; private String name;
private String key; private String key;
private String url; private String url;
private String mediaId;


private List<WxMenuButton> subButtons = new ArrayList<WxMenuButton>(); private List<WxMenuButton> subButtons = new ArrayList<WxMenuButton>();


@Override
public String toString() {
return ToStringBuilder.reflectionToString(this,
ToStringStyle.JSON_STYLE);
}
public String getType() { public String getType() {
return type; return type;
} }
@@ -55,8 +62,11 @@ public class WxMenuButton {
this.subButtons = subButtons; this.subButtons = subButtons;
} }


@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
public String getMediaId() {
return mediaId;
}

public void setMediaId(String mediaId) {
this.mediaId = mediaId;
} }
} }

+ 2
- 0
weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxMenuGsonAdapter.java View File

@@ -52,6 +52,7 @@ public class WxMenuGsonAdapter implements JsonSerializer<WxMenu>, JsonDeserializ
buttonJson.addProperty("name", button.getName()); buttonJson.addProperty("name", button.getName());
buttonJson.addProperty("key", button.getKey()); buttonJson.addProperty("key", button.getKey());
buttonJson.addProperty("url", button.getUrl()); buttonJson.addProperty("url", button.getUrl());
buttonJson.addProperty("media_id", button.getMediaId());
if (button.getSubButtons() != null && button.getSubButtons().size() > 0) { if (button.getSubButtons() != null && button.getSubButtons().size() > 0) {
JsonArray buttonArray = new JsonArray(); JsonArray buttonArray = new JsonArray();
for (WxMenuButton sub_button : button.getSubButtons()) { for (WxMenuButton sub_button : button.getSubButtons()) {
@@ -105,6 +106,7 @@ public class WxMenuGsonAdapter implements JsonSerializer<WxMenu>, JsonDeserializ
button.setKey(GsonHelper.getString(json, "key")); button.setKey(GsonHelper.getString(json, "key"));
button.setUrl(GsonHelper.getString(json, "url")); button.setUrl(GsonHelper.getString(json, "url"));
button.setType(GsonHelper.getString(json, "type")); button.setType(GsonHelper.getString(json, "type"));
button.setMediaId(GsonHelper.getString(json, "media_id"));
return button; return button;
} }




Loading…
Cancel
Save