8000 :bug: #1426 修复多公众号管理的两个问题 · binarywang/WxJava@0a99706 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0a99706

Browse files
authored
🐛 #1426 修复多公众号管理的两个问题
1、允许动态更新公众号的配置,原有逻辑:更新配置时会报“该公众号标识已存在,请更换其他标识!”; 2、多公众号的消息路由,原有逻辑问题:handler里WxMpConfigStorageHolder不能获取到appid,意味着用的wxmpservice不对,只会走默认的,已测试存在该问题
1 parent e3c6aff commit 0a99706

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageRouter.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ public WxMpXmlOutMessage route(final WxMpXmlMessage wxMessage, final Map<String,
152152
return route(wxMessage, context, null);
153153
}
154154

155+
/**
156+
* 处理不同appid微信消息
157+
*/
158+
public WxMpXmlOutMessage route(final String appid, final WxMpXmlMessage wxMessage, final Map<String, Object> context) {
159+
return route(wxMessage, context, this.wxMpService.switchoverTo(appid));
160+
}
161+
155162
/**
156163
* 处理微信消息.
157164
*/
@@ -228,6 +235,10 @@ public WxMpXmlOutMessage route(final WxMpXmlMessage wxMessage) {
228235
return this.route(wxMessage, new HashMap<String, Object>(2));
229236
}
230237

238+
public WxMpXmlOutMessage route(String appid, final WxMpXmlMessage wxMessage) {
239+
return this.route(appid, wxMessage, new HashMap<String, Object>(2));
240+
}
241+
231242
private boolean isMsgDuplicated(WxMpXmlMessage wxMessage) {
232243
StringBuilder messageId = new StringBuilder();
233244
if (wxMessage.getMsgId() == null) {

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,6 @@ public void setMultiConfigStorages(Map<String, WxMpConfigStorage> configStorages
399399
@Override
400400
public void addConfigStorage(String mpId, WxMpConfigStorage configStorages) {
401401
synchronized (this) {
402-
if (this.configStorageMap.containsKey(mpId)) {
403-
throw new RuntimeException("该公众号标识已存在,请更换其他标识!");
404-
}
405402
this.configStorageMap.put(mpId, configStorages);
406403
}
407404
}

0 commit comments

Comments
 (0)
0