package br.gov.sigefp.org.repository;

import br.gov.sigefp.org.domain.Position;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;
import java.util.UUID;

@Repository
public interface PositionRepository extends JpaRepository<Position, UUID> {

    Optional<Position> findByCode(String code);

    boolean existsByCode(String code);

    @EntityGraph(attributePaths = { "orgUnit" })
    Page<Position> findAll(Pageable pageable);

    @EntityGraph(attributePaths = { "orgUnit" })
    List<Position> findByOrgUnitId(UUID orgUnitId);
}
