using AutoMapper;
using DMS.Core.Interfaces.Repositories;
using DMS.Core.Models;
using DMS.Infrastructure.Data;
using Microsoft.Extensions.Logging;

namespace DMS.Infrastructure.Repositories
{
    /// <summary>
    /// 报警历史记录仓库实现
    /// </summary>
    public class AlarmHistoryRepository : BaseRepository<AlarmHistory>, IAlarmHistoryRepository
    {
        public AlarmHistoryRepository(SqlSugarDbContext dbContext,ILogger<AlarmHistoryRepository> logger) : base(dbContext,logger)
        {
        }
        
        // 可以添加特定于报警历史记录的查询方法的实现
        // 例如：
        // public async Task<IEnumerable<AlarmHistory>> GetUnacknowledgedAlarmsAsync()
        // {
        //     return await _db.Queryable<AlarmHistory>()
        //         .Where(a => !a.IsAcknowledged)
        //         .ToListAsync();
        // }
        
        /// <summary>
        /// 异步删除单个报警历史记录。
        /// </summary>
        /// <param name="entity">要删除的报警历史实体。</param>
        /// <returns>受影响的行数。</returns>
        public async Task<int> DeleteAsync(AlarmHistory entity)
        {
            return await base.DeleteAsync(new List<AlarmHistory> { entity });
        }
        
        /// <summary>
        /// 异步根据实体列表批量删除报警历史记录。
        /// </summary>
        /// <param name="entities">要删除的报警历史实体列表。</param>
        /// <returns>受影响的行数。</returns>
        public async Task<int> DeleteAsync(List<AlarmHistory> entities)
        {
            return await base.DeleteAsync(entities);
        }
    }
}