package com.cirle.scientific.dao;

import com.cirle.scientific.po.SysRegion;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface RegionDao extends PagingAndSortingRepository<SysRegion, Long>, JpaSpecificationExecutor<SysRegion> {

    @Query(value = "select * from sys_region where  parent_id  = ?1 order  by id desc ",nativeQuery = true)
    List<SysRegion> findByParentId(Integer pid);

    @Query(value = "select name from sys_region where  id  = ?1",nativeQuery = true)
    String findNameById(Integer id);

    @Query(value = "select id from sys_region where  name  = ?1",nativeQuery = true)
    Integer findIdByName(String name);
}
