package test;
public class SMSVerificationService {
public void sendVerificationCode(String phoneNum){
if (!repeatCheck(phoneNum)){
String code = buildVerificationCode();
SMSSendVerificationCode(phoneNum,code);
RedisUtils.getRedis().set(phoneNum,code,60);
}
}
private boolean repeatCheck(String phoneNum) {
Object value = RedisUtils.getRedis().get(phoneNum);
if (value != null) {
return false;
}
return true;
}
private String buildVerificationCode() {
return "11111111111";
}
private void SMSSendVerificationCode(String phoneNum,String code){
System.out.println("手机号 " + phoneNum + " 验证码:" + code);
}
}