using TakeoutSaaS.Domain.Identity.Entities;

namespace TakeoutSaaS.Domain.Identity.Repositories;

/// <summary>
/// 角色仓储。
/// </summary>
public interface IRoleRepository
{
    /// <summary>
    /// 根据 ID 查询角色。
    /// </summary>
    /// <param name="roleId">角色 ID。</param>
    /// <param name="tenantId">租户 ID。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>角色实体或 null。</returns>
    Task<Role?> FindByIdAsync(long roleId, long tenantId, CancellationToken cancellationToken = default);

    /// <summary>
    /// 根据编码查询角色。
    /// </summary>
    /// <param name="code">角色编码。</param>
    /// <param name="tenantId">租户 ID。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>角色实体或 null。</returns>
    Task<Role?> FindByCodeAsync(string code, long tenantId, CancellationToken cancellationToken = default);

    /// <summary>
    /// 批量获取角色列表。
    /// </summary>
    /// <param name="tenantId">租户 ID。</param>
    /// <param name="roleIds">角色 ID 集合。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>角色集合。</returns>
    Task<IReadOnlyList<Role>> GetByIdsAsync(long tenantId, IEnumerable<long> roleIds, CancellationToken cancellationToken = default);

    /// <summary>
    /// 按关键字搜索角色。
    /// </summary>
    /// <param name="tenantId">租户 ID。</param>
    /// <param name="keyword">关键字。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>角色集合。</returns>
    Task<IReadOnlyList<Role>> SearchAsync(long tenantId, string? keyword, CancellationToken cancellationToken = default);

    /// <summary>
    /// 新增角色。
    /// </summary>
    /// <param name="role">角色实体。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>异步操作任务。</returns>
    Task AddAsync(Role role, CancellationToken cancellationToken = default);

    /// <summary>
    /// 更新角色。
    /// </summary>
    /// <param name="role">角色实体。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>异步操作任务。</returns>
    Task UpdateAsync(Role role, CancellationToken cancellationToken = default);

    /// <summary>
    /// 删除角色。
    /// </summary>
    /// <param name="roleId">角色 ID。</param>
    /// <param name="tenantId">租户 ID。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>异步操作任务。</returns>
    Task DeleteAsync(long roleId, long tenantId, CancellationToken cancellationToken = default);

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