<?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.elephant.framework.galaxy.aroad.module.traffic.mapper.TrafficSpotMapper">

	<resultMap id="trafficSpotMap" type="com.elephant.framework.galaxy.aroad.module.traffic.entity.TrafficSpot">
		<id property="rowId" column="row_id"/>
		<result property="spotCode" column="spot_code"/>
		<result property="spotName" column="spot_name"/>
		<result property="roadCode" column="road_code"/>
		<result property="roadName" column="road_name"/>
		<result property="xzqh" column="XZQH"/>
		<result property="spotType" column="spot_type"/>
		<result property="spotm" column="spotM"/>
		<result property="startm" column="startM"/>
		<result property="endm" column="endM"/>
		<result property="length" column="length"/>
		<result property="startName" column="start_name"/>
		<result property="endName" column="end_name"/>
		<result property="techLevel" column="tech_level"/>
		<result property="carRows" column="car_rows"/>
		<result property="faceType" column="face_type"/>
		<result property="width" column="width"/>
		<result property="speed" column="speed"/>
		<result property="landscape" column="landscape"/>
		<result property="stopMonth" column="stop_month"/>
		<result property="year" column="year"/>
		<result column="longitude" property="longitude"/>
		<result column="latitude" property="latitude"/>
	</resultMap>

	<resultMap id="CoordinateDtoMap"
	           type="com.elephant.framework.galaxy.aroad.module.traffic.dto.CoordinateDto">
		<id column="rowId" property="row_id"/>
		<result column="longitude" property="longitude"/>
		<result column="latitude" property="latitude"/>
	</resultMap>

	<select id="getTrafficSpotPage" resultMap="trafficSpotMap">
		select * from v_traffic_spot
		<where>
			<if test="trafficSpot.roadName != null">
				road_name like CONCAT('%',#{trafficSpot.roadName},'%')
				or
				road_code like CONCAT('%',#{trafficSpot.roadName},'%')
			</if>
		</where>
	</select>

	<select id="getCoordinates" resultMap="CoordinateDtoMap">
		select row_id, longitude, latitude
		from `v_traffic_spot`;
	</select>
</mapper>
