using TakeoutSaaS.Domain.Tenants.Entities;
using TakeoutSaaS.Domain.Tenants.Enums;

namespace TakeoutSaaS.Domain.Tenants.Repositories;

/// <summary>
/// 租户通知仓储。
/// </summary>
public interface ITenantNotificationRepository
{
    /// <summary>
    /// 查询通知列表，按等级、未读状态与时间范围筛选。
    /// </summary>
    /// <param name="tenantId">租户 ID。</param>
    /// <param name="severity">通知等级。</param>
    /// <param name="unreadOnly">仅返回未读。</param>
    /// <param name="from">开始时间（UTC）。</param>
    /// <param name="to">结束时间（UTC）。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>通知集合。</returns>
    Task<IReadOnlyList<TenantNotification>> SearchAsync(
        long tenantId,
        TenantNotificationSeverity? severity,
        bool? unreadOnly,
        DateTime? from,
        DateTime? to,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 按 ID 获取通知。
    /// </summary>
    /// <param name="tenantId">租户 ID。</param>
    /// <param name="notificationId">通知 ID。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>通知实体或 null。</returns>
    Task<TenantNotification?> FindByIdAsync(long tenantId, long notificationId, CancellationToken cancellationToken = default);

    /// <summary>
    /// 新增通知。
    /// </summary>
    /// <param name="notification">通知实体。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>异步任务。</returns>
    Task AddAsync(TenantNotification notification, CancellationToken cancellationToken = default);

    /// <summary>
    /// 更新通知。
    /// </summary>
    /// <param name="notification">通知实体。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>异步任务。</returns>
    Task UpdateAsync(TenantNotification notification, CancellationToken cancellationToken = default);

    /// <summary>
    /// 保存变更。
    /// </summary>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>异步任务。</returns>
    Task SaveChangesAsync(CancellationToken cancellationToken = default);
}
