新增注册功能 通过手机号注册账号90%

This commit is contained in:
WangHao
2021-04-18 20:36:23 +08:00
parent af5faf60df
commit 4131d8bdca
17 changed files with 557 additions and 228 deletions

View File

@ -69,7 +69,7 @@ public class Constants
/**
* 手机号验证码有效期(分钟)
*/
public static final Integer CAPTCHA_PHONE_EXPIRATION = 2;
public static final Integer CAPTCHA_PHONE_EXPIRATION = 15;
/**
* 令牌

View File

@ -17,19 +17,6 @@ public class LoginBody
*/
private String password;
/**
* 邮箱
*/
private String email;
/**
* 手机号
*/
private String phone;
/**
* 手机号验证码
*/
private String phoneCode;
/**
* 验证码
*/
@ -79,28 +66,4 @@ public class LoginBody
{
this.uuid = uuid;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getPhoneCode() {
return phoneCode;
}
public void setPhoneCode(String phoneCode) {
this.phoneCode = phoneCode;
}
}

View File

@ -0,0 +1,106 @@
package com.ruoyi.common.core.domain.model;
/**
* 用户登录对象
*
* @author ruoyi
*/
public class RegisterBody
{
/**
* 用户名
*/
private String username;
/**
* 用户密码
*/
private String password;
/**
* 邮箱
*/
private String email;
/**
* 手机号
*/
private String phone;
/**
* 手机号验证码
*/
private String phoneCode;
/**
* 验证码
*/
private String code;
/**
* 唯一标识
*/
private String uuid = "";
public String getUsername()
{
return username;
}
public void setUsername(String username)
{
this.username = username;
}
public String getPassword()
{
return password;
}
public void setPassword(String password)
{
this.password = password;
}
public String getCode()
{
return code;
}
public void setCode(String code)
{
this.code = code;
}
public String getUuid()
{
return uuid;
}
public void setUuid(String uuid)
{
this.uuid = uuid;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getPhoneCode() {
return phoneCode;
}
public void setPhoneCode(String phoneCode) {
this.phoneCode = phoneCode;
}
}

View File

@ -12,4 +12,6 @@ public class RedisKey {
public static final String BOOKMARK ="bookMark:";
public static final String CONNECTOR =":";
public static final String REGISTER ="register:";
}

View File

@ -10,6 +10,7 @@ import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.redis.RedisKey;
import com.ruoyi.common.core.redis.RedisUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -37,6 +38,7 @@ public class PhoneCode {
*/
public static Boolean getPhonemsg(String phone) {
String key = RedisKey.BOOKMARK + RedisKey.REGISTER + phone;
// 短信验证---阿里
// 设置超时时间-可自行调整
System.setProperty(PhoneDeploy.defaultConnectTimeout, PhoneDeploy.Timeout);
@ -83,16 +85,16 @@ public class PhoneCode {
if (sendSmsResponse.getCode() != null && sendSmsResponse.getCode().equals("OK")) {
// 请求成功
RedisUtil redisUtil = new RedisUtil();
redisUtil.setEx(phone,code,Constants.CAPTCHA_PHONE_EXPIRATION, TimeUnit.MINUTES);
redisUtil.setEx(key,code,Constants.CAPTCHA_PHONE_EXPIRATION, TimeUnit.MINUTES);
return true;
} else {
// 验证码失败 如果验证码出错,会输出错误码告诉你具体原因
logger.info("手机号:" + code + " 时间"+DateUtil.now()+" 发送失败!!错误日志:"+sendSmsResponse.getCode());
logger.info("手机号:" + phone + " 时间"+DateUtil.now()+" 发送失败!!错误日志:"+sendSmsResponse.getCode());
return false;
}
} catch (ClientException e) {
e.printStackTrace();
logger.info("手机号:" + code + " 时间"+DateUtil.now()+" 发送失败!!");
logger.info("手机号:" + phone + " 时间"+DateUtil.now()+" 发送失败!!");
return false;
}
}