<?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.moral.mapper.MapPathMapper">
|
<resultMap id="resultMap" type="WebProvince">
|
<id property="provinceCode" column="province_code"></id>
|
<result property="provinceName" column="province_name"></result>
|
<collection column="province_code" property="cities" ofType="com.moral.entity.WebCity">
|
<id property="cityCode" column="city_code"></id>
|
<result property="cityName" column="city_name"></result>
|
<result property="provinceCode" column="province_code"></result>
|
<collection property="areas" column="city_code" ofType="com.moral.entity.Area">
|
<id property="areaCode" column="area_code"></id>
|
<result property="areaName" column="area_name"></result>
|
<result property="cityCode" column="city_code"></result>
|
</collection>
|
</collection>
|
</resultMap>
|
|
<sql id="Base_Column_List">
|
p.province_code,p.province_name,c.city_code,c.city_name,c.province_code,a.area_code,a.area_name,a.city_code
|
</sql>
|
|
<select id="getMapPathByRegionCode" resultMap="resultMap">
|
SELECT
|
<include refid="Base_Column_List"/>
|
FROM province p
|
JOIN city c ON c.`province_code` = p.`province_code`
|
JOIN area a ON a.`city_code` = c.`city_code`
|
<choose>
|
<when test="areaCode!=null">
|
AND a.`area_code` = #{areaCode}
|
</when>
|
<when test="cityCode!=null">
|
AND c.`city_code` = #{cityCode}
|
</when>
|
<when test="provinceCode!=null">
|
AND p.`province_code` = #{provinceCode}
|
</when>
|
</choose>
|
</select>
|
</mapper>
|