This commit is contained in:
Daniel Qian
2014-11-26 21:16:44 +08:00
parent 08405a879d
commit 6027125025
2 changed files with 30 additions and 2 deletions

View File

@@ -119,6 +119,8 @@ public class WxCpMessageRouter {
private boolean async = true;
private String fromUser;
private String msgType;
private String event;
@@ -212,6 +214,16 @@ public class WxCpMessageRouter {
return this;
}
/**
* 如果fromUser等于某值
* @param fromUser
* @return
*/
public Rule fromUser(String fromUser) {
this.fromUser = fromUser;
return this;
}
/**
* 设置微信消息拦截器
* @param interceptor
@@ -282,6 +294,8 @@ public class WxCpMessageRouter {
protected boolean test(WxCpXmlMessage wxMessage) {
return
(this.fromUser == null || this.fromUser.equals(wxMessage.getFromUserName()))
&&
(this.agentId == null || this.agentId.equals(wxMessage.getAgentId()))
&&
(this.msgType == null || this.msgType.equals(wxMessage.getMsgType()))