| | |
| | | private RedisManager redisManager;
|
| | |
|
| | | @Override
|
| | | public String sendLoginVCode(String phone) throws SMSException {
|
| | | public String sendLoginVCode(String phone, int codeLength) throws SMSException {
|
| | | boolean limit = redisManager.isSmsFrequencyLimit(phone, SMSHistory.TYPE_LOGIN);
|
| | | if (limit)
|
| | | throw new SMSException(1001, "请过60秒再试");
|
| | | String msgCode = StringUtil.getVerifyCode(6);
|
| | | System.out.println(msgCode);
|
| | | |
| | | String msgCode = StringUtil.getVerifyCode(codeLength);
|
| | | // 验证码模板
|
| | | String msg = Constant.smsConfig.getSmsLogin().replace("[签名]", Constant.smsConfig.getSmsSign()).replace("[验证码]",
|
| | | msgCode);
|
| | |
| | | // 缓存
|
| | | redisManager.sendSms(phone, SMSHistory.TYPE_LOGIN);
|
| | | redisManager.saveSMSVCode(phone, SMSHistory.TYPE_LOGIN, msgCode);
|
| | | |
| | | SMSHistory smsHistory = new SMSHistory();
|
| | | smsHistory.setContent(msg);
|
| | | smsHistory.setCreateTime(new Date());
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public void sendBindVCode(String phone) throws SMSException {
|
| | | public void sendBindVCode(String phone, int codeLength) throws SMSException {
|
| | | boolean limit = redisManager.isSmsFrequencyLimit(phone, SMSHistory.TYPE_BIND);
|
| | | if (limit)
|
| | | throw new SMSException(1001, "请过60秒再试");
|
| | | String msgCode = StringUtil.getRandomCode(6);
|
| | | String msgCode = StringUtil.getVerifyCode(codeLength);
|
| | | |
| | | // 验证码模板
|
| | | String msg = Constant.smsConfig.getSmsBind().replace("[签名]", Constant.smsConfig.getSmsSign()).replace("[验证码]",
|
| | | msgCode);
|
| | | // 发送短信
|
| | | TencentSMSUtil.sendSingleMsg(phone, msg);
|
| | | |
| | | // 缓存
|
| | | redisManager.sendSms(phone, SMSHistory.TYPE_BIND);
|
| | | redisManager.saveSMSVCode(phone, SMSHistory.TYPE_BIND, msgCode);
|
| | | |
| | | SMSHistory smsHistory = new SMSHistory();
|
| | | smsHistory.setContent(msg);
|
| | | smsHistory.setCreateTime(new Date());
|
| | | smsHistory.setPhone(phone);
|
| | | smsHistory.setType(SMSHistory.TYPE_BIND);
|
| | | smsHistoryMapper.insertSelective(smsHistory);
|
| | | }
|
| | |
|
| | | @Override
|