mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-04 20:57:47 +08:00
🎨 规范化代码
This commit is contained in:
parent
bf9c0571f8
commit
ae08833323
@ -51,7 +51,9 @@ public interface WxMaUserService {
|
|||||||
* @param encryptedData 消息密文
|
* @param encryptedData 消息密文
|
||||||
* @param ivStr 加密算法的初始向量
|
* @param ivStr 加密算法的初始向量
|
||||||
* @return .
|
* @return .
|
||||||
|
* @deprecated 请使用替代方法 {@link #getPhoneNoInfo(String)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
WxMaPhoneNumberInfo getPhoneNoInfo(String sessionKey, String encryptedData, String ivStr);
|
WxMaPhoneNumberInfo getPhoneNoInfo(String sessionKey, String encryptedData, String ivStr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,6 +63,17 @@ public interface WxMaUserService {
|
|||||||
* @return .
|
* @return .
|
||||||
* @throws WxErrorException .
|
* @throws WxErrorException .
|
||||||
*/
|
*/
|
||||||
|
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;
|
WxMaPhoneNumberInfo getNewPhoneNoInfo(String code) throws WxErrorException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,6 +26,7 @@ import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.User.SET_USE
|
|||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class WxMaUserServiceImpl implements WxMaUserService {
|
public class WxMaUserServiceImpl implements WxMaUserService {
|
||||||
|
private static final String PHONE_INFO = "phone_info";
|
||||||
private final WxMaService service;
|
private final WxMaService service;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -62,17 +63,22 @@ public class WxMaUserServiceImpl implements WxMaUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WxMaPhoneNumberInfo getNewPhoneNoInfo(String code) throws WxErrorException {
|
public WxMaPhoneNumberInfo getPhoneNoInfo(String code) throws WxErrorException {
|
||||||
JsonObject param = new JsonObject();
|
JsonObject param = new JsonObject();
|
||||||
param.addProperty("code", code);
|
param.addProperty("code", code);
|
||||||
String responseContent = this.service.post(GET_PHONE_NUMBER_URL, param.toString());
|
String responseContent = this.service.post(GET_PHONE_NUMBER_URL, param.toString());
|
||||||
JsonObject response = GsonParser.parse(responseContent);
|
JsonObject response = GsonParser.parse(responseContent);
|
||||||
boolean hasPhoneInfo = response.has("phone_info");
|
if (response.has(PHONE_INFO)) {
|
||||||
if (hasPhoneInfo) {
|
return WxMaGsonBuilder.create().fromJson(response.getAsJsonObject(PHONE_INFO),
|
||||||
return WxMaGsonBuilder.create().fromJson(response.getAsJsonObject("phone_info"), WxMaPhoneNumberInfo.class);
|
WxMaPhoneNumberInfo.class);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WxMaPhoneNumberInfo getNewPhoneNoInfo(String code) throws WxErrorException {
|
||||||
|
return this.getPhoneNoInfo(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user