using TakeoutSaaS.Domain.Tenants.Entities;

namespace TakeoutSaaS.Domain.Tenants.Repositories;

/// <summary>
/// 运营操作日志仓储。
/// </summary>
public interface IOperationLogRepository
{
    /// <summary>
    /// 分页查询指定操作人的操作日志。
    /// </summary>
    /// <param name="tenantId">租户 ID。</param>
    /// <param name="operatorId">操作人标识。</param>
    /// <param name="from">开始时间（UTC）。</param>
    /// <param name="to">结束时间（UTC）。</param>
    /// <param name="page">页码（从 1 开始）。</param>
    /// <param name="pageSize">每页条数。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>分页结果（数据与总数）。</returns>
    Task<(IReadOnlyList<OperationLog> Items, int Total)> SearchByOperatorPagedAsync(
        long tenantId,
        string operatorId,
        DateTime from,
        DateTime to,
        int page,
        int pageSize,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 新增操作日志。
    /// </summary>
    /// <param name="log">操作日志。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>异步任务。</returns>
    Task AddAsync(OperationLog log, CancellationToken cancellationToken = default);

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