package io.gmss.fiscad.repositories.user;

import io.gmss.fiscad.entities.infocad.parametre.Structure;
import io.gmss.fiscad.entities.user.Role;
import io.gmss.fiscad.entities.user.User;
import io.gmss.fiscad.enums.UserRole;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;
import java.util.Optional;
import java.util.Set;

public interface UserRepository extends JpaRepository<User, Long> {

    Optional<User> findByUsername(String username);

    long countAllByUsernameIsNotNull();

    List<User> findAllByStructureAndRolesIn(Structure structure, Set<Role> roleSet);

    List<User> findAllByStructureAndRolesNotIn(Structure structure, Set<Role> roleSet);

    List<User> findAllByRolesContains(UserRole userRole);
}
