feat: finalize core modules and gateway

This commit is contained in:
2025-11-23 18:53:12 +08:00
parent 429d4fb747
commit ae273e510a
115 changed files with 4695 additions and 223 deletions

View File

@@ -0,0 +1,35 @@
using System.Net.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using TakeoutSaaS.Module.Sms.Abstractions;
using TakeoutSaaS.Module.Sms.Models;
using TakeoutSaaS.Module.Sms.Options;
namespace TakeoutSaaS.Module.Sms.Services;
/// <summary>
/// 阿里云短信发送实现(简化版,占位可扩展正式签名流程)。
/// </summary>
public sealed class AliyunSmsSender(IHttpClientFactory httpClientFactory, IOptionsMonitor<SmsOptions> optionsMonitor, ILogger<AliyunSmsSender> logger)
: ISmsSender
{
private readonly IHttpClientFactory _httpClientFactory = httpClientFactory;
/// <inheritdoc />
public SmsProviderKind Provider => SmsProviderKind.Aliyun;
/// <inheritdoc />
public Task<SmsSendResult> SendAsync(SmsSendRequest request, CancellationToken cancellationToken = default)
{
var options = optionsMonitor.CurrentValue;
if (options.UseMock)
{
logger.LogInformation("Mock 发送阿里云短信到 {Phone}, Template:{Template}", request.PhoneNumber, request.TemplateCode);
return Task.FromResult(new SmsSendResult { Success = true, Message = "Mocked" });
}
// 占位:保留待接入阿里云正式签名流程,当前返回未实现。
logger.LogWarning("阿里云短信尚未启用,请配置腾讯云或开启 UseMock。");
return Task.FromResult(new SmsSendResult { Success = false, Message = "Aliyun SMS not enabled" });
}
}