feat: 拆分微信小店独立模块 - #4117
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
This pull request is too large for Augment to review. The PR exceeds the maximum size limit of 75000 tokens (approximately 300000 characters) for automated code review. Please consider breaking this PR into smaller, more focused changes. |
There was a problem hiding this comment.
🟡 Changes recommended
BOM 目前未对本 PR 新增的 Store Starter / Solon 插件 artifact 做版本托管,可能影响依赖 BOM 的用户集成与升级体验。
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
该 PR 将“微信小店(Store)”能力从 weixin-java-channel 中拆分为独立的 weixin-java-store SDK,并新增对应的 Spring Boot / Solon 集成模块;同时对 weixin-java-channel 中保留的小店相关 API/模型进行 @Deprecated 标记,以引导用户迁移且保持既有行为不变。
Changes:
- 新增
weixin-java-store模块,并在根聚合构建中注册该模块。 - 新增 Store 的 Spring Boot Starter(单账号/多账号)与 Solon 插件(单账号/多账号)的自动装配/插件声明资源。
- 在
weixin-java-channel中对小店相关接口与大量请求/响应/模型类增加@Deprecated标记。
File summaries
| File | Description |
|---|---|
| pom.xml | 在根聚合模块中加入 weixin-java-store,纳入统一构建/发布链路。 |
| wx-java-bom/pom.xml | BOM 增加 weixin-java-store 的版本托管入口(但目前未覆盖 Store Starter/Solon 插件,见评论)。 |
| spring-boot-starters/pom.xml | 注册 Store 的 Spring Boot Starter 两个子模块。 |
| spring-boot-starters/wx-java-store-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports | 声明 Store 单账号 Starter 的 AutoConfiguration 导入。 |
| spring-boot-starters/wx-java-store-spring-boot-starter/src/main/resources/META-INF/spring.factories | 兼容 Spring Boot 旧机制的自动装配声明。 |
| spring-boot-starters/wx-java-store-multi-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports | 声明 Store 多账号 Starter 的 AutoConfiguration 导入。 |
| spring-boot-starters/wx-java-store-multi-spring-boot-starter/src/main/resources/META-INF/spring.factories | 兼容 Spring Boot 旧机制的自动装配声明。 |
| solon-plugins/pom.xml | 注册 Store 的 Solon 插件两个子模块。 |
| solon-plugins/wx-java-store-solon-plugin/src/main/resources/META-INF/solon/wx-java-store-solon-plugin.properties | 声明 Solon 插件入口与优先级。 |
| solon-plugins/wx-java-store-solon-plugin/src/test/resources/app.yml | Store Solon 插件测试资源(当前为空文件)。 |
| weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelKfService.java | 将 Channel 内小店客服服务接口标记为 @Deprecated(建议补充迁移指引,见评论)。 |
| weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelAfterSaleService.java | 将 Channel 内小店售后服务接口标记为 @Deprecated。 |
| weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelProductService.java | 将 Channel 内小店商品服务接口标记为 @Deprecated。 |
| weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/** | 大量小店相关 Bean/Param/Response 增加 @Deprecated,用于迁移引导与边界划分。 |
Review details
- Files reviewed: 299/1242 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| <dependency> | ||
| <groupId>com.github.binarywang</groupId> | ||
| <artifactId>weixin-java-store</artifactId> | ||
| <version>${project.version}</version> | ||
| </dependency> |
| /** 视频号小店商家客服服务。 */ | ||
| @Deprecated | ||
| public interface WxChannelKfService { |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: da31b5dd85
ℹ️ 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".
| private final WxStoreProperties properties; | ||
|
|
||
| @Bean | ||
| @ConditionalOnMissingBean(WxStoreProperties.class) |
There was a problem hiding this comment.
使用默认配置或显式设置 wx.store.config-storage.type=memory 时,@EnableConfigurationProperties(WxStoreProperties.class) 已经注册了 WxStoreProperties,因此这里的条件恒为假,WxStoreConfig 不会创建;随后 WxStoreServiceAutoConfiguration 的 @ConditionalOnBean(WxStoreConfig.class) 也不成立,文档承诺的两个自动注入对象均不可用。条件应检查缺少 WxStoreConfig,而不是缺少属性 Bean。
AGENTS.md reference: AGENTS.md:L57-L57
Useful? React with 👍 / 👎.
| private final WxStoreProperties properties; | ||
|
|
||
| @Bean | ||
| @Condition(onMissingBean = WxStoreProperties.class) |
There was a problem hiding this comment.
Solon 插件在 WxStorePluginImpl.start 中先执行 context.beanMake(WxStoreProperties.class),再加载此配置,所以默认 memory 场景下这里的 onMissingBean = WxStoreProperties.class 不成立,最终既没有 WxStoreConfig,也无法创建依赖它的 WxStoreService。应将缺失条件改为 WxStoreConfig.class。
AGENTS.md reference: AGENTS.md:L57-L57
Useful? React with 👍 / 👎.
| * @throws WxErrorException 异常 | ||
| */ | ||
| protected String extractAccessToken(String resultContent) throws WxErrorException { | ||
| log.debug("access-token response: {}", resultContent); |
There was a problem hiding this comment.
成功获取凭据时,resultContent 包含可直接调用微信接口的 access_token,开启 DEBUG 后这里会把完整凭据写入日志;同类泄露还发生在 executeInternal 记录带 access_token 查询参数的 uriWithAccessToken 时。请仅记录脱敏响应和不含凭据的请求地址。
AGENTS.md reference: AGENTS.md:L59-L59
Useful? React with 👍 / 👎.
| @ConditionalOnMissingBean(WxStoreService.class) | ||
| @ConditionalOnBean(WxStoreConfig.class) | ||
| public WxStoreService wxStoreService(WxStoreConfig wxStoreConfig) { | ||
| WxStoreService wxStoreService = new WxStoreServiceImpl(); |
There was a problem hiding this comment.
单账号 Spring Starter 无条件实例化 WxStoreServiceImpl,而该类继承 WxStoreServiceHttpClientImpl,所以 wx.store.config-storage.http-client-type 即使设置为默认属性值 HttpComponents 也不会选择 WxStoreServiceHttpComponentsImpl;Solon 单账号配置中也存在相同问题。需要像多账号配置一样根据 HttpClientType 创建对应实现,否则该公开配置项完全无效。
AGENTS.md reference: AGENTS.md:L56-L57
Useful? React with 👍 / 👎.
| * @author <a href="https://github.com/lixize">Zeyes</a> | ||
| */ | ||
| @Configuration | ||
| @ConditionalOnProperty(prefix = WxStoreProperties.PREFIX + ".config-storage", name = "type", havingValue = "redistemplate") |
There was a problem hiding this comment.
单账号 Starter 的 README 要求 wx.store.config-storage.type=redis_template,但该条件只匹配 redistemplate;使用文档配置时 RedisTemplate 配置类不会启用,显式值又会关闭默认 memory 配置,最终没有 WxStoreConfig 或 WxStoreService。���统一条件值、枚举绑定和 README 中的配置键。
AGENTS.md reference: AGENTS.md:L89-L90
Useful? React with 👍 / 👎.
| * @author <a href="https://github.com/lixize">Zeyes</a> | ||
| */ | ||
| @Configuration | ||
| @ConditionalOnProperty(prefix = WxStoreProperties.PREFIX + ".config-storage", name = "type", havingValue = "redistemplate") |
There was a problem hiding this comment.
单账号 Starter 的 README 要求 wx.store.config-storage.type=redis_template,但该条件只匹配 redistemplate;使用文档配置时 RedisTemplate 配置类不会启用,显式值又会关闭默认 memory 配置,最终没有 WxStoreConfig 或 WxStoreService。请统一条件值、枚举绑定和 README 中的配置键。
AGENTS.md reference: AGENTS.md:L89-L90
Useful? React with 👍 / 👎.
| @JsonProperty("user_info") | ||
| @JacksonXmlProperty(localName = "order_info") | ||
| private UserInfo userInfo; |
There was a problem hiding this comment.
微信会员回调使用 XML 且包含 <user_info> 时,这里却从 <order_info> 读取,因此 UserInfoMessage.userInfo 会保持 null,手机号、等级和积分等数据全部丢失;同一字段的 @JsonProperty("user_info") 也确认了传输层名称。应把 JacksonXmlProperty.localName 改为 user_info 并增加 XML 回调回归测试。
AGENTS.md reference: AGENTS.md:L53-L54
Useful? React with 👍 / 👎.
| public Object route(final WxStoreMessage message, final String content, final String appId, | ||
| final WxStoreService service) { | ||
| return this.route(message, content, appId, new HashMap<>(2), service, new StandardSessionManager()); |
| RequestExecutor<StoreImageResponse, String> executor = StoreMediaDownloadRequestExecutor.create(shopService, | ||
| Files.createTempDirectory("wxjava-channel-" + appId).toFile()); |
There was a problem hiding this comment.
每次调用 getImg 都创建一个新的临时目录,下载文件仅通过 deleteOnExit 延迟到 JVM 退出时删除,而该目录本身从未清理;在长期运行且频繁下载图片的服务中,文件和目录会持续累积并可能耗尽磁盘或 inode。应复用受管理的临时目录,并为返回文件定义可执行的及时清理机制。
AGENTS.md reference: AGENTS.md:L107-L107
Useful? React with 👍 / 👎.
| this.executorService = new ThreadPoolExecutor(2, 100, | ||
| 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), namedThreadFactory); |
变更内容
weixin-java-storeSDK,Java 包名为com.binarywang.wxjava.store.*,不依赖weixin-java-channel。wx.store。weixin-java-channel的小店服务和模型,行为不变,并统一标记为@Deprecated。验证
mvn -pl weixin-java-channel,weixin-java-store,spring-boot-starters/wx-java-store-spring-boot-starter,spring-boot-starters/wx-java-store-multi-spring-boot-starter,solon-plugins/wx-java-store-solon-plugin,solon-plugins/wx-java-store-multi-solon-plugin -am test -Dmaven.test.skip=falsegit diff --check