Skip to content

Commit

Permalink
update ScanHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
binarywang committed Dec 14, 2018
1 parent fce81d7 commit f38447e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.github.binarywang.demo.wx.mp.handler.MenuHandler;
import com.github.binarywang.demo.wx.mp.handler.MsgHandler;
import com.github.binarywang.demo.wx.mp.handler.NullHandler;
import com.github.binarywang.demo.wx.mp.handler.ScanHandler;
import com.github.binarywang.demo.wx.mp.handler.StoreCheckNotifyHandler;
import com.github.binarywang.demo.wx.mp.handler.SubscribeHandler;
import com.github.binarywang.demo.wx.mp.handler.UnsubscribeHandler;
Expand Down Expand Up @@ -43,6 +44,7 @@ public class WxMpConfiguration {
private MsgHandler msgHandler;
private UnsubscribeHandler unsubscribeHandler;
private SubscribeHandler subscribeHandler;
private ScanHandler scanHandler;

private WxMpProperties properties;

Expand All @@ -53,7 +55,7 @@ public class WxMpConfiguration {
public WxMpConfiguration(LogHandler logHandler, NullHandler nullHandler, KfSessionHandler kfSessionHandler,
StoreCheckNotifyHandler storeCheckNotifyHandler, LocationHandler locationHandler,
MenuHandler menuHandler, MsgHandler msgHandler, UnsubscribeHandler unsubscribeHandler,
SubscribeHandler subscribeHandler, WxMpProperties properties) {
SubscribeHandler subscribeHandler, ScanHandler scanHandler, WxMpProperties properties) {
this.logHandler = logHandler;
this.nullHandler = nullHandler;
this.kfSessionHandler = kfSessionHandler;
Expand All @@ -63,6 +65,7 @@ public WxMpConfiguration(LogHandler logHandler, NullHandler nullHandler, KfSessi
this.msgHandler = msgHandler;
this.unsubscribeHandler = unsubscribeHandler;
this.subscribeHandler = subscribeHandler;
this.scanHandler = scanHandler;
this.properties = properties;
}

Expand Down Expand Up @@ -147,7 +150,7 @@ private WxMpMessageRouter newRouter(WxMpService wxMpService) {

// 扫码事件
newRouter.rule().async(false).msgType(XmlMsgType.EVENT)
.event(EventType.SCAN).handler(this.nullHandler).end();
.event(EventType.SCAN).handler(this.scanHandler).end();

// 默认
newRouter.rule().async(false).handler(this.msgHandler).end();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
package com.github.binarywang.demo.wx.mp.handler;

/**
* @author Binary Wang(https://github.com/binarywang)
*/
public abstract class ScanHandler extends AbstractHandler {

}
package com.github.binarywang.demo.wx.mp.handler;

import java.util.Map;

import org.springframework.stereotype.Component;

import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;

/**
* @author Binary Wang(https://github.com/binarywang)
*/
@Component
public class ScanHandler extends AbstractHandler {

@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMpXmlMessage, Map<String, Object> map,
WxMpService wxMpService, WxSessionManager wxSessionManager) throws WxErrorException {
// 扫码事件处理
return null;
}
}

0 comments on commit f38447e

Please sign in to comment.