using Oms.Application.Integrations.WeChat; namespace SimpleAdmin.Api.WeChat.Services; /// /// 将 适配为 Application 层模板发送接口。 /// internal sealed class WeChatMpTemplateSenderAdapter(IWeChatMpApiClient apiClient) : IWeChatMpTemplateSender { public async Task SendAsync( string openId, string templateId, string? url, IReadOnlyDictionary data, CancellationToken cancellationToken = default) { var mapped = data.ToDictionary( x => x.Key, x => new WeChatTemplateDataValue(x.Value.Value, x.Value.Color), StringComparer.OrdinalIgnoreCase); var result = await apiClient.SendTemplateMessageAsync( openId, templateId, url, mapped, cancellationToken); return new WeChatMpTemplateSendResult(result.Success, result.MsgId, result.ErrCode, result.ErrMsg); } }