4
4
import me .chanjar .weixin .common .api .WxErrorExceptionHandler ;
5
5
import me .chanjar .weixin .common .error .WxErrorException ;
6
6
import me .chanjar .weixin .common .session .WxSessionManager ;
7
+ import me .chanjar .weixin .cp .bean .message .WxCpTpXmlMessage ;
7
8
import me .chanjar .weixin .cp .bean .message .WxCpXmlMessage ;
8
9
import me .chanjar .weixin .cp .bean .message .WxCpXmlOutMessage ;
9
10
import me .chanjar .weixin .cp .message .WxCpMessageMatcher ;
@@ -24,29 +25,17 @@ public class WxCpTpMessageRouterRule {
24
25
25
26
private boolean async = true ;
26
27
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
-
41
28
private WxCpMessageMatcher matcher ;
42
29
43
30
private boolean reEnter = false ;
44
31
45
- private Integer agentId ;
46
-
47
32
private List <WxCpTpMessageHandler > handlers = new ArrayList <>();
48
33
49
34
private List <WxCpTpMessageInterceptor > interceptors = new ArrayList <>();
35
+ private String suiteId ;
36
+ private String infoType ;
37
+ private String authCode ;
38
+ private String suiteTicket ;
50
39
51
40
/**
52
41
* Instantiates a new Wx cp message router rule.
@@ -68,94 +57,6 @@ public WxCpTpMessageRouterRule async(boolean async) {
68
57
return this ;
69
58
}
70
59
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
-
159
60
/**
160
61
* 如果消息匹配某个matcher,用在用户需要自定义更复杂的匹配规则的时候
161
62
*
@@ -243,25 +144,15 @@ public WxCpTpMessageRouter next() {
243
144
* @param wxMessage the wx message
244
145
* @return the boolean
245
146
*/
246
- protected boolean test (WxCpXmlMessage wxMessage ) {
147
+ protected boolean test (WxCpTpXmlMessage wxMessage ) {
247
148
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 ()))
253
150
&&
254
- (this .event == null || this .event . equalsIgnoreCase (wxMessage .getEvent ()))
151
+ (this .infoType == null || this .infoType . equals (wxMessage .getInfoType ()))
255
152
&&
256
- (this .eventKey == null || this .eventKey .equalsIgnoreCase (wxMessage .getEventKey ()))
153
+ (this .suiteTicket == null || this .suiteTicket .equalsIgnoreCase (wxMessage .getSuiteTicket ()))
257
154
&&
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 ()))
265
156
;
266
157
}
267
158
@@ -275,12 +166,11 @@ protected boolean test(WxCpXmlMessage wxMessage) {
275
166
* @param exceptionHandler the exception handler
276
167
* @return true 代表继续执行别的router,false 代表停止执行别的router
277
168
*/
278
- protected WxCpXmlOutMessage service (WxCpXmlMessage wxMessage ,
169
+ protected WxCpXmlOutMessage service (WxCpTpXmlMessage wxMessage ,
279
170
Map <String , Object > context ,
280
171
WxCpTpService wxCpService ,
281
172
WxSessionManager sessionManager ,
282
173
WxErrorExceptionHandler exceptionHandler ) {
283
-
284
174
if (context == null ) {
285
175
context = new HashMap <>(2 );
286
176
}
0 commit comments