记得上下班打卡 | git大法好,push需谨慎

Commit 30a9c638 authored by 张国柄's avatar 张国柄

发送验证码更换JAVA-API;

parent a6bc4291
......@@ -3,6 +3,10 @@ package com.liquidnet.service.adam.constant;
public class AdamRedisConst {
public static final String ADAM = "adam:";
public static final String VALID = ADAM.concat("valid:");
public static final String VALID_SMS_CODE_MOBILE = VALID.concat("sms:code:mobile");
public static final String IDENTITY = ADAM.concat("identity:");
public static final String IDENTITY_MOBILE = IDENTITY.concat("mobile:");
......@@ -44,7 +48,7 @@ public class AdamRedisConst {
public static final String LOCK_KEY_UMEMBER_NO = "adam:lk:member:no";
// // // // // // // // // //
public static final String LOCK_KEY_USMS_MOBILE = "adam:lk:sms:mobile:";
public static final String LOCK_KEY_SMS_CODE_MOBILE = "adam:lk:sms:code:mobile:";
public static final String LOCK_KEY_UREGISTER = "adam:lk:register:";
public static final String LOCK_KEY_UIDENTITY = "adam:lk:identity:";
public static final String LOCK_KEY_UMEMBER_CODE = "adam:lk:member:code:";
......
......@@ -30,7 +30,7 @@ public class SmsMessage implements Serializable, Cloneable {
private final static SmsMessage instance = new SmsMessage();
public static SmsMessage getNew() {
public static SmsMessage builder() {
try {
return (SmsMessage) instance.clone();
} catch (CloneNotSupportedException e) {
......
......@@ -190,7 +190,8 @@ public class AdamUserController {
@RequestParam String code) {
log.debug("mobile:{},code:{}", mobile, code);
if (!this.checkSmsCode(mobile, code)) return ResponseDto.failure(ErrorMapping.get("10004"));
ResponseDto checkSmsCodeDto = this.checkSmsCode(mobile, code);
if (!checkSmsCodeDto.isSuccess()) return checkSmsCodeDto;
return ResponseDto.success(adamUserInfoService.editMobile(CurrentUtil.getCurrentUid(), mobile));
}
......@@ -241,10 +242,6 @@ public class AdamUserController {
public ResponseDto<List<AdamThirdPartInfoVo>> bindTpa(@Valid @RequestBody AdamThirdPartParam parameter) {
log.debug("login by tpa:{}", JsonUtils.toJson(parameter));
if (StringUtils.isBlank(parameter.getOpenId())) {
return ResponseDto.failure(ErrorMapping.get("10009"));
}
String currentUid = CurrentUtil.getCurrentUid();
String existUid = adamRdmService.getUidByPlatformOpenId(parameter.getPlatform(), parameter.getOpenId());
......@@ -307,27 +304,32 @@ public class AdamUserController {
private static final String PHP_API_SMS_CODE_VALID = "/smsValidation";
private boolean checkSmsCode(String mobile, String code) {
private ResponseDto checkSmsCode(String mobile, String code) {
if (Arrays.asList(LnsEnum.ENV.dev.name(), LnsEnum.ENV.test.name()).contains(env.getProperty(CurrentUtil.CK_ENV_ACTIVE))
&& CurrentUtil.GRAY_LOGIN_SMS_CODE.equals(code)) {
return true;
return ResponseDto.success();
}
LinkedMultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("mobile", mobile);
paramsMap.add("code", code);
LinkedMultiValueMap<String, String> headersMap = new LinkedMultiValueMap<>();
headersMap.add("token", null);
try {
String respStr = HttpUtil.get(env.getProperty("liquidnet.url-service.url") + PHP_API_SMS_CODE_VALID, paramsMap, headersMap);
log.debug("###PHP.API.RESP:{}", respStr);
Map respMap = JsonUtils.fromJson(respStr, Map.class);
return StringUtils.equalsIgnoreCase("OK", (String) respMap.get("message"));
} catch (Exception e) {
log.error("验证码验证异常[mobile:{},code:{}]", mobile, code, e);
return false;
// LinkedMultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
// paramsMap.add("mobile", mobile);
// paramsMap.add("code", code);
// LinkedMultiValueMap<String, String> headersMap = new LinkedMultiValueMap<>();
// headersMap.add("token", null);
// try {
// String respStr = HttpUtil.get(env.getProperty("liquidnet.url-service.url") + PHP_API_SMS_CODE_VALID, paramsMap, headersMap);
// log.debug("###PHP.API.RESP:{}", respStr);
//
// Map respMap = JsonUtils.fromJson(respStr, Map.class);
//
// return StringUtils.equalsIgnoreCase("OK", (String) respMap.get("message"));
// } catch (Exception e) {
// log.error("验证码验证异常[mobile:{},code:{}]", mobile, code, e);
// return false;
// }
String smsCodeByMobile = adamRdmService.getSmsCodeByMobile(mobile);
if (null == smsCodeByMobile) {
return ResponseDto.failure(ErrorMapping.get("10003"));
}
return smsCodeByMobile.equals(code) ? ResponseDto.success() : ResponseDto.failure(ErrorMapping.get("10004"));
}
}
......@@ -35,6 +35,16 @@ public class AdamRdmService {
return null == i ? 1 : i;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | <Mobile, SMS CODE> */
public boolean setSmsCodeByMobile(String mobile, String smsCode) {
return redisUtil.set(AdamRedisConst.VALID_SMS_CODE_MOBILE + mobile, smsCode, 15 * 60);
}
public String getSmsCodeByMobile(String mobile) {
return (String) redisUtil.get(AdamRedisConst.VALID_SMS_CODE_MOBILE + mobile);
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | <Mobile|OPENID, UID> */
public boolean setUidByMobile(String mobile, String uid) {
......
......@@ -5,8 +5,8 @@
10000=请求频繁,稍后再试
10001=
10002=
10003=验证码发送失败
10002=验证码发送失败
10003=已超时,请重新获取验证码
10004=手机验证码错误
10005=手机号获取失败,请更换登录方式
10006=第三方账号未注册
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment