<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.upyuns.platform.rs.universal.mapper.SysRegionMapper">

    <select id="getAllByPage" parameterType="java.util.Map"
            resultType="com.upyuns.platform.rs.universal.entity.SysRegion">
        select `id`, parent_id, `name`, `type`, agency_id from sys_region limit #{pageStart},${pageSize}
    </select>

    <select id="getByIdList" parameterType="java.util.List"
            resultType="com.upyuns.platform.rs.universal.entity.SysRegion">
        select `id`, parent_id, `name`, `type`, agency_id from sys_region where id in
        <foreach collection="list" index="i" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
    </select>

    <select id="getNumber" resultType="Integer">
        select `id` from sys_region  where  name  like  CONCAT('%',#{name},'%') limit 1
    </select>
    <select id="getNumberV2" resultType="Integer">
        select `id` from sys_region  where  name  like  CONCAT('%',#{name},'%') and type=#{type} limit 1
    </select>

    <select id="findByCityName" resultType="com.upyuns.platform.rs.universal.dto.RegionDTO">
        select `id`,`parent_id` as `parentId` from  `sys_region` where `type`=2  and `name` like concat('%',#{city} ,'%')
    </select>
</mapper>