namespace WebApi.Controllers.Dto;
///
/// 邮件消息DTO,包含额外的统计信息
///
public class EmailMessageDto
{
public long Id { get; set; }
public string Subject { get; set; } = string.Empty;
public string From { get; set; } = string.Empty;
public string Body { get; set; } = string.Empty;
public string HtmlBody { get; set; } = string.Empty;
public DateTime ReceivedDate { get; set; }
public DateTime CreateTime { get; set; }
public DateTime? UpdateTime { get; set; }
///
/// 已解析的账单数量
///
public int TransactionCount { get; set; }
///
/// 从实体转换为DTO
///
public static EmailMessageDto FromEntity(Entity.EmailMessage entity, int transactionCount = 0)
{
return new EmailMessageDto
{
Id = entity.Id,
Subject = entity.Subject,
From = entity.From,
Body = entity.Body,
HtmlBody = entity.HtmlBody,
ReceivedDate = entity.ReceivedDate,
CreateTime = entity.CreateTime,
UpdateTime = entity.UpdateTime,
TransactionCount = transactionCount
};
}
}