// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
//
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
namespace Admin.NET.Core;
///
/// 短信配置选项
///
public sealed class SMSOptions : IConfigurableOptions
{
///
/// 验证码缓存过期时间(秒)
/// 默认: 60秒
///
public int VerifyCodeExpireSeconds { get; set; } = 60;
///
/// Aliyun
///
public SMSSettings Aliyun { get; set; }
///
/// Tencentyun
///
public SMSSettings Tencentyun { get; set; }
///
/// Custom 自定义短信接口
///
public CustomSMSSettings Custom { get; set; }
}
public sealed class SMSSettings
{
///
/// SdkAppId
///
public string SdkAppId { get; set; }
///
/// AccessKey ID
///
public string AccessKeyId { get; set; }
///
/// AccessKey Secret
///
public string AccessKeySecret { get; set; }
///
/// Templates
///
public List Templates { get; set; }
///
/// GetTemplate
///
public SmsTemplate GetTemplate(string id = "0")
{
foreach (var template in Templates)
{
if (template.Id == id) { return template; }
}
return null;
}
}
public class SmsTemplate
{
public string Id { get; set; } = string.Empty;
public string SignName { get; set; }
public string TemplateCode { get; set; }
public string Content { get; set; }
}
///
/// 自定义短信配置
///
public sealed class CustomSMSSettings
{
///
/// 是否启用自定义短信接口
///
public bool Enabled { get; set; }
///
/// API 接口地址模板
/// 支持占位符: {mobile} - 手机号, {content} - 短信内容, {code} - 验证码
///
/// 示例: https://api.xxxx.com/sms?u=xxxx&key=59e03f49c3dbb5033&m={mobile}&c={content}
public string ApiUrl { get; set; }
///
/// 请求方法 (GET/POST)
///
public string Method { get; set; } = "GET";
///
/// POST 请求的 Content-Type (application/json 或 application/x-www-form-urlencoded)
/// 默认: application/x-www-form-urlencoded
///
public string ContentType { get; set; } = "application/x-www-form-urlencoded";
///
/// POST 请求的数据模板(支持占位符)
///
///
/// JSON 格式示例: {"mobile":"{mobile}","content":"{content}","apikey":"your_key"}
/// Form 格式示例: mobile={mobile}&content={content}&apikey=your_key
///
public string PostData { get; set; }
///
/// 成功响应标识(用于判断发送是否成功)
/// 如果响应内容包含此字符串,则认为发送成功
///
public string SuccessFlag { get; set; } = "0";
///
/// 短信模板列表
///
public List Templates { get; set; }
///
/// 获取模板
///
public SmsTemplate GetTemplate(string id = "0")
{
foreach (var template in Templates)
{
if (template.Id == id) { return template; }
}
return null;
}
}