package com.yihu.jw.area.dao;

import com.yihu.jw.entity.base.area.BaseTownDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * 区县字典 数据库访问层
 *
 * @version <pre>
 *          Author	Version		Date		Changes
 *          litaohong 	1.0  		2018年08月31日 	Created
 *
 *          </pre>
 * @since 1.
 */
public interface BaseTownDao extends PagingAndSortingRepository<BaseTownDO, Integer>, JpaSpecificationExecutor<BaseTownDO> {

    @Query("select name from BaseTownDO where code =:code")
    String getNameByCode(@Param("code") String code);


    @Query("select p from BaseTownDO p where p.code = ?1")
    BaseTownDO findByCode(String code);


    @Query("select a from BaseTownDO a where a.city = ?1 order by id")
    List<BaseTownDO> findByCityCode(String city);
}