mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-09-20 10:38:13 +08:00
@@ -3,13 +3,13 @@ package me.chanjar.weixin.common.bean;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Serializable;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
|
||||
import org.apache.commons.codec.Charsets;
|
||||
|
||||
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
|
||||
|
||||
/**
|
||||
* 企业号菜单
|
||||
* @author Daniel Qian
|
||||
@@ -19,6 +19,8 @@ public class WxMenu implements Serializable {
|
||||
|
||||
private List<WxMenuButton> buttons = new ArrayList<WxMenuButton>();
|
||||
|
||||
private WxMenuRule matchRule;
|
||||
|
||||
public List<WxMenuButton> getButtons() {
|
||||
return buttons;
|
||||
}
|
||||
@@ -27,6 +29,14 @@ public class WxMenu implements Serializable {
|
||||
this.buttons = buttons;
|
||||
}
|
||||
|
||||
public WxMenuRule getMatchRule() {
|
||||
return matchRule;
|
||||
}
|
||||
|
||||
public void setMatchRule(WxMenuRule matchRule) {
|
||||
this.matchRule = matchRule;
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxGsonBuilder.create().toJson(this);
|
||||
}
|
||||
@@ -118,5 +128,74 @@ public class WxMenu implements Serializable {
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class WxMenuRule {
|
||||
private String groupId;
|
||||
private String sex;
|
||||
private String country;
|
||||
private String province;
|
||||
private String city;
|
||||
private String clientPlatformType;
|
||||
|
||||
public String getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public String getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(String sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public String getProvince() {
|
||||
return province;
|
||||
}
|
||||
|
||||
public void setProvince(String province) {
|
||||
this.province = province;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getClientPlatformType() {
|
||||
return clientPlatformType;
|
||||
}
|
||||
|
||||
public void setClientPlatformType(String clientPlatformType) {
|
||||
this.clientPlatformType = clientPlatformType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "matchrule:{" +
|
||||
"group_id='" + groupId + '\'' +
|
||||
", sex='" + sex + '\'' +
|
||||
", country" + country + '\'' +
|
||||
", province" + province + '\'' +
|
||||
", city" + city + '\'' +
|
||||
", client_platform_type" + clientPlatformType + '\'' +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -10,8 +10,7 @@ package me.chanjar.weixin.common.util.json;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import me.chanjar.weixin.common.bean.WxMenu;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
@@ -21,6 +20,8 @@ import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
|
||||
import me.chanjar.weixin.common.bean.WxMenu;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Daniel Qian
|
||||
@@ -38,6 +39,11 @@ public class WxMenuGsonAdapter implements JsonSerializer<WxMenu>, JsonDeserializ
|
||||
}
|
||||
json.add("button", buttonArray);
|
||||
|
||||
if (menu.getMatchRule() != null) {
|
||||
Gson gson = new Gson();
|
||||
json.add("matchrule", gson.toJsonTree(menu.getMatchRule()));
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user