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

namespace NPP.SmartSchedue.Api.Contracts.Core.Repositories;

/// <summary>
/// 通知设置仓储接口
/// </summary>
public interface INotificationSettingRepository : IRepositoryBase<NotificationSettingEntity>
{
    /// <summary>
    /// 根据启用状态获取通知设置列表
    /// </summary>
    /// <param name="enabled">是否启用</param>
    /// <returns></returns>
    Task<List<NotificationSettingEntity>> GetByEnabledAsync(bool enabled);

    /// <summary>
    /// 根据人员组ID获取通知设置列表
    /// </summary>
    /// <param name="personnelGroupId">人员组ID</param>
    /// <returns></returns>
    Task<List<NotificationSettingEntity>> GetByPersonnelGroupIdAsync(long personnelGroupId);

    /// <summary>
    /// 根据通知方式获取通知设置列表
    /// </summary>
    /// <param name="notificationType">通知方式</param>
    /// <returns></returns>
    Task<List<NotificationSettingEntity>> GetByNotificationTypeAsync(int notificationType);

    /// <summary>
    /// 根据触发条件获取匹配的通知设置列表
    /// </summary>
    /// <param name="businessType">业务类型</param>
    /// <param name="businessContext">业务上下文数据</param>
    /// <returns></returns>
    Task<List<NotificationSettingEntity>> GetMatchingNotificationSettingsAsync(
        string businessType, 
        Dictionary<string, object> businessContext);

    /// <summary>
    /// 检查通知设置名称是否存在
    /// </summary>
    /// <param name="notificationName">通知名称</param>
    /// <param name="excludeId">排除的ID</param>
    /// <returns></returns>
    Task<bool> ExistsNotificationNameAsync(string notificationName, long? excludeId = null);

    /// <summary>
    /// 获取需要在当前时间执行的通知设置列表
    /// </summary>
    /// <param name="currentTime">当前时间</param>
    /// <returns></returns>
    Task<List<NotificationSettingEntity>> GetActiveNotificationSettingsForTimeAsync(DateTime currentTime);
}