61 lines
2.0 KiB
C#
61 lines
2.0 KiB
C#
namespace LMS.Common.Templates
|
||
{
|
||
public class EmailTemplateService()
|
||
{
|
||
/// <summary>
|
||
/// 注册邮件模板
|
||
/// </summary>
|
||
public const string RegisterHtmlTemplates = """
|
||
<!DOCTYPE html>
|
||
<html>
|
||
<body>
|
||
<h1>LMS注册验证码</h1>
|
||
<p>您好,</p>
|
||
<p>您的验证码是 <strong>{RegisterCode}</strong></p>
|
||
<p>该验证码有效期为 10 分钟,如果不是您本人操作,请忽略此邮件。</p>
|
||
</body>
|
||
</html>
|
||
""";
|
||
|
||
public const string ResetPasswordHtmlTemplates = """
|
||
<!DOCTYPE html>
|
||
<html>
|
||
<body>
|
||
<h1>LMS重置密码验证码</h1>
|
||
<p>您好,</p>
|
||
<p>您的验证码是 <strong>{ResetPasswordCode}</strong></p>
|
||
<p>该验证码有效期为 10 分钟,如果不是您本人操作,请忽略此邮件。</p>
|
||
</body>
|
||
</html>
|
||
""";
|
||
|
||
public const string ResetpasswordSuccessMail = """
|
||
<!DOCTYPE html>
|
||
<html>
|
||
<body>
|
||
<h1>LMS重置密码成功</h1>
|
||
<p>您好,</p>
|
||
<p>您的重置密码操作已经成功!</p>
|
||
<p>您的新密码是 <strong>{NewPassword}</strong></p>
|
||
</body>
|
||
</html>
|
||
""";
|
||
|
||
/// <summary>
|
||
/// 替换模板的占位符
|
||
/// </summary>
|
||
/// <param name="template"></param>
|
||
/// <param name="parameters"></param>
|
||
/// <returns></returns>
|
||
public static string ReplaceTemplate(string template, Dictionary<string, string> parameters)
|
||
{
|
||
// 替换占位符
|
||
foreach (var param in parameters)
|
||
{
|
||
template = template.Replace($"{{{param.Key}}}", param.Value);
|
||
}
|
||
return template;
|
||
}
|
||
}
|
||
}
|