using TodoTask = TodoList.Core.Entities.Task;

namespace TodoList.Core.Interfaces;

/// <summary>
/// 任务仓储接口，定义任务数据访问操作
/// </summary>
public interface ITaskRepository
{
    /// <summary>
    /// 获取所有任务
    /// </summary>
    /// <returns>任务列表</returns>
    System.Threading.Tasks.Task<List<TodoTask>> GetAllAsync();
    
    /// <summary>
    /// 根据ID获取指定任务
    /// </summary>
    /// <param name="id">任务ID</param>
    /// <returns>任务对象，如果不存在则返回null</returns>
    System.Threading.Tasks.Task<TodoTask?> GetByIdAsync(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="task">要添加的任务对象</param>
    /// <returns>添加后的任务对象（包含生成的ID）</returns>
    System.Threading.Tasks.Task<TodoTask> AddAsync(TodoTask task);
    
    /// <summary>
    /// 更新任务
    /// </summary>
    /// <param name="task">要更新的任务对象</param>
    /// <returns>更新后的任务对象</returns>
    System.Threading.Tasks.Task<TodoTask> UpdateAsync(TodoTask task);
    
    /// <summary>
    /// 删除指定ID的任务
    /// </summary>
    /// <param name="id">任务ID</param>
    System.Threading.Tasks.Task DeleteAsync(int id);
    
    /// <summary>
    /// 获取指定父任务的所有子任务
    /// </summary>
    /// <param name="parentTaskId">父任务ID</param>
    /// <returns>子任务列表</returns>
    System.Threading.Tasks.Task<List<TodoTask>> GetSubTasksAsync(int parentTaskId);
}
