package de.effigenix.infrastructure.usermanagement.persistence.repository;

import de.effigenix.domain.usermanagement.RoleName;
import de.effigenix.infrastructure.usermanagement.persistence.entity.RoleEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.Optional;

/**
 * Spring Data JPA Repository for RoleEntity.
 * Infrastructure Layer - automatically provides CRUD operations.
 *
 * Spring Data generates implementations at runtime based on method names.
 */
@Repository
public interface RoleJpaRepository extends JpaRepository<RoleEntity, String> {

    /**
     * Finds a role by its name.
     */
    Optional<RoleEntity> findByName(RoleName name);

    /**
     * Checks if a role with the given name exists.
     */
    boolean existsByName(RoleName name);
}
