package cn.palmte.work.model;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface DeptRepository extends JpaRepository<Dept,Integer> {

    Dept findByNameEquals(String name);

    @Query(value = "select * from dept where level = 1", nativeQuery = true)
    List<Dept> findFirstLevelDept();

    @Query(value = "select * from dept where enabled = 1", nativeQuery = true)
    List<Dept> findEnable();

    @Query(value = "select * from dept where enabled = 1 and level <= 2", nativeQuery = true)
    List<Dept> findEnableParent();
}
