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.

138 lines
3.4 KiB
C#

using System.Collections.ObjectModel;
using System.Dynamic;
namespace DS.WMS.Core.Op.Entity
{
/// <summary>
/// 邮件模板模型
/// </summary>
public class MailTemplateModel
{
/// <summary>
/// 业务ID
/// </summary>
public long BusinessId { get; set; }
/// <summary>
/// 业务ID
/// </summary>
public BusinessType BusinessType { get; set; } = BusinessType.OceanShippingExport;
/// <summary>
/// 发送附件
/// </summary>
public List<FileAttachment>? FileAttachments { get; set; }
/// <summary>
/// 发件人
/// </summary>
public MailSender Sender { get; set; }
/// <summary>
/// 收件人
/// </summary>
public List<MailReceiver> Receivers { get; set; }
/// <summary>
/// 当前业务联系人
/// </summary>
public string Contacts => Receivers == null ? string.Empty : string.Join(",", Receivers.Select(x => x.DisplayName));
/// <summary>
/// 主要数据项
/// </summary>
public dynamic Primary { get; set; } = new ExpandoObject();
}
public class MailSender
{
/// <summary>
/// 显示名称
/// </summary>
public string DisplayName { get; set; }
/// <summary>
/// 邮件地址
/// </summary>
public string MailAddress { get; set; }
/// <summary>
/// 个人签名内容
/// </summary>
public string? SignatureHtml { get; set; }
}
public class MailReceiver
{
/// <summary>
/// 显示名称
/// </summary>
public string DisplayName { get; set; }
/// <summary>
/// 邮件地址
/// </summary>
public string MailAddress { get; set; }
}
/// <summary>
/// 文件附件
/// </summary>
public class FileAttachment
{
/// <summary>
/// 文件物理路径
/// </summary>
public string FilePath { get; set; }
/// <summary>
/// 附件显示的名称(为空时显示原始文件名)
/// </summary>
public string? DisplayName { get; set; }
}
/// <summary>
/// 邮件模板模型
/// </summary>
/// <typeparam name="T">数据类型</typeparam>
public class MailTemplateModel<T> : MailTemplateModel
{
/// <summary>
/// 主要数据项
/// </summary>
public new T Primary { get; internal set; }
/// <summary>
/// 初始化
/// </summary>
/// <param name="primary">主数据</param>
public MailTemplateModel(T primary)
{
Primary = primary;
}
}
/// <summary>
/// 邮件模板模型
/// </summary>
/// <typeparam name="T1">主要数据类型</typeparam>
/// <typeparam name="T2">次要数据类型</typeparam>
public class MailTemplateModel<T1, T2> : MailTemplateModel<T1>
{
/// <summary>
/// 次要数据项
/// </summary>
public T2 Secondary { get; internal set; }
/// <summary>
/// 初始化
/// </summary>
/// <param name="primary">主数据</param>
/// <param name="secondary">主数据</param>
public MailTemplateModel(T1 primary, T2 secondary) : base(primary)
{
Secondary = secondary;
}
}
}