<?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.cool.store.mapper.MdmAreaMapper">

    <!-- 获取 MDM 省级地区数据 -->
    <select id="getProvince" resultType="com.cool.store.entity.MDMAreaDO">
        SELECT id, instance_id, code, area_name, parent_code
            FROM mdm_area
            WHERE parent_code = '0'
    </select>

    <!-- 获取子级区域 -->
    <select id="getSonArea" resultType="com.cool.store.entity.MDMAreaDO">
        SELECT id, instance_id, code, area_name, parent_code
            FROM mdm_area
            WHERE parent_code = #{code}
    </select>
    <select id="getProvinceAllCode"  resultType="com.cool.store.entity.MDMAreaDO">
        SELECT  b.* FROM `mdm_area` a  inner join  mdm_area b    on a.`code`=b.`parent_code`
        WHERE a.`parent_code`=#{code}   ORDER BY  b.id desc
    </select>
    <select id="getArea" resultType="com.cool.store.entity.MDMAreaDO">
        SELECT id, instance_id, code, area_name, parent_code
        FROM mdm_area
        WHERE `code` = #{code}
    </select>
</mapper>