<?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.weighbridge.mapper.DibangDriverMapper">
    
    <resultMap type="DibangDriver" id="DibangDriverResult">
        <result property="driverId"    column="driver_id"    />
        <result property="driverName"    column="driver_name"    />
        <result property="mobile"    column="mobile"    />
        <result property="possWord"    column="poss_word"    />
        <result property="driverType"    column="driver_type"    />
        <result property="plateNo"    column="plate_no"    />
        <result property="createTime"    column="create_time"    />
        <result property="modifyTime"    column="modify_time"    />
    </resultMap>

    <sql id="selectDibangDriverVo">
        select driver_id, driver_name, mobile, poss_word, driver_type, plate_no, create_time, modify_time from dibang_driver
    </sql>

    <select id="selectDibangDriverList" parameterType="DibangDriver" resultMap="DibangDriverResult">
        <include refid="selectDibangDriverVo"/>
        <where>  
            <if test="driverId != null  and driverId != ''"> and driver_id = #{driverId}</if>
            <if test="driverName != null  and driverName != ''"> and driver_name like concat('%', #{driverName}, '%')</if>
            <if test="mobile != null  and mobile != ''"> and mobile = #{mobile}</if>
            <if test="possWord != null  and possWord != ''"> and poss_word = #{possWord}</if>
            <if test="driverType != null  and driverType != ''"> and driver_type = #{driverType}</if>
            <if test="plateNo != null  and plateNo != ''"> and plate_no = #{plateNo}</if>
            <if test="createTime != null "> and create_time = #{createTime}</if>
            <if test="modifyTime != null "> and modify_time = #{modifyTime}</if>
        </where>
    </select>
    
    <select id="selectDibangDriverByDriverId" parameterType="String" resultMap="DibangDriverResult">
        <include refid="selectDibangDriverVo"/>
        where driver_id = #{driverId}
    </select>

    <select id="selectDibangDriverByPlateNo" parameterType="String" resultMap="DibangDriverResult">
        <include refid="selectDibangDriverVo"/>
        where  plate_no = #{plateNo}
    </select>
        
    <insert id="insertDibangDriver" parameterType="DibangDriver">
        insert into dibang_driver
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="driverId != null">driver_id,</if>
            <if test="driverName != null">driver_name,</if>
            <if test="mobile != null">mobile,</if>
            <if test="possWord != null">poss_word,</if>
            <if test="driverType != null">driver_type,</if>
            <if test="plateNo != null">plate_no,</if>
            <if test="createTime != null">create_time,</if>
            <if test="modifyTime != null">modify_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="driverId != null">#{driverId},</if>
            <if test="driverName != null">#{driverName},</if>
            <if test="mobile != null">#{mobile},</if>
            <if test="possWord != null">#{possWord},</if>
            <if test="driverType != null">#{driverType},</if>
            <if test="plateNo != null">#{plateNo},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="modifyTime != null">#{modifyTime},</if>
         </trim>
    </insert>

    <update id="updateDibangDriver" parameterType="DibangDriver">
        update dibang_driver
        <trim prefix="SET" suffixOverrides=",">
            <if test="driverName != null">driver_name = #{driverName},</if>
            <if test="mobile != null">mobile = #{mobile},</if>
            <if test="possWord != null">poss_word = #{possWord},</if>
            <if test="driverType != null">driver_type = #{driverType},</if>
            <if test="plateNo != null">plate_no = #{plateNo},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="modifyTime != null">modify_time = #{modifyTime},</if>
        </trim>
        where driver_id = #{driverId}
    </update>

    <delete id="deleteDibangDriverByDriverId" parameterType="String">
        delete from dibang_driver where driver_id = #{driverId}
    </delete>

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