🎨 移除已废弃接口【getPhoneNoInfo】和【getNewPhoneNoInfo(code)】

This commit is contained in:
水依寒 2024-03-02 18:07:52 +08:00 committed by GitHub
parent a35720c657
commit c9b68b5a7c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 42 deletions

View File

@ -45,37 +45,27 @@ public interface WxMaUserService {
void setUserStorage(Map<String, String> kvMap, String sessionKey, String openid) throws WxErrorException;
/**
* 解密用户手机号信息.
* 获取手机号信息,2023年8月28日起
*
* @param sessionKey 会话密钥
* @param encryptedData 消息密文
* @param ivStr 加密算法的初始向量
* @return .
* @deprecated 请使用替代方法 {@link #getPhoneNoInfo(String)}
* @param code 每个code只能使用一次code的有效期为5mincode获取方式参考<a href="https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/getPhoneNumber.html">手机号快速验证组件</a>
* @return 用户手机号信息
* @throws WxErrorException .
* @apiNote 该接口用于将code换取用户手机号
*/
@Deprecated
WxMaPhoneNumberInfo getPhoneNoInfo(String sessionKey, String encryptedData, String ivStr);
WxMaPhoneNumberInfo getPhoneNumber(String code) throws WxErrorException;
/**
* 获取手机号信息,基础库:2.21.2及以上
* 获取手机号信息,2023年8月28日起
*
* @param code 动态令牌
* @return .
* @param code 每个code只能使用一次code的有效期为5mincode获取方式参考<a href="https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/getPhoneNumber.html">手机号快速验证组件</a>
* @return 用户手机号信息
* @throws WxErrorException .
* @apiNote 该接口用于将code换取用户手机号
* @implNote 为保持命名风格一致此方法将更名推荐使用{@link WxMaUserService#getPhoneNumber(String)}
*/
@Deprecated
WxMaPhoneNumberInfo getPhoneNoInfo(String code) throws WxErrorException;
/**
* 获取手机号信息,基础库:2.21.2及以上
*
* @param code 动态令牌
* @return .
* @throws WxErrorException .
* @deprecated 命名有些复杂请使用替代方法 {@link #getPhoneNoInfo(String)}
*/
@Deprecated
WxMaPhoneNumberInfo getNewPhoneNoInfo(String code) throws WxErrorException;
/**
* 验证用户信息完整性.
*

View File

@ -58,12 +58,7 @@ public class WxMaUserServiceImpl implements WxMaUserService {
}
@Override
public WxMaPhoneNumberInfo getPhoneNoInfo(String sessionKey, String encryptedData, String ivStr) {
return WxMaPhoneNumberInfo.fromJson(WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr));
}
@Override
public WxMaPhoneNumberInfo getPhoneNoInfo(String code) throws WxErrorException {
public WxMaPhoneNumberInfo getPhoneNumber(String code) throws WxErrorException {
JsonObject param = new JsonObject();
param.addProperty("code", code);
String responseContent = this.service.post(GET_PHONE_NUMBER_URL, param.toString());
@ -77,8 +72,8 @@ public class WxMaUserServiceImpl implements WxMaUserService {
}
@Override
public WxMaPhoneNumberInfo getNewPhoneNoInfo(String code) throws WxErrorException {
return this.getPhoneNoInfo(code);
public WxMaPhoneNumberInfo getPhoneNoInfo(String code) throws WxErrorException {
return this.getPhoneNumber(code);
}
@Override

View File

@ -47,14 +47,10 @@ public class WxMaUserServiceImplTest {
"75e81ceda165f4ffa64f4068af58c64b8f54b88c"));
}
/**
* TODO 测试数据有问题需要替换为正确的数据
*/
@Test
public void testGetPhoneNoInfo() {
WxMaPhoneNumberInfo phoneNoInfo = this.wxService.getUserService().getPhoneNoInfo("tiihtNczf5v6AKRyjwEUhQ==",
"CiyLU1Aw2KjvrjMdj8YKliAjtP4gsMZMQmRzooG2xrDcvSnxIMXFufNstNGTyaGS9uT5geRa0W4oTOb1WT7fJlAC+oNPdbB+3hVbJSRgv+4lGOETKUQz6OYStslQ142dNCuabNPGBzlooOmB231qMM85d2/fV6ChevvXvQP8Hkue1poOFtnEtpyxVLW1zAo6/1Xx1COxFvrc2d7UL/lmHInNlxuacJXwu0fjpXfz/YqYzBIBzD6WUfTIF9GRHpOn/Hz7saL8xz+W//FRAUid1OksQaQx4CMs8LOddcQhULW4ucetDf96JcR3g0gfRK4PC7E/r7Z6xNrXd2UIeorGj5Ef7b1pJAYB6Y5anaHqZ9J6nKEBvB4DnNLIVWSgARns/8wR2SiRS7MNACwTyrGvt9ts8p12PKFdlqYTopNHR1Vf7XjfhQlVsAJdNiKdYmYVoKlaRv85IfVunYzO0IKXsyl7JCUjCpoG20f0a04COwfneQAGGwd5oa+T8yO5hzuyDb/XcxxmK01EpqOyuxINew==",
"r7BXXKkLb8qrSNn05n0qiA==");
public void testGetPhoneNoInfo() throws WxErrorException {
WxMaPhoneNumberInfo phoneNoInfo = this.wxService.getUserService().getPhoneNumber("tiihtNczf5v6AKRyjwEUhQ==");
assertNotNull(phoneNoInfo);
System.out.println(phoneNoInfo.toString());
}
@ -72,11 +68,6 @@ public class WxMaUserServiceImplTest {
"r7BXXKkLb8qrSNn05n0qiA",((TestConfig)this.wxService.getWxMaConfig()).getOpenid());
}
@Test
public void testGetNewPhoneNoInfo() throws Exception{
assertNotNull(wxService.getUserService().getNewPhoneNoInfo("test"));
}
@Test
public void testGetAccessToken() throws Exception{
assertNotNull(wxService.getAccessToken(true));