using TakeoutSaaS.Domain.Identity.Entities;

namespace TakeoutSaaS.Domain.Identity.Repositories;

/// <summary>
/// 角色-权限关系仓储。
/// </summary>
public interface IRolePermissionRepository
{
    /// <summary>
    /// 根据角色 ID 集合获取角色权限关系。
    /// </summary>
    /// <param name="tenantId">租户 ID。</param>
    /// <param name="roleIds">角色 ID 集合。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>角色权限关系列表。</returns>
    Task<IReadOnlyList<RolePermission>> GetByRoleIdsAsync(long tenantId, IEnumerable<long> roleIds, CancellationToken cancellationToken = default);

    /// <summary>
    /// 批量新增角色权限关系。
    /// </summary>
    /// <param name="rolePermissions">角色权限集合。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>异步操作任务。</returns>
    Task AddRangeAsync(IEnumerable<RolePermission> rolePermissions, CancellationToken cancellationToken = default);

    /// <summary>
    /// 替换角色的权限集合。
    /// </summary>
    /// <param name="tenantId">租户 ID。</param>
    /// <param name="roleId">角色 ID。</param>
    /// <param name="permissionIds">权限 ID 集合。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>异步操作任务。</returns>
    Task ReplaceRolePermissionsAsync(long tenantId, long roleId, IEnumerable<long> permissionIds, CancellationToken cancellationToken = default);

    /// <summary>
    /// 提交持久化变更。
    /// </summary>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>异步操作任务。</returns>
    Task SaveChangesAsync(CancellationToken cancellationToken = default);
}
