<?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.yeejoin.amos.boot.module.common.api.mapper.FireStationMapper">


    <select id="getStationList" resultType="com.yeejoin.amos.boot.module.common.api.dto.FireStationzhDto">

    SELECT
    a.sequence_nbr sequenceNbr,
    a.person_charge_name personChargeName,
    a.longitude,
    a.name,
    a.latitude,
    a.person_charge_telephone personChargeTelephone,
    Round(st_distance(point(a.longitude,a.latitude),point(#{par.longitude},#{par.latitude}))*111195,1) AS distance
    FROM cb_fire_station a
    where  a.is_delete=0 and a.longitude is not null and a.latitude   is not null
    <if test='par.distance!=null'>
        Round(st_distance(point(a.longitude,a.latitude),point(#{par.longitude},#{par.latitude}))*111195,1) &lt;= #{par.distance}
    </if>
        ORDER BY  distance   limit #{pageNum},#{pageSize}
    </select>

    <select id="getStationListCount" resultType="Integer">
    SELECT
    COUNT(a.sequence_nbr) num
    FROM cb_fire_station a
    where  a.is_delete=0 and a.longitude is not null and a.latitude   is not null
    <if test='par.distance!=null'>
        Round(st_distance(point(a.longitude,a.latitude),point(#{par.longitude},#{par.latitude}))*111195,1) &lt;= #{par.distance}
    </if>
    </select>



</mapper>
