using TakeoutSaaS.Domain.Merchants.Entities;

namespace TakeoutSaaS.Domain.Merchants.Repositories;

/// <summary>
/// 商户类目仓储契约。
/// </summary>
public interface IMerchantCategoryRepository
{
    /// <summary>
    /// 列出当前租户的类目。
    /// </summary>
    /// <param name="tenantId">租户 ID。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>类目列表。</returns>
    Task<IReadOnlyList<MerchantCategory>> ListAsync(long tenantId, CancellationToken cancellationToken = default);

    /// <summary>
    /// 是否存在同名类目。
    /// </summary>
    /// <param name="name">类目名称。</param>
    /// <param name="tenantId">租户 ID。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>存在返回 true。</returns>
    Task<bool> ExistsAsync(string name, long tenantId, CancellationToken cancellationToken = default);

    /// <summary>
    /// 查找类目。
    /// </summary>
    /// <param name="id">类目 ID。</param>
    /// <param name="tenantId">租户 ID。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>类目实体或 null。</returns>
    Task<MerchantCategory?> FindByIdAsync(long id, long tenantId, CancellationToken cancellationToken = default);

    /// <summary>
    /// 新增类目。
    /// </summary>
    /// <param name="category">类目实体。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>异步任务。</returns>
    Task AddAsync(MerchantCategory category, CancellationToken cancellationToken = default);

    /// <summary>
    /// 删除类目。
    /// </summary>
    /// <param name="category">类目实体。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>异步任务。</returns>
    Task RemoveAsync(MerchantCategory category, CancellationToken cancellationToken = default);

    /// <summary>
    /// 批量更新类目信息。
    /// </summary>
    /// <param name="categories">类目集合。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>异步任务。</returns>
    Task UpdateRangeAsync(IEnumerable<MerchantCategory> categories, CancellationToken cancellationToken = default);

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