using JiShe.CollectBus.Common.Models;
using JiShe.CollectBus.IoTDB.Model;
using JiShe.CollectBus.IoTDB.Options;
using JiShe.CollectBus.IoTDB.Provider;

namespace JiShe.CollectBus.IoTDB.Interface
{
    /// <summary>
    /// IoTDB数据源,数据库能同时存多个时序模型，但数据是完全隔离的，不能跨时序模型查询，通过连接字符串配置
    /// </summary>
    public interface IIoTDbProvider
    {
        ///// <summary>
        ///// 切换 SessionPool
        ///// </summary>
        ///// <param name="useTableSession">是否使用表模型</param>
        //void SwitchSessionPool(bool useTableSession);

        /// <summary>
        /// 插入数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task InsertAsync<T>(T entity) where T : IoTEntity;

        /// <summary>
        /// 批量插入数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entities"></param>
        /// <returns></returns>
        Task BatchInsertAsync<T>(IEnumerable<T> entities) where T : IoTEntity;

        /// <summary>
        /// 批量插入数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="deviceMetadata">设备元数据</param>
        /// <param name="entities"></param>
        /// <returns></returns>
        Task BatchInsertAsync<T>(DeviceMetadata deviceMetadata,IEnumerable<T> entities) where T : IoTEntity;


        /// <summary>
        /// 删除数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="options"></param>
        /// <returns></returns>
        Task<object> DeleteAsync<T>(IoTDBQueryOptions options) where T : IoTEntity;

        /// <summary>
        /// 获取设备元数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        Task<DeviceMetadata> GetMetadata<T>() where T : IoTEntity;

        /// <summary>
        /// 查询数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="options"></param>
        /// <returns></returns>
        Task<BusPagedResult<T>> QueryAsync<T>(IoTDBQueryOptions options) where T : IoTEntity, new();
    }
}
