package net.shyshkin.study.fullstack.supportportal.backend.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
// import org.springframework.data.rest.core.annotation.RepositoryRestResource;

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


import net.shyshkin.study.fullstack.supportportal.backend.domain.Professor;

// @RepositoryRestResource(collectionResourceRel = "professors", path = "professors")
public interface ProfessorRepository extends JpaRepository<Professor, Long> {

    @Query("SELECT p FROM Professor p WHERE p.email = :email")
    Optional<Professor> findByEmail(@Param("email") String email);

    @Query("SELECT CASE WHEN COUNT(p) > 0 THEN TRUE ELSE FALSE END FROM Professor p WHERE p.email = :email")
    Boolean existsByEmail(@Param("email") String email);

    Boolean existsByProfessorId(UUID professorId);

    @Query("SELECT p FROM Professor p WHERE p.professorId = :professorId")
    Optional<Professor> findByProfessorId(@Param("professorId") UUID professorId);
}
