Files
EmailBill/WebApi/Controllers/Dto/EmailMessageDto.cs
SunCheng 435efbcb90
Some checks failed
Docker Build & Deploy / Build Docker Image (push) Failing after 38s
Docker Build & Deploy / Deploy to Production (push) Has been skipped
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 2s
Docker Build & Deploy / WeChat Notification (push) Successful in 2s
大量的代码格式化
2026-01-18 22:25:59 +08:00

51 lines
1.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
namespace WebApi.Controllers.Dto;
/// <summary>
/// 邮件消息DTO包含额外的统计信息
/// </summary>
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; }
/// <summary>
/// 已解析的账单数量
/// </summary>
public int TransactionCount { get; set; }
public string ToName { get; set; } = string.Empty;
/// <summary>
/// 从实体转换为DTO
/// </summary>
public static EmailMessageDto FromEntity(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,
ToName = entity.To.Split('<').FirstOrDefault()?.Trim() ?? "未知"
};
}
}