为 WxOpenMessageRouter 添加 WxOpenMaService 支持,新增 routeForMa 方法 #3654
+28
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
问题描述
WxOpenMessageRouter类原本只支持将消息路由到WxMpService(公众号),但缺少对WxOpenMaService(小程序)的支持。这导致开发者在通过路由器处理小程序消息时无法访问小程序特定的功能。用户原始问题:
解决方案
在
WxOpenMessageRouter中新增了两个方法,将WxOpenMaService注入到消息上下文中:routeForMa(WxMpXmlMessage wxMessage, String appId)- 路由小程序消息并自动注入服务routeForMa(WxMpXmlMessage wxMessage, Map<String, Object> context, String appId)- 支持自定义上下文并注入服务主要特性:
route()方法保持不变context.get("wxOpenMaService")获取WxOpenMaServiceWxMpXmlMessage格式使用方式
开发者现在可以在处理器中访问
WxOpenMaService:这使开发者能够通过现有的路由器基础设施处理小程序审核事件、代码提交和其他小程序特定操作。
修复 #3629。
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.