using Model;
using Model.SQLModel;
using SqlSugar;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Service.Interface
{
    /// <summary>
    /// 泛型基础服务接口（返回 Result 封装）
    /// </summary>
    /// <typeparam name="TEntity">实体类型</typeparam>
    public interface IBaseService<TEntity> where TEntity : class, new()
    {
        /// <summary>
        /// 查询全部
        /// </summary>
        /// <returns>返回包含数据的 Result</returns>
        Task<Result<List<TEntity>>> GetAllAsync();

        /// <summary>
        /// 插入单条数据
        /// </summary>
        /// <param name="entity"></param>
        /// <returns>返回操作是否成功的 Result</returns>
        Task<Result<bool>> InsertAsync(TEntity entity);

        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="pageIndex">页码（从1开始）</param>
        /// <param name="pageSize">每页数量</param>
        /// <param name="total">总条数（输出参数）</param>
        /// <returns>返回包含分页数据的 Result</returns>
        Task<Result<List<TEntity>>> GetPagedAsync(int pageIndex, int pageSize, RefAsync<int> total);

        /// <summary>
        /// 分页查询，并根据日期范围进行过滤
        /// </summary>
        /// <param name="pageIndex">页码（从1开始）</param>
        /// <param name="pageSize">每页数量</param>
        /// <param name="total">总条数（输出参数）</param>
        /// <param name="startDate">开始日期</param>
        /// <param name="endDate">结束日期</param>
        /// <returns>返回包含分页数据的 Result</returns>
        Task<Result<List<TEntity>>> GetPagedAsync(int pageIndex, int pageSize, RefAsync<int> total, DateTime? startDate, DateTime? endDate);
    }
}
