using Newtonsoft.Json;
using NPin.Framework.Upms.Domain.Shared.Enums;
namespace NPin.Framework.Upms.Domain.Shared.Model;
public class SmsConfigModel
{
///
/// 是否启用(总控)
///
public bool Enabled { get; set; } = false;
///
/// 提供商列表
///
[JsonIgnore]
public List Providers { get; set; } = [];
///
/// 短信模板列表
///
[JsonIgnore]
public List Templates { get; set; } = [];
///
/// 系统短信设定集
/// 类型:设定
///
[JsonIgnore]
public Dictionary Settings { get; set; } = new();
public SmsProvider GetProvider(SmsSettings settings)
{
return Providers.First(it => it.Id == settings.ProviderId);
}
public SmsTemplate GetTemplate(SmsSettings settings)
{
return Templates.First(it => it.Id == settings.TemplateId);
}
public SmsSettings? GetSetting(SmsTypeEnum typeEnum)
{
return Settings.GetValueOrDefault(typeEnum, null);
}
}
///
/// 短信提供商配置
///
public class SmsProvider
{
///
/// ID
///
public Guid Id { get; set; }
///
/// 服务提供商
///
public SmsProviderTypeEnum ProviderType { get; set; }
///
/// 访问密钥Key
///
public string AccessKeyId { get; set; }
///
/// 访问密钥
///
public string AccessKeySecret { get; set; }
///
/// 区域
///
public string Region { get; set; }
///
/// 短信访问 端点
///
public string Endpoint { get; set; }
///
/// 短信SdkAppId
///
public string SmsSdkAppId { get; set; }
}
public class SmsTemplate
{
///
/// ID
///
public Guid Id { get; set; }
///
/// 短信签名名称
///
public string SignName { get; set; }
///
/// 短信模板Code
///
public string TemplateCode { get; set; }
}
public class SmsSettings
{
///
/// 短信类型
///
public SmsTypeEnum SmsType { get; set; }
///
/// 提供商ID
///
public Guid ProviderId { get; set; }
///
/// 模板ID
///
public Guid TemplateId { get; set; }
///
/// 过期时间,单位:秒
///
public int Expires { get; set; }
}