<?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="org.springblade.modules.yjxt.base.map.mapper.DangerAreaMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="dangerAreaResultMap" type="org.springblade.modules.yjxt.base.map.entity.DangerAreaEntity">

        <result column="danger_area_pid" property="dangerAreaPid"/>
        <result column="danger_area_name" property="dangerAreaName"/>
        <result column="adcd" property="adcd"/>
        <result column="st_code" property="stCode"/>
        <result column="center_point_lng" property="centerPointLng"/>
        <result column="center_point_lat" property="centerPointLat"/>
        <result column="danger_status" property="dangerStatus"/>
    </resultMap>


    <resultMap id="dangerAreaResultVOMap" type="org.springblade.modules.yjxt.base.map.vo.DangerAreaVO">

        <result column="danger_area_pid" property="dangerAreaPid"/>
        <result column="danger_area_name" property="dangerAreaName"/>
        <result column="adcd" property="adcd"/>
        <result column="st_code" property="stCode"/>
        <result column="center_point_lng" property="centerPointLng"/>
        <result column="center_point_lat" property="centerPointLat"/>
        <result column="danger_status" property="dangerStatus"/>
        <result column="adnm" property="adnm"/>
    </resultMap>


    <select id="selectPage" resultMap="dangerAreaResultVOMap">
        SELECT
        d.*,a.adnm
        FROM
        map_danger_area_info d
        LEFT JOIN base_data_ad_cd a ON a.adcd = d.adcd
        WHERE
        d.is_deleted = 0
        <if test="dto.dangerAreaName!=null">
            and d.danger_area_name like concat(concat('%', #{dto.dangerAreaName}), '%')
        </if>
        order by d.adcd
    </select>

    <select id="selectAdDangerArea" resultMap="dangerAreaResultVOMap">
        SELECT
        d.*,a.adnm
        FROM
        map_danger_area_info d
        LEFT JOIN base_data_ad_cd a ON a.adcd = d.adcd
        WHERE
        d.is_deleted = 0
        <if test="dto.adcd!=null">
            and d.adcd = #{dto.adcd}
        </if>
        order by d.adcd
    </select>
</mapper>
