WxMenuButton增加缺失的media_id字段

This commit is contained in:
BinaryWang 2016-08-18 18:01:17 +08:00
parent 977161cbeb
commit 184e6d785a
2 changed files with 15 additions and 3 deletions

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 getMediaId() {
public String toString() { return mediaId;
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE); }
public void setMediaId(String mediaId) {
this.mediaId = mediaId;
} }
} }

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;
} }