using TakeoutSaaS.Domain.Identity.Entities;
using TakeoutSaaS.Domain.Identity.Enums;

namespace TakeoutSaaS.Domain.Identity.Repositories;

/// <summary>
/// 菜单仓储。
/// </summary>
public interface IMenuRepository
{
    /// <summary>
    /// 按 Portal 获取菜单列表。
    /// </summary>
    /// <param name="portal">Portal 类型。</param>
    /// <param name="cancellationToken">取消标记。</param>
    Task<IReadOnlyList<MenuDefinition>> GetByPortalAsync(PortalType portal, CancellationToken cancellationToken = default);

    /// <summary>
    /// 根据 ID 查询菜单。
    /// </summary>
    /// <param name="id">菜单 ID。</param>
    /// <param name="portal">Portal 类型。</param>
    /// <param name="cancellationToken">取消标记。</param>
    Task<MenuDefinition?> FindByIdAsync(long id, PortalType portal, CancellationToken cancellationToken = default);

    /// <summary>
    /// 新增菜单。
    /// </summary>
    Task AddAsync(MenuDefinition menu, CancellationToken cancellationToken = default);

    /// <summary>
    /// 更新菜单。
    /// </summary>
    Task UpdateAsync(MenuDefinition menu, CancellationToken cancellationToken = default);

    /// <summary>
    /// 删除菜单。
    /// </summary>
    /// <param name="id">菜单 ID。</param>
    /// <param name="portal">Portal 类型。</param>
    /// <param name="cancellationToken">取消标记。</param>
    Task DeleteAsync(long id, PortalType portal, CancellationToken cancellationToken = default);

    /// <summary>
    /// 持久化变更。
    /// </summary>
    Task SaveChangesAsync(CancellationToken cancellationToken = default);
}
