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

Commit df96be57 authored by 张国柄's avatar 张国柄

~api:商城短信验证码根据环境选择调用服务商;

parent cf3f7282
...@@ -57,12 +57,17 @@ public class GoblinSmsController { ...@@ -57,12 +57,17 @@ public class GoblinSmsController {
return ResponseDto.failure(ErrorMapping.get("140000")); return ResponseDto.failure(ErrorMapping.get("140000"));
} }
} }
ObjectNode msgNode = JsonUtils.OM().createObjectNode(); if (LnsEnum.ENV.prod.name().equals(env.getProperty(CurrentUtil.CK_ENV_ACTIVE))) {
msgNode.put("code", smsCode); ObjectNode msgNode = JsonUtils.OM().createObjectNode();
boolean sendRst = smsProcessor.send(mobile, SmsEnum.ADSignName.M02.getVal(), SmsEnum.ADTemplate.SMS_221055862.name(), msgNode.toString()); msgNode.put("code", smsCode);
if (sendRst) { boolean sendRst = smsProcessor.send(mobile, SmsEnum.ADSignName.M02.getVal(), SmsEnum.ADTemplate.SMS_221055862.name(), msgNode.toString());
goblinRedisUtils.setSmsCodeByMobile(mobile, smsCode); if (sendRst) {
goblinRedisUtils.setSmsCodeByMobile(mobile, smsCode);
return ResponseDto.success();
}
} else {
goblinRedisUtils.setSmsCodeByMobile(mobile, CurrentUtil.GRAY_LOGIN_SMS_CODE);
return ResponseDto.success(); return ResponseDto.success();
} }
return ResponseDto.failure(ErrorMapping.get("140017")); return ResponseDto.failure(ErrorMapping.get("140017"));
......
...@@ -57,25 +57,28 @@ public class GoblinUserSafeController { ...@@ -57,25 +57,28 @@ public class GoblinUserSafeController {
@NotBlank(message = "验证码不能为空") @Pattern(regexp = "\\d{6}", message = "验证码格式有误") @RequestParam String code @NotBlank(message = "验证码不能为空") @Pattern(regexp = "\\d{6}", message = "验证码格式有误") @RequestParam String code
) { ) {
String currentUid = CurrentUtil.getCurrentUid(), currentMobile = (String) CurrentUtil.getTokenClaims().get(CurrentUtil.TOKEN_MOBILE); String currentUid = CurrentUtil.getCurrentUid(), currentMobile = (String) CurrentUtil.getTokenClaims().get(CurrentUtil.TOKEN_MOBILE);
ResponseDto<Object> validResultDto = this.validVerificationCode(code, currentMobile);
if (!validResultDto.isSuccess()) return validResultDto;
String lockKey = GoblinRedisConst.USER_SAFE_CONFIG.concat("lk").concat(currentUid);
if (goblinRedisUtils.incr(lockKey, 1) > 1) return ResponseDto.failure(ErrorMapping.get("140000"));
goblinRedisUtils.expire(lockKey, 30);
boolean resultFlg = goblinUserAssetConfigService.initSafePasswd(passwd, currentUid);
goblinRedisUtils.del(lockKey);
return resultFlg ? ResponseDto.success() : ResponseDto.failure(ErrorMapping.get("140002"));
}
private ResponseDto<Object> validVerificationCode(String code, String mobile) {
if (!LnsEnum.ENV.prod.name().equals(env.getProperty(CurrentUtil.CK_ENV_ACTIVE))) { if (!LnsEnum.ENV.prod.name().equals(env.getProperty(CurrentUtil.CK_ENV_ACTIVE))) {
if (CurrentUtil.GRAY_LOGIN_SMS_CODE.equals(code)) return ResponseDto.success(); if (CurrentUtil.GRAY_LOGIN_SMS_CODE.equals(code)) return ResponseDto.success();
} }
String cacheCode = goblinRedisUtils.getSmsCodeByMobile(currentMobile); String cacheCode = goblinRedisUtils.getSmsCodeByMobile(mobile);
if (StringUtils.isEmpty(cacheCode)) { if (StringUtils.isEmpty(cacheCode)) {
return ResponseDto.failure(ErrorMapping.get("140018")); return ResponseDto.failure(ErrorMapping.get("140018"));
} }
if (!cacheCode.equals(code)) { if (!cacheCode.equals(code)) {
return ResponseDto.failure(ErrorMapping.get("140001")); return ResponseDto.failure(ErrorMapping.get("140019"));
}
GoblinUserSafeConfigDto userSafeConfigDto = goblinRedisUtils.getUserSafeConfigDto(currentUid);
if (null != userSafeConfigDto) {
return ResponseDto.failure(ErrorMapping.get("140020"));
} }
String lockKey = GoblinRedisConst.USER_SAFE_CONFIG.concat("lk").concat(currentUid); return ResponseDto.success();
if (goblinRedisUtils.incr(lockKey, 1) > 1) return ResponseDto.failure(ErrorMapping.get("140000"));
goblinRedisUtils.expire(lockKey, 30);
boolean resultFlg = goblinUserAssetConfigService.initSafePasswd(passwd, currentUid);
goblinRedisUtils.del(lockKey);
return resultFlg ? ResponseDto.success() : ResponseDto.failure(ErrorMapping.get("140002"));
} }
} }
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