短信验证码

master
shijie 4 years ago
parent 17c047ff29
commit ee26c4e201
  1. 5
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/UserServiceImpl.java
  2. 2
      dq-framework-common/src/main/java/com/daqing/framework/util/SendSMS.java

@ -31,6 +31,7 @@ import com.daqing.framework.domain.hrms.UserEntity;
import com.daqing.financial.hrms.service.UserService;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
@ -38,7 +39,7 @@ import javax.imageio.ImageIO;
@Service("userService")
public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements UserService {
@Autowired
@Resource
private EmployeeDao employeeDao;
/**
@ -201,7 +202,7 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
}
String code = (int)((Math.random() * 9 + 1) * 100000)+ "";
// 发送短信
Boolean result = SendSMS.sendCode(phone, code);
Boolean result = SendSMS.sendCode(phone,"SMS_204155294",code);
if (result){
RedisUtil.setEx(phone,code,PromptSuccess.OVERDUE_TIME);
return true;

@ -59,7 +59,7 @@ public class SendSMS {
//必填:短信签名-可在短信控制台中找到
request.setSignName("职站");//注意要与你在短信控制台中的签名一致
//必填:短信模板-可在短信控制台中找到
request.setTemplateCode("SMS_204155294");
request.setTemplateCode(sendTemplate);
//可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
//友情提示:如果JSON中需要带换行符,请参照标准的JSON协议对换行符的要求,比如短信内容中包含\r\n的情况在JSON中需要表示成\\r\\n,否则会导致JSON在服务端解析失败
// request.setTemplateParam("{\"name\":\"Tom\", \"code\":\"123\"}");

Loading…
Cancel
Save