🐛 #1426 修复多公众号管理的两个问题

1、允许动态更新公众号的配置,原有逻辑:更新配置时会报“该公众号标识已存在,请更换其他标识!”;
2、多公众号的消息路由,原有逻辑问题:handler里WxMpConfigStorageHolder不能获取到appid,意味着用的wxmpservice不对,只会走默认的,已测试存在该问题
This commit is contained in:
S 2020-03-08 16:18:09 +08:00 committed by GitHub
parent e3c6aff3cb
commit 0a99706b74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -152,6 +152,13 @@ public class WxMpMessageRouter {
return route(wxMessage, context, null);
}
/**
* 处理不同appid微信消息
*/
public WxMpXmlOutMessage route(final String appid, final WxMpXmlMessage wxMessage, final Map<String, Object> context) {
return route(wxMessage, context, this.wxMpService.switchoverTo(appid));
}
/**
* 处理微信消息.
*/
@ -228,6 +235,10 @@ public class WxMpMessageRouter {
return this.route(wxMessage, new HashMap<String, Object>(2));
}
public WxMpXmlOutMessage route(String appid, final WxMpXmlMessage wxMessage) {
return this.route(appid, wxMessage, new HashMap<String, Object>(2));
}
private boolean isMsgDuplicated(WxMpXmlMessage wxMessage) {
StringBuilder messageId = new StringBuilder();
if (wxMessage.getMsgId() == null) {

View File

@ -399,9 +399,6 @@ public abstract class BaseWxMpServiceImpl<H, P> implements WxMpService, RequestH
@Override
public void addConfigStorage(String mpId, WxMpConfigStorage configStorages) {
synchronized (this) {
if (this.configStorageMap.containsKey(mpId)) {
throw new RuntimeException("该公众号标识已存在,请更换其他标识!");
}
this.configStorageMap.put(mpId, configStorages);
}
}