Skip to content

Commit

Permalink
阿里sms默认短信验证码配置问题处理
Browse files Browse the repository at this point in the history
  • Loading branch information
chopper711 committed Jun 7, 2021
1 parent 0fc179c commit 6d7e9e7
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 6 deletions.
12 changes: 12 additions & 0 deletions common-api/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,18 @@ jasypt:
password: lili

lili:
#短信模版配置
sms:
#登录
LOGIN: SMS_205755300
#注册
REGISTER: SMS_205755298
#找回密码
FIND_USER: SMS_205755301
#设置密码
UPDATE_PASSWORD: SMS_205755297
#支付密码
WALLET_PASSWORD: SMS_205755301
system:
isDemoSite: true
licences: 'temporary'
Expand Down
12 changes: 12 additions & 0 deletions config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,18 @@ jasypt:
password: lili

lili:
#短信模版配置
sms:
#登录
LOGIN: SMS_205755300
#注册
REGISTER: SMS_205755298
#找回密码
FIND_USER: SMS_205755301
#设置密码
UPDATE_PASSWORD: SMS_205755297
#支付密码
WALLET_PASSWORD: SMS_205755301
system:
isDemoSite: false
statistics:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import cn.lili.common.sms.SmsUtil;
import cn.lili.common.utils.CommonUtil;
import cn.lili.common.verification.enums.VerificationEnums;
import cn.lili.config.properties.SmsTemplateSetting;
import cn.lili.modules.connect.util.Base64Utils;
import cn.lili.modules.member.entity.dos.Member;
import cn.lili.modules.member.service.MemberService;
Expand Down Expand Up @@ -51,6 +52,9 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
@Autowired
private MemberService memberService;

@Autowired
private SmsTemplateSetting smsTemplateSetting;

@Override
public void sendSmsCode(String mobile, VerificationEnums verificationEnums, String uuid) {
//获取短信配置
Expand All @@ -75,17 +79,17 @@ public void sendSmsCode(String mobile, VerificationEnums verificationEnums, Stri
switch (verificationEnums) {
//登录
case LOGIN: {
templateCode = "SMS_205755300";
templateCode = smsTemplateSetting.getLOGIN();
break;
}
//注册
case REGISTER: {
templateCode = "SMS_205755298";
templateCode = smsTemplateSetting.getREGISTER();
break;
}
//找回密码
case FIND_USER: {
templateCode = "SMS_205755301";
templateCode = smsTemplateSetting.getFIND_USER();
break;
}
//修改密码
Expand All @@ -96,7 +100,15 @@ public void sendSmsCode(String mobile, VerificationEnums verificationEnums, Stri
}
//更新为用户最新手机号
mobile = member.getMobile();
templateCode = "SMS_205755297";
templateCode = smsTemplateSetting.getUPDATE_PASSWORD();
break;
}
//设置支付密码
case WALLET_PASSWORD: {
Member member = memberService.getById(UserContext.getCurrentUser().getId());
//更新为用户最新手机号
mobile = member.getMobile();
templateCode = smsTemplateSetting.getWALLET_PASSWORD();
break;
}
//如果不是有效的验证码手段,则此处不进行短信操作
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package cn.lili.config.properties;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
* 短信模版设置
*
* @author Chopper
*/
@Data
@Configuration
@ConfigurationProperties(prefix = "lili.sms")
public class SmsTemplateSetting {
//登录
private String LOGIN = "SMS_205755300";
//注册
private String REGISTER = "SMS_205755298";
//找回密码
private String FIND_USER = "SMS_205755301";
//设置密码
private String UPDATE_PASSWORD = "SMS_205755297";
//设置支付密码
private String WALLET_PASSWORD = "SMS_205755297";
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/**
* 短信配置
*
* 这里在前台不做调整,方便客户直接把服务商的内容配置在我们平台
* @author Chopper
* @date 2020/11/30 15:23
*/
Expand All @@ -17,7 +17,7 @@ public class SmsSetting implements Serializable {
* 节点地址
* key
* 密钥
* 签名,这里在前台不做调整,方便客户直接把服务商的内容配置在我们平台
* 签名
*/
private String regionId;

Expand Down

0 comments on commit 6d7e9e7

Please sign in to comment.