LMS.service/LMS.Common/Templates/EmailTemplateService.cs
lq1405 a23984c9f5 V1.0.5
新增用户重置密码和修改密码
2025-03-22 20:48:40 +08:00

61 lines
2.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
}
}
}