This commit is contained in:
wangjinlei
2023-11-17 13:25:30 +08:00
parent ac3e7f30cb
commit db58953a9f
5 changed files with 238 additions and 13 deletions

View File

@@ -166,8 +166,15 @@ public class MyUserController {
* 常规注册 发短信验证码
*/
@RequestMapping("/sms/sendcode")
public R registerSms(@RequestParam("phone") String phone,@RequestParam Integer areaCode) throws Exception {
public R registerSms(@RequestParam("phone") String phone,@RequestParam(required = false) String areaCode) throws Exception {
int areacode=0;
if(areaCode==null||areaCode.equals("")){
areacode=0;
}else{
areacode = Integer.valueOf(areaCode);
}
System.out.println(areacode);
//验证一分钟内是否已经发过
String redisCode = redisTemplate.opsForValue().get("RegistCode" + phone);
if (!StringUtils.isEmpty(redisCode)) {
@@ -192,7 +199,7 @@ public class MyUserController {
redisTemplate.opsForValue().set("RegistCode"+phone,code,5, TimeUnit.MINUTES);
//发送
userService.sendCodeForRegister(phone,code,areaCode);
userService.sendCodeForRegister(phone,code,areacode);
return R.ok();
}