|
@@ -3,14 +3,11 @@ package org.springblade.auth.verification;
|
|
|
import com.alibaba.druid.util.StringUtils;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
-import me.zhyd.oauth.utils.IpUtils;
|
|
|
-import org.apache.commons.lang.math.RandomUtils;
|
|
|
import org.springblade.auth.utils.ImgVerifyCode;
|
|
|
import org.springblade.common.cache.CacheNames;
|
|
|
import org.springblade.common.enums.NumberEnum;
|
|
|
import org.springblade.common.utils.RedisUtils;
|
|
|
import org.springblade.common.utils.VerificationCodeUtil;
|
|
|
-import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.sms.model.SmsResponse;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.resource.feign.ISmsClient;
|
|
@@ -21,7 +18,6 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import java.awt.image.BufferedImage;
|
|
|
import java.io.IOException;
|
|
|
import java.util.Objects;
|
|
|
-import java.util.Random;
|
|
|
|
|
|
|
|
|
@RestController
|
|
@@ -65,19 +61,20 @@ public class verificationController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- @GetMapping("getPhoneVerifyCode")
|
|
|
- public R<String> getPhoneVerifyCode(@RequestParam("phone") String phone, HttpServletRequest request) {
|
|
|
- String uuid = request.getHeader("uuid");
|
|
|
+ @GetMapping("/getPhoneVerifyCode")
|
|
|
+ public R<String> getPhoneVerifyCode(@RequestParam("phone") String phone, @RequestParam("uuid") String uuid, HttpServletRequest request) {
|
|
|
+// String uuid = request.getHeader("uuid");
|
|
|
String redisKey = uuid + "-" + phone;
|
|
|
Object redisCode = redisUtils.get(CacheNames.APP_LOGIN_CODE_KEY + redisKey);
|
|
|
if (Objects.nonNull(redisCode)) {
|
|
|
return R.fail("验证码已发送,请勿重复发送");
|
|
|
}
|
|
|
String code = VerificationCodeUtil.getVerificationCode(NumberEnum.SIX.number);
|
|
|
+ System.out.println("验证码:" + code);
|
|
|
// TODO: 需要短信发送
|
|
|
String params = "TemplateParamSet:[\"" + code + "\"]";
|
|
|
- R<SmsResponse> responseR = smsClient.sendMessage("tencent-kbs", params, phone);
|
|
|
- redisUtils.set(phone, code, NumberEnum.THREE_HUNDRED.number);
|
|
|
+ R<SmsResponse> responseR = smsClient.sendMessage("tencent-kbs", params, phone);
|
|
|
+ redisUtils.set(CacheNames.APP_LOGIN_CODE_KEY + redisKey, code, NumberEnum.THREE_HUNDRED.number);
|
|
|
return R.success(code);
|
|
|
}
|
|
|
|