You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
2.8 KiB
C#

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