Conversation
- 添加 WxMaFaceService 接口,包含 getVerifyId 和 queryVerifyInfo 方法 - 添加 WxMaFaceServiceImpl 实现,包含 cert_hash 计算工具方法 - 添加请求/响应 bean:WxMaFaceGetVerifyIdRequest/Response、WxMaFaceQueryVerifyInfoRequest/Response - 在 WxMaApiUrlConstants 中新增 Face 接口 URL 常量 - 在 WxMaService 和 BaseWxMaServiceImpl 中注册人脸核身服务 - 新增测试类 WxMaFaceServiceImplTest(含 cert_hash 单元测试) Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
🤖 Augment PR Summary总结:本 PR 按照微信官方文档新增「小程序人脸核身」后台能力,补齐获取核身会话与查询核身结果两类接口。 主要变更:
技术说明:接口调用由底层执行器统一追加 🤖 Was this summary useful? React with 👍 or 👎 |
| byte[] hashBytes = digest.digest(raw.getBytes(StandardCharsets.UTF_8)); | ||
| StringBuilder hex = new StringBuilder(); | ||
| for (byte b : hashBytes) { | ||
| hex.append(String.format("%02x", b)); |
| .certName("张三") | ||
| .certNo("310101199801011234") | ||
| .build()) | ||
| .openid("test_openid_001") |
There was a problem hiding this comment.
testGetVerifyId/testQueryVerifyInfo 里使用了明显的占位 openid/verifyId(如 test_openid_001、test_verify_id_001),在真实调用微信接口时大概率直接报错抛 WxErrorException,会让用例不可用/不稳定。
Severity: medium
Other Locations
weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaFaceServiceImplTest.java:53weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaFaceServiceImplTest.java:56
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
There was a problem hiding this comment.
Pull request overview
该 PR 在 weixin-java-miniapp 模块中新增“小程序人脸核身服务”后台接口封装,补齐官方文档中的 getVerifyId 与 queryVerifyInfo 两个能力,并将其纳入 WxMaService 的子服务体系,方便 SDK 使用方以统一方式调用。
Changes:
- 新增人脸核身服务接口
WxMaFaceService及实现WxMaFaceServiceImpl,封装getVerifyId/queryVerifyInfo请求。 - 新增对应的请求/响应 Bean,并补充
WxMaApiUrlConstants.Face接口地址常量。 - 在
WxMaService/BaseWxMaServiceImpl中注册并暴露getFaceService();新增相关测试类。
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaFaceServiceImplTest.java | 新增人脸核身服务测试用例(目前包含直连真实接口的用例)。 |
| weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaApiUrlConstants.java | 增加 Face 接口 URL 常量定义。 |
| weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/face/WxMaFaceQueryVerifyInfoResponse.java | 新增 queryVerifyInfo 响应模型与反序列化方法。 |
| weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/face/WxMaFaceQueryVerifyInfoRequest.java | 新增 queryVerifyInfo 请求模型与序列化方法。 |
| weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/face/WxMaFaceGetVerifyIdResponse.java | 新增 getVerifyId 响应模型与反序列化方法。 |
| weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/face/WxMaFaceGetVerifyIdRequest.java | 新增 getVerifyId 请求模型(含 cert_info)与序列化方法。 |
| weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaFaceServiceImpl.java | 新增服务实现与 cert_hash 计算工具方法。 |
| weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java | 注册 WxMaFaceService 实例并提供 getter。 |
| weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaService.java | 新增 getFaceService() 对外声明。 |
| weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaFaceService.java | 新增人脸核身服务接口定义与方法注释。 |
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaFaceServiceImpl.java
Outdated
Show resolved
Hide resolved
...in-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaFaceServiceImplTest.java
Outdated
Show resolved
Hide resolved
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaFaceService.java
Outdated
Show resolved
Hide resolved
...ava-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/face/WxMaFaceGetVerifyIdRequest.java
Outdated
Show resolved
Hide resolved
...va-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/face/WxMaFaceGetVerifyIdResponse.java
Outdated
Show resolved
Hide resolved
...in-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaFaceServiceImplTest.java
Outdated
Show resolved
Hide resolved
| import org.testng.annotations.Test; | ||
|
|
||
| import static org.testng.Assert.assertEquals; | ||
| import static org.testng.AssertJUnit.assertNotNull; |
There was a problem hiding this comment.
这里同时静态导入了 org.testng.Assert.assertEquals 和 org.testng.AssertJUnit.assertNotNull,断言库混用会降低可读性并可能引入行为差异。建议统一使用 TestNG 的 org.testng.Assert(例如静态导入 assertNotNull),与本模块其他测试类保持一致。
| import static org.testng.AssertJUnit.assertNotNull; | |
| import static org.testng.Assert.assertNotNull; |
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaFaceServiceImpl.java
Outdated
Show resolved
Hide resolved
...miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/face/WxMaFaceQueryVerifyInfoRequest.java
Outdated
Show resolved
Hide resolved
...iniapp/src/main/java/cn/binarywang/wx/miniapp/bean/face/WxMaFaceQueryVerifyInfoResponse.java
Outdated
Show resolved
Hide resolved
…/impl/WxMaFaceServiceImplTest.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…/WxMaFaceService.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…n/face/WxMaFaceGetVerifyIdResponse.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@copilot apply changes based on the comments in this thread |
- 将 calcCertHash 工具方法从 WxMaFaceServiceImpl 移到 WxMaFaceQueryVerifyInfoRequest 中 - 修复所有文件中 Github → GitHub 拼写错误 - 重构测试类:移除依赖真实接口的测试,只保留本地 calcCertHash 计算测试 - 修复测试类断言库混用问题,统一使用 TestNG 的 org.testng.Assert Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
已根据审查意见完成全部修改(commit
|
按照官方文档实现微信小程序人脸核身服务的两个后台接口,接口路径以
/cityservice/face/identify/为前缀。新增接口
getVerifyId— 根据用户实名信息(姓名+身份证)获取核身会话标识verifyId,供前端调用wx.requestFacialVerify使用queryVerifyInfo— 根据verifyId查询人脸核身真实结果;核身通过条件:errcode=0且verify_ret=10000新增文件
WxMaFaceServiceWxMaFaceServiceImplWxMaFaceGetVerifyIdRequest/Response、WxMaFaceQueryVerifyInfoRequest/ResponseWxMaApiUrlConstants.Face变更文件
WxMaService— 新增getFaceService()声明BaseWxMaServiceImpl— 注册服务实例并实现 gettercert_hash 计算
queryVerifyInfo需要传入cert_hash,WxMaFaceQueryVerifyInfoRequest内置了静态工具方法:计算结果与官方文档示例值完全一致。
使用示例
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.