From 1da17d215d48e3e3aa9e8d7a3ef526904764f408 Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期一, 08 四月 2019 14:06:12 +0800 Subject: [PATCH] 1.5.3部分需求 提交 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/SMSServiceImpl.java | 21 ++++++++++++++++----- 1 files changed, 16 insertions(+), 5 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/SMSServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/SMSServiceImpl.java index 1595cbc..26a3487 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/SMSServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/SMSServiceImpl.java @@ -26,12 +26,12 @@ 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); @@ -40,6 +40,7 @@ // 缂撳瓨 redisManager.sendSms(phone, SMSHistory.TYPE_LOGIN); redisManager.saveSMSVCode(phone, SMSHistory.TYPE_LOGIN, msgCode); + SMSHistory smsHistory = new SMSHistory(); smsHistory.setContent(msg); smsHistory.setCreateTime(new Date()); @@ -50,18 +51,28 @@ } @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 -- Gitblit v1.8.0