// EN: Shop repository interface.
// VI: Interface repository cho Shop.

using MerchantService.Domain.SeedWork;

namespace MerchantService.Domain.AggregatesModel.ShopAggregate;

/// <summary>
/// EN: Repository interface for Shop aggregate.
/// VI: Interface repository cho Shop aggregate.
/// </summary>
public interface IShopRepository : IRepository<Shop>
{
    /// <summary>
    /// EN: Get shop by ID.
    /// VI: Lấy shop theo ID.
    /// </summary>
    Task<Shop?> GetByIdAsync(Guid id, CancellationToken cancellationToken = default);
    
    /// <summary>
    /// EN: Get shop by ID with branches loaded.
    /// VI: Lấy shop theo ID kèm theo các chi nhánh.
    /// </summary>
    Task<Shop?> GetByIdWithBranchesAsync(Guid id, CancellationToken cancellationToken = default);
    
    /// <summary>
    /// EN: Get shop by slug (URL-friendly identifier).
    /// VI: Lấy shop theo slug (định danh thân thiện URL).
    /// </summary>
    Task<Shop?> GetBySlugAsync(string slug, CancellationToken cancellationToken = default);
    
    /// <summary>
    /// EN: Check if slug is already taken.
    /// VI: Kiểm tra slug đã được sử dụng chưa.
    /// </summary>
    Task<bool> SlugExistsAsync(string slug, CancellationToken cancellationToken = default);
    
    /// <summary>
    /// EN: Get all shops by merchant ID.
    /// VI: Lấy tất cả shops theo merchant ID.
    /// </summary>
    Task<IReadOnlyList<Shop>> GetByMerchantIdAsync(Guid merchantId, CancellationToken cancellationToken = default);
    
    /// <summary>
    /// EN: Get shops by category.
    /// VI: Lấy shops theo ngành nghề.
    /// </summary>
    Task<IReadOnlyList<Shop>> GetByCategoryAsync(BusinessCategory category, int pageNumber, int pageSize, CancellationToken cancellationToken = default);
    
    /// <summary>
    /// EN: Add a new shop.
    /// VI: Thêm shop mới.
    /// </summary>
    Shop Add(Shop shop);
    
    /// <summary>
    /// EN: Update a shop.
    /// VI: Cập nhật shop.
    /// </summary>
    void Update(Shop shop);
    
    /// <summary>
    /// EN: Get all active shops with branches loaded for nearby search.
    /// VI: Lấy tất cả shops active kèm chi nhánh để tìm kiếm gần đây.
    /// </summary>
    Task<IReadOnlyList<Shop>> GetActiveShopsWithBranchesAsync(CancellationToken cancellationToken = default);

    /// <summary>
    /// EN: Get shops by merchant ID with pagination and optional status filter.
    /// VI: Lấy shops theo merchant ID với phân trang và lọc theo trạng thái (tùy chọn).
    /// </summary>
    Task<(IReadOnlyList<Shop> Items, int TotalCount)> GetByMerchantIdPagedAsync(
        Guid merchantId, int? statusId, int pageNumber, int pageSize, CancellationToken cancellationToken = default);

    /// <summary>
    /// EN: Get the default shop for a merchant.
    /// VI: Lấy shop mặc định của merchant.
    /// </summary>
    Task<Shop?> GetDefaultByMerchantIdAsync(Guid merchantId, CancellationToken cancellationToken = default);
}
