更换短信验证码
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
//充值花生币
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -77,8 +77,7 @@ public class UserController {
|
||||
//redis 缓存验证码
|
||||
redisTemplate.opsForValue().set("RegistCode"+phone,code,5, TimeUnit.MINUTES);
|
||||
//发送
|
||||
userService.sendCodeForRegister(phone,code,areacode);
|
||||
return R.ok();
|
||||
return userService.sendCodeForRegister(phone,code,areacode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.peanut.modules.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.MyUserEntity;
|
||||
|
||||
public interface MyUserService extends IService<MyUserEntity> {
|
||||
|
||||
void sendCodeForRegister(String phone, String code,Integer areaCode) throws Exception;
|
||||
R sendCodeForRegister(String phone, String code, Integer areaCode) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@ import com.aliyun.tea.TeaException;
|
||||
import com.aliyun.teautil.Common;
|
||||
import com.aliyun.teautil.models.RuntimeOptions;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bcloud.msg.http.HttpSender;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.SmsUtil;
|
||||
import com.peanut.modules.app.config.SMSConfig;
|
||||
import com.peanut.modules.app.config.Sample;
|
||||
import com.peanut.modules.common.dao.MyUserDao;
|
||||
@@ -22,11 +25,18 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
|
||||
|
||||
@Autowired
|
||||
private SMSConfig smsConfig;
|
||||
@Autowired
|
||||
private SmsUtil smsUtil;
|
||||
|
||||
@Override
|
||||
public void sendCodeForRegister(String phone, String code, Integer areaCode) throws Exception {
|
||||
public R sendCodeForRegister(String phone, String code, Integer areaCode){
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendCode(String phone, String code, Integer areaCode) throws Exception {
|
||||
@@ -59,4 +69,6 @@ public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> impl
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -31,13 +31,13 @@ public class VodAliController {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (!validRe) {
|
||||
return Base64.decodeBase64("Illegal access");
|
||||
return Base64.decodeBase64("Illegal access".getBytes());
|
||||
}
|
||||
if (null == cipherText) {
|
||||
return Base64.decodeBase64("Illegal access !");
|
||||
return Base64.decodeBase64("Illegal access !".getBytes());
|
||||
}
|
||||
DecryptKMSDataKeyResponseBody decryptKMSDataKeyResponseBody = SpdbUtil.enKMS(cipherText);
|
||||
return Base64.decodeBase64(decryptKMSDataKeyResponseBody.getPlaintext());
|
||||
return Base64.decodeBase64(decryptKMSDataKeyResponseBody.getPlaintext().getBytes());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user