补充企业微信智能机器人 API 模式 JSON 回调消息模型与服务调用入口#4011
Conversation
Agent-Logs-Url: https://github.com/binarywang/WxJava/sessions/07e83fbe-cc11-4b67-82ec-6cb21fb184a3 Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 93417276dc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @SerializedName("url") | ||
| private String url; |
There was a problem hiding this comment.
Capture media aeskey in callback payloads
For image/file/video callbacks, WeCom sends the download URL together with an aeskey used to decrypt the downloaded media. These media payload classes only retain url, so fromJson() silently drops the key and callers receiving encrypted image, file, or video messages cannot use the SDK model to decrypt the media without reparsing the raw JSON.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
本 PR 为 weixin-java-cp 的企业微信「智能机器人」能力补齐 API 模式 JSON 回调消息体的 SDK 级模型与解析入口,降低接入侧自行拼装/解析 JSON 的成本,并提供契约测试与文档示例以稳定回归。
Changes:
- 新增
WxCpIntelligentRobotMessage:覆盖回调公共字段及多种消息载荷结构,并提供fromJson/toJson统一序列化入口。 - 新增
WxCpIntelligentRobotMessageTest:覆盖文本与 mixed+quote 复合结构解析及序列化回归。 - 更新
INTELLIGENT_ROBOT.md:补充 API 模式 JSON 回调解析示例与文档排版修正。
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/intelligentrobot/WxCpIntelligentRobotMessage.java | 新增智能机器人 API 模式 JSON 回调消息模型,提供 Gson 序列化/反序列化入口 |
| weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/intelligentrobot/WxCpIntelligentRobotMessageTest.java | 新增契约测试,验证 JSON 解析与序列化回归 |
| weixin-java-cp/INTELLIGENT_ROBOT.md | 补充 JSON 回调解析示例并修正文档列表格式 |
|
@copilot 这个新增的模型要如何调用?没有入口吗? |
Agent-Logs-Url: https://github.com/binarywang/WxJava/sessions/153a6a9d-1d0b-4a49-a3c4-493265b9b6fa Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
已补上统一入口: |
当前
weixin-java-cp已覆盖智能机器人管理与会话相关服务端 API,但对文档(path/101039/path/100719)中的 API 模式 JSON 回调消息体缺少统一模型,接入侧需要自行拼装解析。本 PR 在不扩展不存在接口的前提下,补齐官方回调结构的 SDK 级解析能力,并补充服务层统一调用入口。
新增回调消息模型(
intelligentrobot包)WxCpIntelligentRobotMessagemsgid、aibotid、chatid、chattype、from、response_url、msgtypetext/image/mixed/voice/file/video/quote/streamfromJson/toJson,统一接入方序列化与反序列化入口新增服务调用入口(反馈补充)
WxCpIntelligentRobotService新增parseCallbackMessage(String callbackMessageJson)WxCpIntelligentRobotServiceImpl完成实现,内部基于WxCpIntelligentRobotMessage.fromJson(...)解析wxCpService.getIntelligentRobotService()直接解析回调消息,而不必手动依赖模型静态方法补充契约测试(JSON 结构稳定性)
WxCpIntelligentRobotMessageTestWxCpIntelligentRobotServiceImplTest新增testParseCallbackMessage,覆盖服务入口调用路径文档更新(接入路径补全)
weixin-java-cp/INTELLIGENT_ROBOT.mdrobotService.parseCallbackMessage(jsonBody)调用,明确 SDK 推荐入口示例: