修复
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace FutureMailAPI.DTOs
|
||||
{
|
||||
@@ -44,6 +45,82 @@ namespace FutureMailAPI.DTOs
|
||||
public string? Theme { get; set; }
|
||||
}
|
||||
|
||||
// 兼容前端请求格式的DTO
|
||||
public class SentMailCreateCompatDto
|
||||
{
|
||||
[Required(ErrorMessage = "标题是必填项")]
|
||||
[StringLength(200, ErrorMessage = "标题长度不能超过200个字符")]
|
||||
public string title { get; set; } = string.Empty;
|
||||
|
||||
[Required(ErrorMessage = "内容是必填项")]
|
||||
public string content { get; set; } = string.Empty;
|
||||
|
||||
[Required(ErrorMessage = "收件人类型是必填项")]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public RecipientTypeEnum recipientType { get; set; }
|
||||
|
||||
public string? recipientEmail { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "投递时间是必填项")]
|
||||
public DateTime sendTime { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "触发条件类型是必填项")]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public TriggerTypeEnum triggerType { get; set; }
|
||||
|
||||
public object? triggerCondition { get; set; }
|
||||
|
||||
public List<object>? attachments { get; set; }
|
||||
|
||||
public bool isEncrypted { get; set; } = false;
|
||||
|
||||
public string capsuleStyle { get; set; } = "default";
|
||||
|
||||
// 转换为内部DTO
|
||||
public SentMailCreateDto ToInternalDto()
|
||||
{
|
||||
var dto = new SentMailCreateDto
|
||||
{
|
||||
Title = this.title,
|
||||
Content = this.content,
|
||||
RecipientType = (int)this.recipientType,
|
||||
RecipientEmail = this.recipientEmail,
|
||||
DeliveryTime = this.sendTime,
|
||||
TriggerType = (int)this.triggerType,
|
||||
IsEncrypted = this.isEncrypted,
|
||||
Theme = this.capsuleStyle
|
||||
};
|
||||
|
||||
// 处理触发条件
|
||||
if (this.triggerCondition != null)
|
||||
{
|
||||
dto.TriggerDetails = System.Text.Json.JsonSerializer.Serialize(this.triggerCondition);
|
||||
}
|
||||
|
||||
// 处理附件
|
||||
if (this.attachments != null && this.attachments.Count > 0)
|
||||
{
|
||||
dto.Attachments = System.Text.Json.JsonSerializer.Serialize(this.attachments);
|
||||
}
|
||||
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
|
||||
public enum RecipientTypeEnum
|
||||
{
|
||||
SELF = 0,
|
||||
SPECIFIC = 1,
|
||||
PUBLIC = 2
|
||||
}
|
||||
|
||||
public enum TriggerTypeEnum
|
||||
{
|
||||
TIME = 0,
|
||||
LOCATION = 1,
|
||||
EVENT = 2
|
||||
}
|
||||
|
||||
public class SentMailUpdateDto
|
||||
{
|
||||
[StringLength(200, ErrorMessage = "标题长度不能超过200个字符")]
|
||||
|
||||
Reference in New Issue
Block a user