using JiShe.CollectBus.IotSystems.LogRecord;
using JiShe.CollectBus.IotSystems.MeterReadingRecords;
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;

namespace JiShe.CollectBus.Repository.LogRecord
{
    public interface ILogRecordRepository : IRepository<LogRecords, Guid>
    {
        /// <summary>
        /// 批量插入
        /// </summary>
        /// <param name="entities"></param>
        /// <param name="dateTime"></param>
        /// <returns></returns>
        Task InsertManyAsync(List<LogRecords> entities,
            DateTime? dateTime);

        /// <summary>
        /// 单个插入
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="dateTime"></param>
        /// <returns></returns>
        Task<LogRecords> InsertAsync(LogRecords entity, DateTime? dateTime);

        /// <summary>
        /// 单条更新
        /// </summary>
        /// <param name="filter">过滤条件，示例：Builders<LogRecords>.Filter.Eq(x => x.Id, filter.Id)</param>
        /// <param name="update">包含待更新的内容，示例：Builders<LogRecords>.Update.Set(x => x.SendHexMessage, SendHexMessage).Set(x => x.MessageId, MessageId)</param>
        /// <param name="entity">数据实体，用于获取对应的分片库</param>
        /// <returns></returns>
        Task<LogRecords> UpdateOneAsync(FilterDefinition<LogRecords> filter, UpdateDefinition<LogRecords> update, LogRecords entity);

        /// <summary>
        /// 单个获取
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="dateTime"></param>
        /// <returns></returns>
        Task<LogRecords> FirOrDefaultAsync(LogRecords entity, DateTime dateTime);

        /// <summary>
        /// 多集合数据查询
        /// </summary>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        Task<List<LogRecords>> ParallelQueryAsync(DateTime startTime, DateTime endTime);
    }
}
