using TakeoutSaaS.Domain.Dictionary.Entities;

namespace TakeoutSaaS.Domain.Dictionary.Repositories;

/// <summary>
/// 租户字典覆盖仓储契约。
/// </summary>
public interface ITenantDictionaryOverrideRepository
{
    /// <summary>
    /// 获取租户覆盖配置。
    /// </summary>
    /// <param name="tenantId">租户 ID。</param>
    /// <param name="systemGroupId">系统字典分组 ID。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>覆盖配置或 null。</returns>
    Task<TenantDictionaryOverride?> GetAsync(long tenantId, long systemGroupId, CancellationToken cancellationToken = default);

    /// <summary>
    /// 获取租户全部覆盖配置。
    /// </summary>
    /// <param name="tenantId">租户 ID。</param>
    /// <param name="cancellationToken">取消标记。</param>
    /// <returns>覆盖配置列表。</returns>
    Task<IReadOnlyList<TenantDictionaryOverride>> ListAsync(long tenantId, CancellationToken cancellationToken = default);

    /// <summary>
    /// 新增覆盖配置。
    /// </summary>
    /// <param name="overrideConfig">覆盖配置。</param>
    /// <param name="cancellationToken">取消标记。</param>
    Task AddAsync(TenantDictionaryOverride overrideConfig, CancellationToken cancellationToken = default);

    /// <summary>
    /// 更新覆盖配置。
    /// </summary>
    /// <param name="overrideConfig">覆盖配置。</param>
    /// <param name="cancellationToken">取消标记。</param>
    Task UpdateAsync(TenantDictionaryOverride overrideConfig, CancellationToken cancellationToken = default);

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