using SIGCM2.Application.Common;
using SIGCM2.Domain.Entities;

namespace SIGCM2.Application.Abstractions.Persistence;

public interface IUsuarioRepository
{
    Task<Usuario?> GetByUsernameAsync(string username);
    Task<Usuario?> GetByIdAsync(int id, CancellationToken ct = default);
    Task<bool> ExistsByUsernameAsync(string username, CancellationToken ct = default);
    Task<int> AddAsync(Usuario usuario, CancellationToken ct = default);

    // UDT-008
    Task UpdateUltimoLoginAsync(int id, DateTime utcNow, CancellationToken ct = default);
    Task<PagedResult<UsuarioListItem>> GetPagedAsync(UsuariosQuery query, CancellationToken ct = default);
    Task<Usuario?> GetDetailAsync(int id, CancellationToken ct = default);
    Task UpdateAsync(int id, UpdateUsuarioFields fields, DateTime fechaModificacion, CancellationToken ct = default);
    Task UpdatePasswordAsync(int id, string passwordHash, bool mustChangePassword, CancellationToken ct = default);
    Task<int> CountActiveAdminsAsync(CancellationToken ct = default);

    // UDT-009
    Task UpdatePermisosJsonAsync(int id, string permisosJson, DateTime fechaModificacion, CancellationToken ct = default);
}
