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