package com.tykj.dev.device.user.subject.dao;

import com.tykj.dev.device.user.subject.entity.Area;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zjm
 * @version 1.0.0
 * @ClassName AreaDao.java
 * @Description TODO
 * @createTime 2020年07月28日 10:01:00
 */
@Repository
public interface AreaDao extends JpaRepository<Area, Integer>, JpaSpecificationExecutor<Area> {
    List<Area> findAllByFatherId(Integer areaId);

    List<Area> findByFatherId(Integer areaId);

    List<Area> findAreasByType(Integer type);

    @Query("select o.name from Area o where o.id=?1")
    String findNameById(int id);

}
