<?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.jx.mapper.DriveCarBindMapper">

    <resultMap type="cn.iocoder.yudao.module.jx.domain.DriveCarBind" id="DriveCarBindResult">
        <result property="id"    column="id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="carId"    column="car_id"    />
        <result property="driveSchoolCoachId"    column="drive_school_coach_id"    />
        <result property="userName"    column="user_name"    />
        <result property="driveLicense"    column="drive_license"    />
        <result property="createTime"    column="create_time"    />
        <result property="creator"    column="creator"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updater"    column="updater"    />
    </resultMap>

    <sql id="selectDriveCarBindVo">
        select id, dept_id, car_id, drive_school_coach_id, user_name, drive_license, create_time, creator, update_time, updater from drive_car_bind
    </sql>

    <select id="selectDriveCarBindList" parameterType="cn.iocoder.yudao.module.jx.domain.DriveCarBind" resultMap="DriveCarBindResult">
        <include refid="selectDriveCarBindVo"/>
        <where>
            deleted = 0
            <if test="entity.deptId != null "> and dept_id = #{entity.deptId}</if>
            <if test="entity.carId != null "> and car_id = #{entity.carId}</if>
            <if test="entity.driveSchoolCoachId != null "> and drive_school_coach_id = #{entity.driveSchoolCoachId}</if>
            <if test="entity.userName != null  and entity.userName != ''"> and user_name like concat('%', #{entity.userName}, '%')</if>
            <if test="entity.driveLicense != null  and entity.driveLicense != ''"> and drive_license = #{entity.driveLicense}</if>
        </where>
    </select>

    <select id="selectDriveCarBindById" parameterType="Long" resultMap="DriveCarBindResult">
        <include refid="selectDriveCarBindVo"/>
        where id = #{id}
    </select>

    <insert id="insertDriveCarBind" parameterType="cn.iocoder.yudao.module.jx.domain.DriveCarBind" useGeneratedKeys="true" keyProperty="id">
        insert into drive_car_bind
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="deptId != null">dept_id,</if>
            <if test="carId != null">car_id,</if>
            <if test="driveSchoolCoachId != null">drive_school_coach_id,</if>
            <if test="userName != null">user_name,</if>
            <if test="driveLicense != null">drive_license,</if>
            <if test="createTime != null">create_time,</if>
            <if test="creator != null">creator,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updater != null">updater,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="deptId != null">#{deptId},</if>
            <if test="carId != null">#{carId},</if>
            <if test="driveSchoolCoachId != null">#{driveSchoolCoachId},</if>
            <if test="userName != null">#{userName},</if>
            <if test="driveLicense != null">#{driveLicense},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="creator != null">#{creator},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updater != null">#{updater},</if>
         </trim>
    </insert>

    <update id="updateDriveCarBind" parameterType="cn.iocoder.yudao.module.jx.domain.DriveCarBind">
        update drive_car_bind
        <trim prefix="SET" suffixOverrides=",">
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="carId != null">car_id = #{carId},</if>
            <if test="driveSchoolCoachId != null">drive_school_coach_id = #{driveSchoolCoachId},</if>
            <if test="userName != null">user_name = #{userName},</if>
            <if test="driveLicense != null">drive_license = #{driveLicense},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="creator != null">creator = #{creator},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updater != null">updater = #{updater},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteDriveCarBindById" parameterType="Long">
        delete from drive_car_bind where id = #{id}
    </delete>

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