All checks were successful
Build and Deploy / deploy (push) Successful in 1m21s
支持入库/出库/签收/派送失败/问题件推送,客户默认可选订阅,运营可配模板并试发。 Co-authored-by: Cursor <cursoragent@cursor.com>
32 lines
1.0 KiB
C#
32 lines
1.0 KiB
C#
using Oms.Application.Integrations.WeChat;
|
|
|
|
namespace SimpleAdmin.Api.WeChat.Services;
|
|
|
|
/// <summary>
|
|
/// 将 <see cref="IWeChatMpApiClient"/> 适配为 Application 层模板发送接口。
|
|
/// </summary>
|
|
internal sealed class WeChatMpTemplateSenderAdapter(IWeChatMpApiClient apiClient) : IWeChatMpTemplateSender
|
|
{
|
|
public async Task<WeChatMpTemplateSendResult> SendAsync(
|
|
string openId,
|
|
string templateId,
|
|
string? url,
|
|
IReadOnlyDictionary<string, WeChatMpTemplateDataItem> 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);
|
|
}
|
|
}
|