44import me .chanjar .weixin .common .api .WxErrorExceptionHandler ;
55import me .chanjar .weixin .common .error .WxErrorException ;
66import me .chanjar .weixin .common .session .WxSessionManager ;
7+ import me .chanjar .weixin .cp .bean .message .WxCpTpXmlMessage ;
78import me .chanjar .weixin .cp .bean .message .WxCpXmlMessage ;
89import me .chanjar .weixin .cp .bean .message .WxCpXmlOutMessage ;
910import me .chanjar .weixin .cp .message .WxCpMessageMatcher ;
@@ -24,29 +25,17 @@ public class WxCpTpMessageRouterRule {
2425
2526 private boolean async = true ;
2627
27- private String fromUser ;
28-
29- private String msgType ;
30-
31- private String event ;
32-
33- private String eventKey ;
34-
35- private String eventKeyRegex ;
36-
37- private String content ;
38-
39- private String rContent ;
40-
4128 private WxCpMessageMatcher matcher ;
4229
4330 private boolean reEnter = false ;
4431
45- private Integer agentId ;
46-
4732 private List <WxCpTpMessageHandler > handlers = new ArrayList <>();
4833
4934 private List <WxCpTpMessageInterceptor > interceptors = new ArrayList <>();
35+ private String suiteId ;
36+ private String infoType ;
37+ private String authCode ;
38+ private String suiteTicket ;
5039
5140 /**
5241 * Instantiates a new Wx cp message router rule.
@@ -68,94 +57,6 @@ public WxCpTpMessageRouterRule async(boolean async) {
6857 return this ;
6958 }
7059
71- /**
72- * 如果agentId匹配
73- *
74- * @param agentId the agent id
75- * @return the wx cp message router rule
76- */
77- public WxCpTpMessageRouterRule agentId (Integer agentId ) {
78- this .agentId = agentId ;
79- return this ;
80- }
81-
82- /**
83- * 如果msgType等于某值
84- *
85- * @param msgType the msg type
86- * @return the wx cp message router rule
87- */
88- public WxCpTpMessageRouterRule msgType (String msgType ) {
89- this .msgType = msgType ;
90- return this ;
91- }
92-
93- /**
94- * 如果event等于某值
95- *
96- * @param event the event
97- * @return the wx cp message router rule
98- */
99- public WxCpTpMessageRouterRule event (String event ) {
100- this .event = event ;
101- return this ;
102- }
103-
104- /**
105- * 如果eventKey等于某值
106- *
107- * @param eventKey the event key
108- * @return the wx cp message router rule
109- */
110- public WxCpTpMessageRouterRule eventKey (String eventKey ) {
111- this .eventKey = eventKey ;
112- return this ;
113- }
114-
115- /**
116- * 如果eventKey匹配该正则表达式
117- *
118- * @param regex the regex
119- * @return the wx cp message router rule
120- */
121- public WxCpTpMessageRouterRule eventKeyRegex (String regex ) {
122- this .eventKeyRegex = regex ;
123- return this ;
124- }
125-
126- /**
127- * 如果content等于某值
128- *
129- * @param content the content
130- * @return the wx cp message router rule
131- */
132- public WxCpTpMessageRouterRule content (String content ) {
133- this .content = content ;
134- return this ;
135- }
136-
137- /**
138- * 如果content匹配该正则表达式
139- *
140- * @param regex the regex
141- * @return the wx cp message router rule
142- */
143- public WxCpTpMessageRouterRule rContent (String regex ) {
144- this .rContent = regex ;
145- return this ;
146- }
147-
148- /**
149- * 如果fromUser等于某值
150- *
151- * @param fromUser the from user
152- * @return the wx cp message router rule
153- */
154- public WxCpTpMessageRouterRule fromUser (String fromUser ) {
155- this .fromUser = fromUser ;
156- return this ;
157- }
158-
15960 /**
16061 * 如果消息匹配某个matcher,用在用户需要自定义更复杂的匹配规则的时候
16162 *
@@ -243,25 +144,15 @@ public WxCpTpMessageRouter next() {
243144 * @param wxMessage the wx message
244145 * @return the boolean
245146 */
246- protected boolean test (WxCpXmlMessage wxMessage ) {
147+ protected boolean test (WxCpTpXmlMessage wxMessage ) {
247148 return
248- (this .fromUser == null || this .fromUser .equals (wxMessage .getFromUserName ()))
249- &&
250- (this .agentId == null || this .agentId .equals (wxMessage .getAgentId ()))
251- &&
252- (this .msgType == null || this .msgType .equalsIgnoreCase (wxMessage .getMsgType ()))
149+ (this .suiteId == null || this .suiteId .equals (wxMessage .getSuiteId ()))
253150 &&
254- (this .event == null || this .event . equalsIgnoreCase (wxMessage .getEvent ()))
151+ (this .infoType == null || this .infoType . equals (wxMessage .getInfoType ()))
255152 &&
256- (this .eventKey == null || this .eventKey .equalsIgnoreCase (wxMessage .getEventKey ()))
153+ (this .suiteTicket == null || this .suiteTicket .equalsIgnoreCase (wxMessage .getSuiteTicket ()))
257154 &&
258- (this .eventKeyRegex == null || Pattern .matches (this .eventKeyRegex , StringUtils .trimToEmpty (wxMessage .getEventKey ())))
259- &&
260- (this .content == null || this .content .equals (StringUtils .trimToNull (wxMessage .getContent ())))
261- &&
262- (this .rContent == null || Pattern .matches (this .rContent , StringUtils .trimToEmpty (wxMessage .getContent ())))
263- &&
264- (this .matcher == null || this .matcher .match (wxMessage ))
155+ (this .authCode == null || this .authCode .equalsIgnoreCase (wxMessage .getAuthCode ()))
265156 ;
266157 }
267158
@@ -275,12 +166,11 @@ protected boolean test(WxCpXmlMessage wxMessage) {
275166 * @param exceptionHandler the exception handler
276167 * @return true 代表继续执行别的router,false 代表停止执行别的router
277168 */
278- protected WxCpXmlOutMessage service (WxCpXmlMessage wxMessage ,
169+ protected WxCpXmlOutMessage service (WxCpTpXmlMessage wxMessage ,
279170 Map <String , Object > context ,
280171 WxCpTpService wxCpService ,
281172 WxSessionManager sessionManager ,
282173 WxErrorExceptionHandler exceptionHandler ) {
283-
284174 if (context == null ) {
285175 context = new HashMap <>(2 );
286176 }
0 commit comments