<?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="cn.iocoder.yudao.module.rescue.mapper.DriverInfoMapper">
    

    <sql id="selectDriverInfoVo">
        select id, user_id, phonenumber, license_image, id_card_right, id_card_back, auth_status, reject_info, driver_status, driver_longitude, driver_latitude, driver_position_info, driver_offline_time from driver_info
    </sql>

    <select id="selectDriverInfoList" parameterType="cn.iocoder.yudao.module.rescue.domain.DriverInfo" resultType="cn.iocoder.yudao.module.rescue.domain.DriverInfo">
        <include refid="selectDriverInfoVo"/>
        <where>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="phonenumber != null "> and phonenumber = #{phonenumber}</if>
            <if test="licenseImage != null  and licenseImage != ''"> and license_image = #{licenseImage}</if>
            <if test="idCardRight != null  and idCardRight != ''"> and id_card_right = #{idCardRight}</if>
            <if test="idCardBack != null  and idCardBack != ''"> and id_card_back = #{idCardBack}</if>
            <if test="authStatus != null  and authStatus != ''"> and auth_status = #{authStatus}</if>
            <if test="rejectInfo != null  and rejectInfo != ''"> and reject_info = #{rejectInfo}</if>
            <if test="driverStatus != null  and driverStatus != ''"> and driver_status = #{driverStatus}</if>
            <if test="driverLongitude != null "> and driver_longitude = #{driverLongitude}</if>
            <if test="driverLatitude != null "> and driver_latitude = #{driverLatitude}</if>
            <if test="driverPositionInfo != null  and driverPositionInfo != ''"> and driver_position_info = #{driverPositionInfo}</if>
            <if test="driverOfflineTime != null "> and driver_offline_time = #{driverOfflineTime}</if>
            ${params.dataScope}
        </where>
    </select>

    <select id="selectDriverInfoById" parameterType="java.lang.Long" resultType="cn.iocoder.yudao.module.rescue.domain.DriverInfo">
        <include refid="selectDriverInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertDriverInfo" parameterType="cn.iocoder.yudao.module.rescue.domain.DriverInfo">
        insert into driver_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="userId != null">user_id,</if>
            <if test="phonenumber != null">phonenumber,</if>
            <if test="licenseImage != null">license_image,</if>
            <if test="idCardRight != null">id_card_right,</if>
            <if test="idCardBack != null">id_card_back,</if>
            <if test="authStatus != null">auth_status,</if>
            <if test="rejectInfo != null">reject_info,</if>
            <if test="driverStatus != null">driver_status,</if>
            <if test="driverLongitude != null">driver_longitude,</if>
            <if test="driverLatitude != null">driver_latitude,</if>
            <if test="driverPositionInfo != null">driver_position_info,</if>
            <if test="driverOfflineTime != null">driver_offline_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="userId != null">#{userId},</if>
            <if test="phonenumber != null">#{phonenumber},</if>
            <if test="licenseImage != null">#{licenseImage},</if>
            <if test="idCardRight != null">#{idCardRight},</if>
            <if test="idCardBack != null">#{idCardBack},</if>
            <if test="authStatus != null">#{authStatus},</if>
            <if test="rejectInfo != null">#{rejectInfo},</if>
            <if test="driverStatus != null">#{driverStatus},</if>
            <if test="driverLongitude != null">#{driverLongitude},</if>
            <if test="driverLatitude != null">#{driverLatitude},</if>
            <if test="driverPositionInfo != null">#{driverPositionInfo},</if>
            <if test="driverOfflineTime != null">#{driverOfflineTime},</if>
        </trim>
    </insert>

    <update id="updateDriverInfo" parameterType="cn.iocoder.yudao.module.rescue.domain.DriverInfo">
        update driver_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="phonenumber != null">phonenumber = #{phonenumber},</if>
            <if test="licenseImage != null">license_image = #{licenseImage},</if>
            <if test="idCardRight != null">id_card_right = #{idCardRight},</if>
            <if test="idCardBack != null">id_card_back = #{idCardBack},</if>
            <if test="authStatus != null">auth_status = #{authStatus},</if>
            <if test="rejectInfo != null">reject_info = #{rejectInfo},</if>
            <if test="driverStatus != null">driver_status = #{driverStatus},</if>
            <if test="driverLongitude != null">driver_longitude = #{driverLongitude},</if>
            <if test="driverLatitude != null">driver_latitude = #{driverLatitude},</if>
            <if test="driverPositionInfo != null">driver_position_info = #{driverPositionInfo},</if>
            <if test="driverOfflineTime != null">driver_offline_time = #{driverOfflineTime},</if>
            <if test="age != null">age = #{age},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteDriverInfoById" >
        delete from driver_info where id = #{id}
    </delete>

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