支持支付宝获取用户手机号
This commit is contained in:
@@ -179,17 +179,12 @@ public class LoginContoller {
|
||||
// }
|
||||
@RequestMapping("getPhoneNumber")
|
||||
public Result getPhoneNumber(@RequestHeader String openId, @RequestBody Map<String, String> map) {
|
||||
|
||||
if (ObjectUtil.isNull(map) || ObjectUtil.isEmpty(map) || !map.containsKey("code") || ObjectUtil.isEmpty(map.get("code"))) {
|
||||
Result.fail("code不能为空");
|
||||
}
|
||||
|
||||
String encryptedData = map.get("encryptedData");
|
||||
// 三方登录来源 wechat、alipay
|
||||
String source = map.getOrDefault("source",AuthSource.WECHAT.getValue());
|
||||
String code = map.get("code");
|
||||
if (AuthSource.ALIPAY.getValue().equals(source)) {
|
||||
try {
|
||||
String mobile = alipayUtil.getMobile(code);
|
||||
String mobile = alipayUtil.getMobile(encryptedData);
|
||||
return Result.success(CodeEnum.SUCCESS, mobile);
|
||||
}catch (AlipayApiException e){
|
||||
log.error("获取手机号失败:",e);
|
||||
@@ -200,7 +195,11 @@ public class LoginContoller {
|
||||
return Result.fail("获取手机号失败:未知错误");
|
||||
}
|
||||
}
|
||||
String encryptedData = map.get("encryptedData");
|
||||
if (ObjectUtil.isNull(map) || ObjectUtil.isEmpty(map) || !map.containsKey("code") || ObjectUtil.isEmpty(map.get("code"))) {
|
||||
Result.fail("code不能为空");
|
||||
}
|
||||
String code = map.get("code");
|
||||
|
||||
|
||||
String ivStr = map.get("iv");
|
||||
if (StringUtils.isBlank(encryptedData) || StringUtils.isBlank(ivStr)) {
|
||||
|
||||
Reference in New Issue
Block a user