|
|
|
@@ -1,7 +1,6 @@ |
|
|
|
package com.iformall.mp.manager; |
|
|
|
|
|
|
|
import com.iformall.mp.handler.*; |
|
|
|
import com.iformall.service.WxAppinfoService; |
|
|
|
import com.iformall.service.wechat.FmOpenService; |
|
|
|
import me.chanjar.weixin.mp.api.WxMpMessageRouter; |
|
|
|
import me.chanjar.weixin.mp.api.WxMpService; |
|
|
|
@@ -9,6 +8,9 @@ import me.chanjar.weixin.mp.constant.WxMpEventConstants; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
|
|
|
|
import static me.chanjar.weixin.common.api.WxConsts.*; |
|
|
|
|
|
|
|
/** |
|
|
|
@@ -19,12 +21,11 @@ import static me.chanjar.weixin.common.api.WxConsts.*; |
|
|
|
@Service |
|
|
|
public class WxMpManager { |
|
|
|
|
|
|
|
private Map<String, WxMpMessageRouter> myRouterMap = new ConcurrentHashMap<String, WxMpMessageRouter>(); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
protected FmOpenService openService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxAppinfoService appinfoService; |
|
|
|
protected FmOpenService openService; |
|
|
|
@Autowired |
|
|
|
private LogHandler logHandler; |
|
|
|
@Autowired |
|
|
|
@@ -49,7 +50,12 @@ public class WxMpManager { |
|
|
|
} |
|
|
|
|
|
|
|
public WxMpMessageRouter getRouter(WxMpService mpService) { |
|
|
|
return newRouter(mpService); |
|
|
|
String appId = mpService.getWxMpConfigStorage().getAppId(); |
|
|
|
if (myRouterMap.containsKey(appId)) { |
|
|
|
return myRouterMap.get(appId); |
|
|
|
} else { |
|
|
|
return newRouter(mpService); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private WxMpMessageRouter newRouter(WxMpService wxMpService) { |
|
|
|
@@ -122,6 +128,8 @@ public class WxMpManager { |
|
|
|
// 默认 |
|
|
|
newRouter.rule().async(false).handler(this.msgHandler).end(); |
|
|
|
|
|
|
|
myRouterMap.put(wxMpService.getWxMpConfigStorage().getAppId(), newRouter); |
|
|
|
|
|
|
|
return newRouter; |
|
|
|
} |
|
|
|
|
|
|
|
|