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;
}
///
/// 获取生成的模板内容 根据模板名称 和 传入的对象进行替换
///
///
///
///
[HttpGet("template-content")]
public virtual async Task GetEmailTemplateContentAsync(string templateJson, string templateName)
{
var dict = JsonSerializer.Deserialize>(templateJson);
return await _templateRenderer.RenderAsync(templateName, dict).ConfigureAwait(false);
}
}