using System.ComponentModel.DataAnnotations; using System.Text.Json; using Tiku.Application.Growth; namespace Tiku.Api.Contracts; /// /// 新增或更新CRM配置请求 DTO。 /// public sealed class UpsertCrmConfigDto { /// /// 是否启用。 /// public bool Enabled { get; set; } /// /// 访问地址。 /// [StringLength(2048)] public string? Url { get; set; } /// /// 密钥引用。 /// [StringLength(300)] public string? SecretRef { get; set; } /// /// 密钥内容。 /// public string? Secret { get; set; } /// /// 表单名称。 /// [StringLength(200)] public string? FormName { get; set; } /// /// 考试类型。 /// [StringLength(100)] public string? ExamType { get; set; } /// /// 超时时长,单位为秒。 /// [Range(1, 120)] public int? TimeoutSeconds { get; set; } /// /// 延迟秒数。 /// [Range(0, 86400)] public int? DelaySeconds { get; set; } /// /// 分配模式。 /// [StringLength(50)] public string? AssignmentMode { get; set; } /// /// 分配池。 /// public JsonElement? AssignmentPool { get; set; } /// /// 分配配置。 /// public JsonElement? AssignmentConfig { get; set; } public UpsertCrmConfigCommand ToCommand() { return new UpsertCrmConfigCommand( Enabled, Url, SecretRef, Secret, FormName, ExamType, TimeoutSeconds, DelaySeconds, AssignmentMode, AssignmentPool, AssignmentConfig); } } /// /// CRM队列查询参数。 /// public sealed class CrmQueueQueryDto { /// /// 状态。 /// [StringLength(50)] public string? Status { get; set; } /// /// 队列任务 ID。 /// public Guid? QueueId { get; set; } /// /// 来源。 /// [StringLength(200)] public string? Source { get; set; } /// /// 返回数量上限。 /// [Range(1, 500)] public int? Limit { get; set; } public CrmQueueQuery ToQuery() { return new CrmQueueQuery(Status, QueueId, Source, Limit); } } /// /// CRM队列日志查询参数。 /// public sealed class CrmQueueLogQueryDto { /// /// 队列任务 ID。 /// public Guid? QueueId { get; set; } /// /// 返回数量上限。 /// [Range(1, 200)] public int? Limit { get; set; } public CrmQueueLogQuery ToQuery() { return new CrmQueueLogQuery(QueueId, Limit); } } /// /// CRM队列Action请求 DTO。 /// public sealed class CrmQueueActionDto { /// /// 队列任务 ID。 /// [Required] public Guid QueueId { get; set; } /// /// 操作。 /// [StringLength(50)] public string? Action { get; set; } /// /// 备注。 /// [StringLength(500)] public string? Note { get; set; } /// /// 扩展元数据。 /// public JsonElement? Metadata { get; set; } public CrmQueueActionCommand ToCommand() { return new CrmQueueActionCommand(QueueId, Action, Note, Metadata); } }