feat(user): 用户注册成功后发送邮件通知
- 在用户注册成功后,添加了发送邮件通知的功能 - 邮件内容包括用户名、密码和手机号码等信息 - 通过 EmailRecordService 发送邮件
This commit is contained in:
@@ -24,6 +24,7 @@ import com.gxwebsoft.common.core.security.JwtSubject;
|
|||||||
import com.gxwebsoft.common.core.security.JwtUtil;
|
import com.gxwebsoft.common.core.security.JwtUtil;
|
||||||
import com.gxwebsoft.common.core.utils.CacheClient;
|
import com.gxwebsoft.common.core.utils.CacheClient;
|
||||||
import com.gxwebsoft.common.core.utils.CommonUtil;
|
import com.gxwebsoft.common.core.utils.CommonUtil;
|
||||||
|
import com.gxwebsoft.common.core.utils.DomainUtil;
|
||||||
import com.gxwebsoft.common.core.utils.RedisUtil;
|
import com.gxwebsoft.common.core.utils.RedisUtil;
|
||||||
import com.gxwebsoft.common.core.web.ApiResult;
|
import com.gxwebsoft.common.core.web.ApiResult;
|
||||||
import com.gxwebsoft.common.core.web.BaseController;
|
import com.gxwebsoft.common.core.web.BaseController;
|
||||||
@@ -92,6 +93,8 @@ public class MainController extends BaseController {
|
|||||||
private UserRoleService userRoleService;
|
private UserRoleService userRoleService;
|
||||||
@Resource
|
@Resource
|
||||||
private UserRefereeService userRefereeService;
|
private UserRefereeService userRefereeService;
|
||||||
|
@Resource
|
||||||
|
private EmailRecordService emailRecordService;
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation("用户登录")
|
@ApiOperation("用户登录")
|
||||||
@@ -607,6 +610,7 @@ public class MainController extends BaseController {
|
|||||||
public ApiResult<LoginResult> register(@RequestBody User user) {
|
public ApiResult<LoginResult> register(@RequestBody User user) {
|
||||||
// 验证签名
|
// 验证签名
|
||||||
String tenantName = user.getCompanyName(); // 应用名称
|
String tenantName = user.getCompanyName(); // 应用名称
|
||||||
|
String username = user.getUsername(); // 用户名
|
||||||
String phone = user.getPhone(); // 手机号码
|
String phone = user.getPhone(); // 手机号码
|
||||||
String password = user.getPassword(); // 密码
|
String password = user.getPassword(); // 密码
|
||||||
String code = user.getCode(); // 短信验证码
|
String code = user.getCode(); // 短信验证码
|
||||||
@@ -628,6 +632,7 @@ public class MainController extends BaseController {
|
|||||||
userParam.setPhone(phone);
|
userParam.setPhone(phone);
|
||||||
userParam.setEmail(email);
|
userParam.setEmail(email);
|
||||||
userParam.setPassword(password);
|
userParam.setPassword(password);
|
||||||
|
userParam.setUsername(username);
|
||||||
userParam.setNickname(DesensitizedUtil.mobilePhone(phone));
|
userParam.setNickname(DesensitizedUtil.mobilePhone(phone));
|
||||||
if (user.getTemplateId() != null) {
|
if (user.getTemplateId() != null) {
|
||||||
userParam.setTemplateId(user.getTemplateId());
|
userParam.setTemplateId(user.getTemplateId());
|
||||||
@@ -638,6 +643,16 @@ public class MainController extends BaseController {
|
|||||||
// 签发token
|
// 签发token
|
||||||
String access_token = JwtUtil.buildToken(new JwtSubject(phone, addUser.getTenantId()),
|
String access_token = JwtUtil.buildToken(new JwtSubject(phone, addUser.getTenantId()),
|
||||||
tokenExpireTime, configProperties.getTokenKey());
|
tokenExpireTime, configProperties.getTokenKey());
|
||||||
|
// 发送邮件通知
|
||||||
|
String title = "恭喜!您的WebSoft账号已注册成功";
|
||||||
|
String appUrl = "\r\n用户名:" + username;
|
||||||
|
String passwordStr = "\r\n密码:" + password;
|
||||||
|
String appName = "\r\n手机号码:" + phone;
|
||||||
|
String content = title + appUrl + appName + passwordStr;
|
||||||
|
// 发送邮件通知
|
||||||
|
if (email != null) {
|
||||||
|
emailRecordService.sendEmail(title, content, email);
|
||||||
|
}
|
||||||
return success("注册成功", new LoginResult(access_token, addUser));
|
return success("注册成功", new LoginResult(access_token, addUser));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user