package com.example.removetolocal.newuser.dao;

import com.example.removetolocal.newuser.domin.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 fatherId);

    List<Area> findAreasByType(Integer type);

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

    List<Area> findAllByTypeInOrderByTypeAsc(List<Integer> types);
}
