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