package com.magistr.app.repository;

import com.magistr.app.model.ScheduleRuleSlot;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface ScheduleRuleSlotRepository extends JpaRepository<ScheduleRuleSlot, Long> {

    @Query("select case when count(slot) > 0 then true else false end from ScheduleRuleSlot slot join slot.subgroups subgroup where subgroup.id = :subgroupId")
    boolean existsBySubgroupId(@Param("subgroupId") Long subgroupId);

    boolean existsByTimeSlotId(Long timeSlotId);
}
