Skip to content

Commit f38447e

Browse files
committed
update ScanHandler
1 parent fce81d7 commit f38447e

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

src/main/java/com/github/binarywang/demo/wx/mp/config/WxMpConfiguration.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.github.binarywang.demo.wx.mp.handler.MenuHandler;
1515
import com.github.binarywang.demo.wx.mp.handler.MsgHandler;
1616
import com.github.binarywang.demo.wx.mp.handler.NullHandler;
17+
import com.github.binarywang.demo.wx.mp.handler.ScanHandler;
1718
import com.github.binarywang.demo.wx.mp.handler.StoreCheckNotifyHandler;
1819
import com.github.binarywang.demo.wx.mp.handler.SubscribeHandler;
1920
import com.github.binarywang.demo.wx.mp.handler.UnsubscribeHandler;
@@ -43,6 +44,7 @@ public class WxMpConfiguration {
4344
private MsgHandler msgHandler;
4445
private UnsubscribeHandler unsubscribeHandler;
4546
private SubscribeHandler subscribeHandler;
47+
private ScanHandler scanHandler;
4648

4749
private WxMpProperties properties;
4850

@@ -53,7 +55,7 @@ public class WxMpConfiguration {
5355
public WxMpConfiguration(LogHandler logHandler, NullHandler nullHandler, KfSessionHandler kfSessionHandler,
5456
StoreCheckNotifyHandler storeCheckNotifyHandler, LocationHandler locationHandler,
5557
MenuHandler menuHandler, MsgHandler msgHandler, UnsubscribeHandler unsubscribeHandler,
56-
SubscribeHandler subscribeHandler, WxMpProperties properties) {
58+
SubscribeHandler subscribeHandler, ScanHandler scanHandler, WxMpProperties properties) {
5759
this.logHandler = logHandler;
5860
this.nullHandler = nullHandler;
5961
this.kfSessionHandler = kfSessionHandler;
@@ -63,6 +65,7 @@ public WxMpConfiguration(LogHandler logHandler, NullHandler nullHandler, KfSessi
6365
this.msgHandler = msgHandler;
6466
this.unsubscribeHandler = unsubscribeHandler;
6567
this.subscribeHandler = subscribeHandler;
68+
this.scanHandler = scanHandler;
6669
this.properties = properties;
6770
}
6871

@@ -147,7 +150,7 @@ private WxMpMessageRouter newRouter(WxMpService wxMpService) {
147150

148151
// 扫码事件
149152
newRouter.rule().async(false).msgType(XmlMsgType.EVENT)
150-
.event(EventType.SCAN).handler(this.nullHandler).end();
153+
.event(EventType.SCAN).handler(this.scanHandler).end();
151154

152155
// 默认
153156
newRouter.rule().async(false).handler(this.msgHandler).end();
Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
1-
package com.github.binarywang.demo.wx.mp.handler;
2-
3-
/**
4-
* @author Binary Wang(https://github.com/binarywang)
5-
*/
6-
public abstract class ScanHandler extends AbstractHandler {
7-
8-
}
1+
package com.github.binarywang.demo.wx.mp.handler;
2+
3+
import java.util.Map;
4+
5+
import org.springframework.stereotype.Component;
6+
7+
import me.chanjar.weixin.common.error.WxErrorException;
8+
import me.chanjar.weixin.common.session.WxSessionManager;
9+
import me.chanjar.weixin.mp.api.WxMpService;
10+
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
11+
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
12+
13+
/**
14+
* @author Binary Wang(https://github.com/binarywang)
15+
*/
16+
@Component
17+
public class ScanHandler extends AbstractHandler {
18+
19+
@Override
20+
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMpXmlMessage, Map<String, Object> map,
21+
WxMpService wxMpService, WxSessionManager wxSessionManager) throws WxErrorException {
22+
// 扫码事件处理
23+
return null;
24+
}
25+
}

0 commit comments

Comments
 (0)