Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
chanjarster committed Dec 25, 2015
2 parents 780074f + 03406f1 commit 6a8fd45
Show file tree
Hide file tree
Showing 15 changed files with 463 additions and 251 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ weixin-java-tools
<dependency>
<groupId>me.chanjar</groupId>
<artifactId>weixin-java-mp</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
</dependency>
```

Expand All @@ -33,7 +33,7 @@ weixin-java-tools
<dependency>
<groupId>me.chanjar</groupId>
<artifactId>weixin-java-cp</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>me.chanjar</groupId>
<artifactId>weixin-java-parent</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<packaging>pom</packaging>
<name>WeiXin Java Tools - Parent</name>
<description>微信公众号、企业号上级POM</description>
Expand Down
2 changes: 1 addition & 1 deletion weixin-java-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>me.chanjar</groupId>
<artifactId>weixin-java-parent</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
</parent>

<artifactId>weixin-java-common</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class WxConsts {
public static final String CUSTOM_MSG_NEWS = "news";
public static final String CUSTOM_MSG_FILE = "file";
public static final String CUSTOM_MSG_TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service";
public static final String CUSTOM_MSG_SAFE_NO = "0";
public static final String CUSTOM_MSG_SAFE_YES = "1";

///////////////////////
// 群发消息的消息类型
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
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
Expand All @@ -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;
}
Expand All @@ -27,6 +29,14 @@ public void setButtons(List<WxMenuButton> buttons) {
this.buttons = buttons;
}

public WxMenuRule getMatchRule() {
return matchRule;
}

public void setMatchRule(WxMenuRule matchRule) {
this.matchRule = matchRule;
}

public String toJson() {
return WxGsonBuilder.create().toJson(this);
}
Expand Down Expand Up @@ -118,5 +128,74 @@ public String toString() {
'}';
}
}


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 + '\'' +
"}";
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

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;
Expand All @@ -21,6 +20,8 @@
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;

import me.chanjar.weixin.common.bean.WxMenu;

/**
*
* @author Daniel Qian
Expand All @@ -38,6 +39,11 @@ public JsonElement serialize(WxMenu menu, Type typeOfSrc, JsonSerializationConte
}
json.add("button", buttonArray);

if (menu.getMatchRule() != null) {
Gson gson = new Gson();
json.add("matchrule", gson.toJsonTree(menu.getMatchRule()));
}

return json;
}

Expand Down
2 changes: 1 addition & 1 deletion weixin-java-cp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>me.chanjar</groupId>
<artifactId>weixin-java-parent</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
</parent>

<artifactId>weixin-java-cp</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class WxCpMessage implements Serializable {
private String description;
private String musicUrl;
private String hqMusicUrl;
private String safe;
private List<WxArticle> articles = new ArrayList<WxArticle>();

public String getToUser() {
Expand Down Expand Up @@ -63,6 +64,14 @@ public String getMsgType() {
return msgType;
}

public String getSafe() {
return safe;
}

public void setSafe(String safe) {
this.safe = safe;
}

/**
* <pre>
* 请使用
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.chanjar.weixin.cp.bean.messagebuilder;

import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.cp.bean.WxCpMessage;

public class BaseBuilder<T> {
Expand All @@ -8,6 +9,7 @@ public class BaseBuilder<T> {
protected String toUser;
protected String toParty;
protected String toTag;
protected String safe;

public T agentId(String agentId) {
this.agentId = agentId;
Expand All @@ -29,13 +31,20 @@ public T toTag(String toTag) {
return (T) this;
}

public T safe(String safe) {
this.safe = safe;
return (T) this;
}

public WxCpMessage build() {
WxCpMessage m = new WxCpMessage();
m.setAgentId(this.agentId);
m.setMsgType(this.msgType);
m.setToUser(this.toUser);
m.setToParty(this.toParty);
m.setToTag(this.toTag);
m.setSafe(
(this.safe == null || "".equals(this.safe))? WxConsts.CUSTOM_MSG_SAFE_NO: this.safe);
return m;
}

Expand Down
2 changes: 1 addition & 1 deletion weixin-java-mp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>me.chanjar</groupId>
<artifactId>weixin-java-parent</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
</parent>
<artifactId>weixin-java-mp</artifactId>
<name>WeiXin Java Tools - MP</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ public interface WxMpService {
* <pre>
* 自定义菜单创建接口
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单创建接口
* 如果要创建个性化菜单,请设置matchrule属性
* 详情请见:http://mp.weixin.qq.com/wiki/0/c48ccd12b69ae023159b4bfaa7c39c20.html
* </pre>
* @param menu
* @throws WxErrorException
Expand All @@ -339,6 +341,16 @@ public interface WxMpService {
*/
public void menuDelete() throws WxErrorException;

/**
* <pre>
* 删除个性化菜单接口
* 详情请见: http://mp.weixin.qq.com/wiki/0/c48ccd12b69ae023159b4bfaa7c39c20.html
* </pre>
* @param menuid
* @throws WxErrorException
*/
public void menuDelete(String menuid) throws WxErrorException;

/**
* <pre>
* 自定义菜单查询接口
Expand All @@ -348,6 +360,16 @@ public interface WxMpService {
* @throws WxErrorException
*/
public WxMenu menuGet() throws WxErrorException;

/**
* <pre>
* 测试个性化菜单匹配结果
* 详情请见: http://mp.weixin.qq.com/wiki/0/c48ccd12b69ae023159b4bfaa7c39c20.html
* </pre>
* @param userid 可以是粉丝的OpenID,也可以是粉丝的微信号。
* @throws WxErrorException
*/
public WxMenu menuTryMatch(String userid) throws WxErrorException;

/**
* <pre>
Expand Down
Loading

0 comments on commit 6a8fd45

Please sign in to comment.