|
|
@@ -2,6 +2,7 @@ package com.izouma.nineth.web;
|
|
|
|
|
|
import com.izouma.nineth.config.Constants;
|
|
|
import com.izouma.nineth.exception.BusinessException;
|
|
|
+import com.izouma.nineth.service.CaptchaService;
|
|
|
import com.izouma.nineth.service.sms.SmsService;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
@@ -16,16 +17,27 @@ import java.util.regex.Pattern;
|
|
|
@RequestMapping("/sms")
|
|
|
@AllArgsConstructor
|
|
|
public class SmsController {
|
|
|
- private SmsService smsService;
|
|
|
+ private SmsService smsService;
|
|
|
+ private CaptchaService captchaService;
|
|
|
|
|
|
@GetMapping("/sendVerify")
|
|
|
public String sendVerify(@RequestParam String phone) {
|
|
|
+ //throw new BusinessException("此接口已停用,请重启APP或刷新网页");
|
|
|
if (!Pattern.matches(Constants.Regex.PHONE, phone)) {
|
|
|
throw new BusinessException("请输入正确的手机号");
|
|
|
}
|
|
|
return smsService.sendVerify(phone);
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/sendSecureVerify")
|
|
|
+ public String sendVerify(@RequestParam String phone, @RequestParam String captcha, @RequestParam String captchaKey) {
|
|
|
+ if (!Pattern.matches(Constants.Regex.PHONE, phone)) {
|
|
|
+ throw new BusinessException("请输入正确的手机号");
|
|
|
+ }
|
|
|
+ captchaService.verify(captchaKey, captcha);
|
|
|
+ return smsService.sendVerify(phone);
|
|
|
+ }
|
|
|
+
|
|
|
@GetMapping("/verify")
|
|
|
public String verify(@RequestParam String phone, @RequestParam String code) throws SmsService.SmsVerifyException {
|
|
|
return smsService.verify(phone, code);
|