using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using NPP.SmartSchedue.Api.Contracts.Core.Enums;
using ZhonTai.Admin.Core.Repositories;

namespace NPP.SmartSchedue.Api.Contracts.Domain.Notification;

/// <summary>
/// 通知历史记录仓储接口
/// </summary>
public interface INotificationHistoryRepository : IRepositoryBase<NotificationHistoryEntity>
{
    /// <summary>
    /// 根据通知设置ID获取历史记录列表
    /// </summary>
    Task<List<NotificationHistoryEntity>> GetByNotificationSettingIdAsync(long notificationSettingId);

    /// <summary>
    /// 根据接收人员ID获取历史记录列表
    /// </summary>
    Task<List<NotificationHistoryEntity>> GetByRecipientPersonnelIdAsync(long recipientPersonnelId);

    /// <summary>
    /// 根据发送状态获取历史记录列表
    /// </summary>
    Task<List<NotificationHistoryEntity>> GetBySendStatusAsync(NotificationStatusEnum sendStatus);

    /// <summary>
    /// 根据通知方式获取历史记录列表
    /// </summary>
    Task<List<NotificationHistoryEntity>> GetByNotificationTypeAsync(NotificationTypeEnum notificationType);

    /// <summary>
    /// 根据业务类型和业务ID获取历史记录列表
    /// </summary>
    Task<List<NotificationHistoryEntity>> GetByBusinessAsync(string businessType, long? businessId = null);

    /// <summary>
    /// 获取需要重试的失败通知列表
    /// </summary>
    Task<List<NotificationHistoryEntity>> GetFailedNotificationsForRetryAsync(int? maxRetryCount = null);

    /// <summary>
    /// 获取指定时间范围内的通知统计信息
    /// </summary>
    Task<Dictionary<string, int>> GetNotificationStatisticsAsync(
        DateTime startTime,
        DateTime endTime,
        long? notificationSettingId = null);

    /// <summary>
    /// 根据日期范围获取历史记录列表
    /// </summary>
    Task<List<NotificationHistoryEntity>> GetByDateRangeAsync(DateTime startDate, DateTime endDate);

    /// <summary>
    /// 更新通知发送状态
    /// </summary>
    Task UpdateSendStatusAsync(long id, NotificationStatusEnum sendStatus, string sendResult = "", string errorMessage = "");

    /// <summary>
    /// 批量更新通知发送状态
    /// </summary>
    Task BatchUpdateSendStatusAsync(List<(long Id, NotificationStatusEnum Status, string Result, string Error)> updates);
}