新增自定义个性化菜单语言信息匹配项

This commit is contained in:
jinyu 2016-01-20 20:15:25 +08:00
parent d3150cc936
commit 5d037b2eb6
4 changed files with 45 additions and 6 deletions

View File

@ -614,3 +614,5 @@
* 2016-01-20
+ weixin4j-mp:新增获取模板和删除模板接口
+ weixin4j-mp:新增自定义个性化菜单语言信息匹配项

View File

@ -203,3 +203,5 @@
* 2016-01-20
+ 新增获取模板和删除模板接口
+ 新增自定义个性化菜单语言信息匹配项

View File

@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.model.Gender;
import com.foxinmy.weixin4j.mp.type.ClientPlatformType;
import com.foxinmy.weixin4j.mp.type.Lang;
/**
* 个性化菜单匹配规则
@ -62,6 +63,10 @@ public class MenuMatchRule implements Serializable {
*/
private ClientPlatformType platformType;
/**
* 请使用 {@link #platform(ClientPlatformType platformType)}}
* @param platform
*/
@JSONField(name = "client_platform_type")
public void platform0(int platform) {
this.platformType = ClientPlatformType.values().length >= platform ? ClientPlatformType
@ -133,6 +138,29 @@ public class MenuMatchRule implements Serializable {
return this;
}
/**
* 语言信息是用户在微信中设置的语言
*/
private Lang language;
/**
* 请使用 {@link #language(Lang language)}
* @param language
*/
@JSONField(name = "language")
public void language0(int language) {
this.language = Lang.values().length >= language ? Lang.values()[language - 1]
: null;
}
public MenuMatchRule language(Lang language) {
if (language != null) {
matchRule.put("language", language.ordinal() + 1);
}
this.language = language;
return this;
}
public ClientPlatformType getPlatformType() {
return platformType;
}
@ -157,6 +185,10 @@ public class MenuMatchRule implements Serializable {
return city;
}
public Lang getLanguage() {
return language;
}
public boolean hasRule() {
return !matchRule.isEmpty();
}
@ -169,6 +201,7 @@ public class MenuMatchRule implements Serializable {
public String toString() {
return "MenuMatchRule [groupId=" + groupId + ", gender=" + gender
+ ", platformType=" + platformType + ", country=" + country
+ ", province=" + province + ", city=" + city + "]";
+ ", province=" + province + ", city=" + city + ", language="
+ language + "]";
}
}

View File

@ -1,8 +1,8 @@
package com.foxinmy.weixin4j.mp.type;
/**
* 国家地区语言版本
*
* @className Lang
* @author jy
* @date 2014年11月5日
@ -10,8 +10,10 @@ package com.foxinmy.weixin4j.mp.type;
* @see
*/
public enum Lang {
zh_CN("简体"), zh_TW("繁体"), en("英语");
zh_CN("简体中文"), zh_TW("繁体中文"), zh_HK("繁体中文"), en("英语"), id("印尼"), ms("马来"), es(
"西班牙"), ko("韩国"), it("意大利"), ja("日本"), pl("波兰"), pt("葡萄牙"), ru("俄国"), th(
"泰文"), vi("越南"), ar("阿拉伯语"), hi("北印度"), he("希伯来"), tr("土耳其"), de(
"德语"), fr("法语");
private String desc;
Lang(String desc) {