整合预先登录接口与邮件发送
This commit is contained in:
@@ -14,7 +14,19 @@ public class AccountPreLoginDTO {
|
||||
@ApiModelProperty("用户名")
|
||||
private String userName;
|
||||
|
||||
/*新增字段*/
|
||||
@NotBlank(message = "Please input email !")
|
||||
@ApiModelProperty("邮箱")
|
||||
private String email;
|
||||
|
||||
@NotBlank(message = "password cannot be empty!")
|
||||
@ApiModelProperty("密码")
|
||||
private String password;
|
||||
|
||||
@NotBlank(message = "operationType cannot be empty")
|
||||
@ApiModelProperty("操作类型 LOGIN 注册 FORGET_PWD 忘记密码 BIND_MAILBOX 绑定邮箱")
|
||||
private String operationType;
|
||||
|
||||
@ApiModelProperty("异常ip")
|
||||
private String ip;
|
||||
}
|
||||
|
||||
@@ -73,6 +73,37 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
}else{
|
||||
Assert.isTrue(account.getUserPassword().equals(accountDTO.getPassword()),"Password error !");
|
||||
}
|
||||
/*发送邮件*/
|
||||
OperationTypeEnum operationTypeEnum = OperationTypeEnum.of(accountDTO.getOperationType());
|
||||
Assert.notNull(operationTypeEnum, "Unknown operation type!");
|
||||
String randomVerifyCode = RandomsUtil.generateVerifyCode(100000L, 999999L);
|
||||
LocalCacheUtils.setVerifyCodeCache(
|
||||
accountDTO.getOperationType() + "_" + accountDTO.getEmail(), randomVerifyCode);
|
||||
Boolean result = Boolean.FALSE;
|
||||
switch (operationTypeEnum) {
|
||||
case LOGIN:
|
||||
Assert.notNull(accountDTO, "Email not registered!");
|
||||
result = SendEmailUtil.send(accountDTO.getEmail(), null,
|
||||
SendEmailUtil.LOGIN_TEMPLATE_ID, randomVerifyCode);
|
||||
break;
|
||||
case FORGET_PWD:
|
||||
Assert.notNull(accountDTO, "Email not registered!");
|
||||
result = SendEmailUtil.send(accountDTO.getEmail(), null,
|
||||
SendEmailUtil.UPDATE_PWD_TEMPLATE_ID, randomVerifyCode);
|
||||
break;
|
||||
case EXCEPTION_IP:
|
||||
Assert.notNull(accountDTO, "Email not registered!");
|
||||
result = SendEmailUtil.send(accountDTO.getEmail(), accountDTO.getIp(),
|
||||
SendEmailUtil.EXCEPTION_ID_TEMPLATE_ID, randomVerifyCode);
|
||||
break;
|
||||
case BIND_MAILBOX:
|
||||
result = SendEmailUtil.send(accountDTO.getEmail(), null,
|
||||
SendEmailUtil.BIND_MAILBOX_TEMPLATE_ID, randomVerifyCode);
|
||||
break;
|
||||
default:
|
||||
Assert.notNull(operationTypeEnum, "Unknown operation type!");
|
||||
}
|
||||
Assert.isTrue(result, "Failed to send mail");
|
||||
return new AccountPreLoginVO(account.getId());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
server.port=5566
|
||||
server.port=5567
|
||||
|
||||
#datasource
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.url=jdbc:mysql://18.162.111.141:3306/aida?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=QWa998345
|
||||
spring.datasource.url=jdbc:mysql://192.168.77.128:3306/aida?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
|
||||
spring.datasource.username=zcr
|
||||
spring.datasource.password=root
|
||||
|
||||
#security
|
||||
spring.security.jwtSecret=JWTSECRET
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
#spring.profiles.active=test
|
||||
|
||||
#<23><><EFBFBD><EFBFBD>application-prod<6F>ļ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||
spring.profiles.active=prod
|
||||
spring.profiles.active=test
|
||||
Reference in New Issue
Block a user