using TodoList.Core.Entities;
using System.Text.Json.Serialization;

namespace TodoList.Api.Models;

/// <summary>
/// 创建任务的数据传输对象
/// </summary>
public class CreateTaskDto
{
    /// <summary>
    /// 任务标题
    /// </summary>
    public string Title { get; set; } = string.Empty;
    
    /// <summary>
    /// 任务优先级
    /// </summary>
    [JsonConverter(typeof(JsonStringEnumConverter))]
    public TaskPriority Priority { get; set; } = TaskPriority.Medium;
    
    /// <summary>
    /// 父任务ID（可选）
    /// </summary>
    public int? ParentTaskId { get; set; }
}

/// <summary>
/// 更新任务的数据传输对象
/// </summary>
public class UpdateTaskDto
{
    /// <summary>
    /// 新的任务标题（可选）
    /// </summary>
    public string? Title { get; set; }
    
    /// <summary>
    /// 新的任务优先级（可选）
    /// </summary>
    [JsonConverter(typeof(JsonStringEnumConverter))]
    public TaskPriority? Priority { get; set; }
}

/// <summary>
/// 任务数据传输对象
/// </summary>
public class TaskDto
{
    /// <summary>
    /// 任务ID
    /// </summary>
    public int Id { get; set; }
    
    /// <summary>
    /// 任务标题
    /// </summary>
    public string Title { get; set; } = string.Empty;
    
    /// <summary>
    /// 任务优先级
    /// </summary>
    [JsonConverter(typeof(JsonStringEnumConverter))]
    public TaskPriority Priority { get; set; }
    
    /// <summary>
    /// 任务是否已完成
    /// </summary>
    public bool IsCompleted { get; set; }
    
    /// <summary>
    /// 任务创建时间
    /// </summary>
    public DateTime CreatedAt { get; set; }
    
    /// <summary>
    /// 任务最后更新时间
    /// </summary>
    public DateTime UpdatedAt { get; set; }
    
    /// <summary>
    /// 父任务ID
    /// </summary>
    public int? ParentTaskId { get; set; }
    
    /// <summary>
    /// 子任务列表
    /// </summary>
    public List<TaskDto> SubTasks { get; set; } = new();
}

/// <summary>
/// API统一响应格式
/// </summary>
/// <typeparam name="T">响应数据类型</typeparam>
public class ApiResponse<T>
{
    /// <summary>
    /// 请求是否成功
    /// </summary>
    public bool Success { get; set; }
    
    /// <summary>
    /// 响应数据
    /// </summary>
    public T? Data { get; set; }
    
    /// <summary>
    /// 响应消息
    /// </summary>
    public string Message { get; set; } = string.Empty;
    
    /// <summary>
    /// 错误信息列表
    /// </summary>
    public List<string> Errors { get; set; } = new();
}
