| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
open: 三个 WxOpenInRedis*ConfigStorage 的 20 个方法逐字符相同,抽取 AbstractWxOpenInRedisOpsConfigStorage 统一实现,子类仅保留构造函数。 channel: 两个媒体下载执行器中的 uri 拼参与临时文件命名逻辑上移到 ChannelMediaDownloadRequestExecutor。 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Sorry, something went wrong.
There was a problem hiding this comment.
本 PR 延续 #4082 的思路,在 weixin-java-open 与 weixin-java-channel 模块内抽取公共父类/公共方法,以消除 CPD 扫描出的逐字符重复代码,目标是不改变既有对外行为。
Changes:
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file| File | Description |
|---|---|
| weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/AbstractWxOpenInRedisOpsConfigStorage.java | 新增基于 WxRedisOps 的公共 redis 配置存储实现,集中承载原 3 份重复方法逻辑 |
| weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInRedisConfigStorage.java | 改为继承新的公共父类,类内仅保留构造函数并透传 WxRedisOps/keyPrefix |
| weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInRedisTemplateConfigStorage.java | 同上(RedisTemplate 适配实现) |
| weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInRedissonConfigStorage.java | 同上(Redisson 适配实现) |
| weixin-java-channel/src/main/java/me/chanjar/weixin/channel/executor/ChannelMediaDownloadRequestExecutor.java | 新增 appendDataToUri / saveTmpFile 公共逻辑,供不同 HttpClient 实现复用 |
| weixin-java-channel/src/main/java/me/chanjar/weixin/channel/executor/ApacheHttpChannelMediaDownloadRequestExecutor.java | 使用父类公共逻辑替换重复代码 |
| weixin-java-channel/src/main/java/me/chanjar/weixin/channel/executor/HttpComponentsChannelMediaDownloadRequestExecutor.java | 使用父类公共逻辑替换重复代码 |
Sorry, something went wrong.
| * | ||
| * @author yangyidian | ||
| */ | ||
| public abstract class AbstractWxOpenInRedisOpsConfigStorage extends AbstractWxOpenInRedisConfigStorage { |
| Back | FazBrowse Home | New Git URL |
Summary
续 #4082,继续清理 CPD 扫描出的模块内重复(均不改变对外 API 与行为)。
weixin-java-open:WxOpenInRedisConfigStorage、WxOpenInRedisTemplateConfigStorage、WxOpenInRedissonConfigStorage 三个类各 140 行,除构造函数外的 20 个方法(component ticket / access token、authorizer token、jsapi ticket、card api ticket、lock)逐字符相同,都只是在操作 WxRedisOps。抽取:
三个实现类只剩构造函数(super(redisOps, keyPrefix)),公共构造函数签名、可见性与 @NonNull 语义全部保留;原 private final WxRedisOps redisOps 字段本就不对外暴露。
weixin-java-channel:ApacheHttpChannelMediaDownloadRequestExecutor 与 HttpComponentsChannelMediaDownloadRequestExecutor 使用不同的 HttpClient 类型(httpclient4 / hc5),无法直接合并,但其中与 HTTP 库无关的两段逻辑重复,上移到公共父类 ChannelMediaDownloadRequestExecutor:
原代码中 if (StringUtils.isBlank(fileName) || baseName.length() < 3) 的前半段判断在该位置恒为 false(fileName 上一行已被兜底成时间戳),新实现改为等价且更直观的 StringUtils.isBlank(baseName) || baseName.length() < 3,结果一致。
验证
Link to Devin session: https://app.devin.ai/sessions/65a1cece5efb4304a7e6b85aaa562d7a
Requested by: @binarywang