using TakeoutSaaS.Domain.Tenants.Entities;

namespace TakeoutSaaS.Domain.Tenants.Repositories;

/// <summary>
/// 租户可见角色规则仓储。
/// </summary>
public interface ITenantVisibilityRoleRuleRepository
{
    /// <summary>
    /// 按租户获取规则。
    /// </summary>
    /// <param name="tenantId">租户 ID。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>规则实体，未配置时返回 null。</returns>
    Task<TenantVisibilityRoleRule?> FindByTenantIdAsync(long tenantId, CancellationToken cancellationToken = default);

    /// <summary>
    /// 新增规则。
    /// </summary>
    /// <param name="rule">规则实体。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>异步任务。</returns>
    Task AddAsync(TenantVisibilityRoleRule rule, CancellationToken cancellationToken = default);

    /// <summary>
    /// 更新规则。
    /// </summary>
    /// <param name="rule">规则实体。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>异步任务。</returns>
    Task UpdateAsync(TenantVisibilityRoleRule rule, CancellationToken cancellationToken = default);

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