37 lines
1.6 KiB
XML
37 lines
1.6 KiB
XML
<?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.cdzy.operations.mapper.EbikeBikeInfoMapper">
|
|
|
|
<resultMap id="EbikeDtoMap" type="com.cdzy.operations.model.dto.EbikeDto">
|
|
<result column="bike_code" property="bikeCode"/>
|
|
<result column="location" property="location" typeHandler="com.cdzy.operations.handler.PGpointTypeHandler"/>
|
|
</resultMap>
|
|
|
|
<select id="selectPolygonGeometry" resultType="com.cdzy.operations.model.entity.EbikeBikeInfo">
|
|
SELECT *
|
|
FROM ebike_bike_info
|
|
WHERE ST_Within(location::geometry, #{polygon}::geometry)
|
|
</select>
|
|
|
|
<!-- 半径查询(带距离排序) -->
|
|
<select id="selectRadiusGeometryWithOrder" resultMap="EbikeDtoMap">
|
|
SELECT
|
|
ebike_bike_info.bike_code,
|
|
ebike_bike_info.location,
|
|
ST_Distance(
|
|
ST_SetSRID(ST_MakePoint(ST_X(location::geometry), ST_Y(location::geometry)), 4326)::geography,
|
|
ST_SetSRID(ST_MakePoint(#{centerPoint.x}, #{centerPoint.y}), 4326)::geography
|
|
) as distance
|
|
FROM ebike_bike_info
|
|
WHERE ST_DWithin(
|
|
ST_SetSRID(ST_MakePoint(ST_X(location::geometry), ST_Y(location::geometry)), 4326)::geography,
|
|
ST_SetSRID(ST_MakePoint(#{centerPoint.x}, #{centerPoint.y}), 4326)::geography,
|
|
#{radius}
|
|
)
|
|
AND ebike_bike_info.status = 1
|
|
ORDER BY distance ASC
|
|
</select>
|
|
</mapper>
|