using StorageService.Domain.SeedWork;

namespace StorageService.Domain.AggregatesModel.FileAggregate;

/// <summary>
/// EN: Repository interface for StorageFile aggregate.
/// VI: Interface repository cho StorageFile aggregate.
/// </summary>
public interface IFileRepository : IRepository<StorageFile>
{
    /// <summary>
    /// EN: Add a new file.
    /// VI: Thêm file mới.
    /// </summary>
    Task<StorageFile> AddAsync(StorageFile file, CancellationToken cancellationToken = default);
    
    /// <summary>
    /// EN: Update an existing file.
    /// VI: Cập nhật file.
    /// </summary>
    void Update(StorageFile file);
    
    /// <summary>
    /// EN: Get file by ID.
    /// VI: Lấy file theo ID.
    /// </summary>
    Task<StorageFile?> GetByIdAsync(Guid id, CancellationToken cancellationToken = default);
    
    /// <summary>
    /// EN: Get file by object key.
    /// VI: Lấy file theo object key.
    /// </summary>
    Task<StorageFile?> GetByObjectKeyAsync(string objectKey, CancellationToken cancellationToken = default);
    
    /// <summary>
    /// EN: Get files by user ID.
    /// VI: Lấy files theo user ID.
    /// </summary>
    Task<IEnumerable<StorageFile>> GetByUserIdAsync(
        string userId, 
        int skip = 0, 
        int take = 20,
        CancellationToken cancellationToken = default);
    
    /// <summary>
    /// EN: Get total size of files by user ID.
    /// VI: Lấy tổng kích thước files theo user ID.
    /// </summary>
    Task<long> GetTotalSizeByUserIdAsync(string userId, CancellationToken cancellationToken = default);
    
    /// <summary>
    /// EN: Get file count by user ID.
    /// VI: Lấy số lượng files theo user ID.
    /// </summary>
    Task<int> GetFileCountByUserIdAsync(string userId, CancellationToken cancellationToken = default);
    
    /// <summary>
    /// EN: Search files by name.
    /// VI: Tìm kiếm files theo tên.
    /// </summary>
    Task<IEnumerable<StorageFile>> SearchAsync(
        string userId,
        string? searchTerm,
        int skip = 0,
        int take = 20,
        CancellationToken cancellationToken = default);
}
