You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

35 lines
1.1 KiB

using System.Collections.Generic;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Application.Services;
using Volo.Abp.TextTemplating;
using Win_in.Sfs.Message.Domain.Shared;
namespace Win_in.Sfs.Message.Application;
[Route($"{MessageConsts.RootPath}email-template")]
public class EmailTemplateService : ApplicationService
{
private readonly ITemplateRenderer _templateRenderer;
public EmailTemplateService(ITemplateRenderer templateRenderer)
{
_templateRenderer = templateRenderer;
}
/// <summary>
/// 获取生成的模板内容 根据模板名称 和 传入的对象进行替换
/// </summary>
/// <param name="templateJson"></param>
/// <param name="templateName"></param>
/// <returns></returns>
[HttpGet("template-content")]
public virtual async Task<string> GetEmailTemplateContentAsync(string templateJson, string templateName)
{
var dict = JsonSerializer.Deserialize<Dictionary<string, string>>(templateJson);
return await _templateRenderer.RenderAsync(templateName, dict).ConfigureAwait(false);
}
}