更换短信验证码

This commit is contained in:
wuchunlei
2025-04-16 16:39:07 +08:00
parent 2b57f006a5
commit c6b7699e84
16 changed files with 174 additions and 21 deletions

View File

@@ -232,7 +232,6 @@ public class MyUserController {
return R.error(500,"短信验证码频率过高,请稍后再试!");
}
}
//生成随机六位数
Random random = new Random();
String i = random.nextInt(999999) + "";
@@ -242,14 +241,10 @@ public class MyUserController {
}
i = sb.toString() + i;
String code = i + "_"+System.currentTimeMillis();
//redis 缓存验证码
redisTemplate.opsForValue().set("RegistCode"+phone,code,5, TimeUnit.MINUTES);
//发送
userService.sendCodeForRegister(phone,code,areacode);
return R.ok();
return userService.sendCodeForRegister(phone,code,areacode);
}
/**

View File

@@ -2,6 +2,7 @@ package com.peanut.modules.book.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
import com.peanut.modules.common.entity.BookForumArticlesEntity;
import com.peanut.modules.common.entity.MyUserEntity;
import java.util.List;
@@ -19,7 +20,7 @@ public interface MyUserService extends IService<MyUserEntity> {
PageUtils queryPage(Map<String, Object> params);
void sendCodeForRegister(String phone, String code,Integer areaCode) throws Exception;
R sendCodeForRegister(String phone, String code, Integer areaCode) throws Exception;
List<BookForumArticlesEntity> getForumsLimit(Integer book_id, Integer limit);
//充值花生币

View File

@@ -30,6 +30,8 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
@Autowired
private SMSConfig smsConfig;
@Autowired
private SmsUtil smsUtil;
@Autowired
private UserEbookBuyService userEbookBuyService;
@Autowired
private BookForumArticlesService bookForumArticlesService;
@@ -45,9 +47,14 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
}
@Override
public void sendCodeForRegister(String phone, String code,Integer areaCode) throws Exception {
public R sendCodeForRegister(String phone, String code,Integer areaCode) throws Exception {
String scode = code.split("_")[0];
sendCode(phone,scode,areaCode);
// sendCode(phone,scode,areaCode);
if (areaCode!=null&&areaCode>0&&areaCode!=86){
return smsUtil.sendSmsAbroad(""+areaCode+phone,scode);
}else {
return smsUtil.sendSmsCode(phone,scode);
}
}
@Override