<?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.ruoyi.system.mapper.RiderPositionMapper">
    
    <resultMap type="RiderPosition" id="RiderPositionResult">
        <result property="id"    column="id"    />
        <result property="riderId"    column="rider_id"    />
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
        <result property="notes"    column="notes"    />
        <result property="cid"    column="cid"    />
    </resultMap>

    <sql id="selectRiderPositionVo">
        select id, rider_id, longitude, latitude, notes,cid from rider_position
    </sql>

    <select id="selectRiderPositionList" parameterType="RiderPosition" resultMap="RiderPositionResult">
        <include refid="selectRiderPositionVo"/>
        <where>  
            <if test="riderId != null "> and rider_id = #{riderId}</if>
            <if test="longitude != null "> and longitude = #{longitude}</if>
            <if test="latitude != null "> and latitude = #{latitude}</if>
            <if test="notes != null  and notes != ''"> and notes = #{notes}</if>
            <if test="cid != null  and cid != ''"> and cid = #{cid}</if>
        </where>
    </select>
    
    <select id="selectRiderPositionById" parameterType="Long" resultMap="RiderPositionResult">
        <include refid="selectRiderPositionVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertRiderPosition" parameterType="RiderPosition">
        insert into rider_position
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="riderId != null">rider_id,</if>
            <if test="longitude != null">longitude,</if>
            <if test="latitude != null">latitude,</if>
            <if test="notes != null">notes,</if>
            <if test="cid != null">cid,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="riderId != null">#{riderId},</if>
            <if test="longitude != null">#{longitude},</if>
            <if test="latitude != null">#{latitude},</if>
            <if test="notes != null">#{notes},</if>
            <if test="cid != null">#{cid},</if>
         </trim>
    </insert>

    <update id="updateRiderPosition" parameterType="RiderPosition">
        update rider_position
        <trim prefix="SET" suffixOverrides=",">
            <if test="riderId != null">rider_id = #{riderId},</if>
            <if test="longitude != null">longitude = #{longitude},</if>
            <if test="latitude != null">latitude = #{latitude},</if>
            <if test="notes != null">notes = #{notes},</if>
            <if test="cid != null">cid = #{cid},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteRiderPositionById" parameterType="Long">
        delete from rider_position where id = #{id}
    </delete>

    <delete id="deleteRiderPositionByIds" parameterType="String">
        delete from rider_position where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>