using TodoTask = TodoList.Core.Entities.Task;
using TodoList.Core.Entities;

namespace TodoList.Core.Interfaces;

/// <summary>
/// 任务服务接口，定义任务业务逻辑操作
/// </summary>
public interface ITaskService
{
    /// <summary>
    /// 获取所有任务
    /// </summary>
    /// <returns>任务列表</returns>
    System.Threading.Tasks.Task<List<TodoTask>> GetAllTasksAsync();
    
    /// <summary>
    /// 根据ID获取指定任务
    /// </summary>
    /// <param name="id">任务ID</param>
    /// <returns>任务对象，如果不存在则返回null</returns>
    System.Threading.Tasks.Task<TodoTask?> GetTaskByIdAsync(int id);
    
    /// <summary>
    /// 获取所有未完成的任务
    /// </summary>
    /// <returns>未完成任务列表</returns>
    System.Threading.Tasks.Task<List<TodoTask>> GetActiveTasksAsync();
    
    /// <summary>
    /// 获取所有已完成的任务
    /// </summary>
    /// <returns>已完成任务列表</returns>
    System.Threading.Tasks.Task<List<TodoTask>> GetCompletedTasksAsync();
    
    /// <summary>
    /// 创建新任务
    /// </summary>
    /// <param name="title">任务标题</param>
    /// <param name="priority">任务优先级</param>
    /// <param name="parentTaskId">父任务ID（可选）</param>
    /// <returns>创建的任务对象</returns>
    System.Threading.Tasks.Task<TodoTask> CreateTaskAsync(string title, TaskPriority priority, int? parentTaskId = null);
    
    /// <summary>
    /// 更新任务
    /// </summary>
    /// <param name="id">任务ID</param>
    /// <param name="title">新的任务标题（可选）</param>
    /// <param name="priority">新的任务优先级（可选）</param>
    /// <returns>更新后的任务对象</returns>
    System.Threading.Tasks.Task<TodoTask> UpdateTaskAsync(int id, string? title = null, TaskPriority? priority = null);
    
    /// <summary>
    /// 切换任务的完成状态
    /// </summary>
    /// <param name="id">任务ID</param>
    /// <returns>更新后的任务对象</returns>
    System.Threading.Tasks.Task<TodoTask> ToggleCompleteAsync(int id);
    
    /// <summary>
    /// 删除指定ID的任务
    /// </summary>
    /// <param name="id">任务ID</param>
    System.Threading.Tasks.Task DeleteTaskAsync(int id);
    
    /// <summary>
    /// 获取指定父任务的所有子任务
    /// </summary>
    /// <param name="parentTaskId">父任务ID</param>
    /// <returns>子任务列表</returns>
    System.Threading.Tasks.Task<List<TodoTask>> GetSubTasksAsync(int parentTaskId);
}
