feat(system): 支持按应用代号发送开通成功邮件
- 在 Company 和 User 实体中新增 appCode 字段,接收前端传入的应用代号 - MainController 传递 appCode 到 Company 实体,用于后续处理 - TenantServiceImpl 根据 appCode 动态生成不同域名的网址和后台管理地址 - 优化企业开通成功邮件内容,增强安全提示和登录信息展示 - 邮件发送逻辑改为根据应用代号映射对应的站点和后台域名
This commit is contained in:
@@ -1603,6 +1603,7 @@ public class MainController extends BaseController {
|
||||
company.setEmail(email);
|
||||
company.setPhone(phone);
|
||||
company.setPassword(password);
|
||||
company.setAppCode(user.getAppCode());
|
||||
company.setTid(tenant.getTenantId());
|
||||
company.setShortName(tenantName);
|
||||
company.setCategoryId(661);
|
||||
|
||||
@@ -294,6 +294,10 @@ public class Company implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private String password;
|
||||
|
||||
@Schema(description = "应用代号(非数据库字段,注册时由前端传入,用于生成开通邮件中的域名,如 mp/shop/site)")
|
||||
@TableField(exist = false)
|
||||
private String appCode;
|
||||
|
||||
@Schema(description = "手机号(脱敏)")
|
||||
@TableField(exist = false)
|
||||
private String mobile;
|
||||
|
||||
@@ -61,6 +61,10 @@ public class User implements UserDetails {
|
||||
@Schema(description = "邮箱")
|
||||
private String email;
|
||||
|
||||
@Schema(description = "应用代号(非数据库字段,注册时由前端传入,用于生成开通邮件中的域名,如 mp/shop/site)")
|
||||
@TableField(exist = false)
|
||||
private String appCode;
|
||||
|
||||
@Schema(description = "邮箱验证码(非数据库字段,仅用于绑定/修改邮箱时校验)")
|
||||
@TableField(exist = false)
|
||||
private String emailCode;
|
||||
|
||||
@@ -619,17 +619,38 @@ import java.util.stream.Collectors;
|
||||
}
|
||||
|
||||
}
|
||||
// 发送邮件通知
|
||||
String title = "恭喜!您的应用已创建成功";
|
||||
String appUrl = "\r\n应用地址:" + DomainUtil.getSiteUrl(company.getTid().toString());
|
||||
String appName = "\r\n应用名称:" + company.getShortName();
|
||||
String adminUrl = "\r\n后台管理:" + DomainUtil.getAdminUrl(company.getTid().toString());
|
||||
String account = "\r\n账号:admin";
|
||||
String password = "\r\n密码:" + company.getPassword();
|
||||
String content = title + appUrl + appName + adminUrl + account + password;
|
||||
// 发送邮件通知(按应用代号区分域名:前端注册时传入 appCode,未知默认 mp)
|
||||
// mp -> https://mp-{tid}.shoplnk.cn 后台 https://mp.websoft.top
|
||||
// shop -> https://shop-{tid}.shoplnk.cn 后台 https://shop.websoft.top
|
||||
// site -> https://site-{tid}.websoft.top 后台 https://site.websoft.top
|
||||
final Map<String, String[]> appDomainMap = new HashMap<>(3);
|
||||
appDomainMap.put("mp", new String[]{"mp", "shoplnk.cn", "mp.websoft.top"});
|
||||
appDomainMap.put("shop", new String[]{"shop", "shoplnk.cn", "shop.websoft.top"});
|
||||
appDomainMap.put("site", new String[]{"site", "websoft.top", "site.websoft.top"});
|
||||
final String appCode = StrUtil.isBlank(company.getAppCode()) ? "mp" : company.getAppCode();
|
||||
final String[] domainCfg = appDomainMap.getOrDefault(appCode, appDomainMap.get("mp"));
|
||||
final String sitePrefix = domainCfg[0];
|
||||
final String siteDomain = domainCfg[1];
|
||||
final String adminHost = domainCfg[2];
|
||||
final String siteUrl = "https://" + sitePrefix + "-" + company.getTid() + "." + siteDomain;
|
||||
final String adminUrl = "https://" + adminHost;
|
||||
final String title = "您的企业官网已开通成功";
|
||||
final StringBuilder content = new StringBuilder();
|
||||
content.append("尊敬的用户:\r\n\r\n");
|
||||
content.append("恭喜!您的企业官网「").append(company.getShortName()).append("」已开通成功。\r\n\r\n");
|
||||
content.append("您可以使用以下信息登录管理后台,继续完善站点内容:\r\n\r\n");
|
||||
content.append("• 官网地址:").append(siteUrl).append("\r\n");
|
||||
content.append("• 后台地址:").append(adminUrl).append("\r\n");
|
||||
content.append("• 登录账号:").append(company.getEmail()).append("\r\n");
|
||||
content.append("• 登录密码:").append(company.getPassword()).append("\r\n\r\n");
|
||||
content.append("安全提示:\r\n");
|
||||
content.append("1. 请妥善保管登录密码,不要通过邮件、聊天工具发送给他人。\r\n");
|
||||
content.append("2. 建议首次登录后立即进入「个人中心 > 修改密码」重置密码。\r\n\r\n");
|
||||
content.append("点击登录后台:").append(adminUrl).append("\r\n\r\n");
|
||||
content.append("如有疑问,请联系客服或访问帮助中心。");
|
||||
// 发送邮件通知
|
||||
if (company.getEmail() != null) {
|
||||
emailRecordService.sendEmail(title, content, company.getEmail(), company.getTid());
|
||||
emailRecordService.sendEmail(title, content.toString(), company.getEmail(), company.getTid());
|
||||
}
|
||||
return company;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user