<?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.DriveSchoolCheckMapper">

    <resultMap type="cn.iocoder.yudao.module.jx.domain.DriveSchoolCheck" id="DriveSchoolCheckResult">
        <result property="id"    column="id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="userId"    column="user_id"    />
        <result property="userName"    column="user_name"    />
        <result property="manager"    column="manager"    />
        <result property="coach"    column="coach"    />
        <result property="phone"    column="phone"    />
        <result property="carId"    column="car_id"    />
        <result property="carNo"    column="car_no"    />
        <result property="problem"    column="problem"    />
        <result property="content"    column="content"    />
        <result property="money"    column="money"    />
        <result property="createTime"    column="create_time"    />
        <result property="creator"    column="creator"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updater"    column="updater"    />
        <result property="checkTime"    column="checkTime"    />
    </resultMap>

    <sql id="selectDriveSchoolCheckVo">
        select id, dept_id, user_id,coach,manager, checkTime,user_name, phone, car_id, car_no, problem, content, money, create_time, creator, update_time, updater from drive_school_check
    </sql>

    <select id="selectDriveSchoolCheckList" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolCheck" resultMap="DriveSchoolCheckResult">
        <include refid="selectDriveSchoolCheckVo"/>
        <where>
            deleted = 0
            <if test="entity.deptId != null "> and dept_id = #{entity.deptId}</if>
            <if test="entity.userId != null "> and user_id = #{entity.userId}</if>
            <if test="entity.userName != null  and entity.userName != ''"> and user_name like concat('%', #{entity.userName}, '%')</if>
            <if test="entity.phone != null  and entity.phone != ''"> and phone = #{entity.phone}</if>
            <if test="entity.carId != null "> and car_id = #{entity.carId}</if>
            <if test="entity.carNo != null  and entity.carNo != ''"> and car_no like concat('%',#{entity.carNo},'%') </if>
            <if test="entity.problem != null  and entity.problem != ''"> and problem = #{entity.problem}</if>
            <if test="entity.content != null  and entity.content != ''"> and content = #{entity.content}</if>
            <if test="entity.money != null "> and money = #{entity.money}</if>
        </where>
        order by create_time desc
    </select>

    <select id="selectDriveSchoolCheckById" parameterType="Long" resultMap="DriveSchoolCheckResult">
        <include refid="selectDriveSchoolCheckVo"/>
        where id = #{id}
    </select>

    <insert id="insertDriveSchoolCheck" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolCheck" useGeneratedKeys="true" keyProperty="id">
        insert into drive_school_check
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="deptId != null">dept_id,</if>
            <if test="userId != null">user_id,</if>
            <if test="userName != null and userName != ''">user_name,</if>
            <if test="coach != null and coach != ''">coach,</if>
            <if test="manager != null and manager != ''">manager,</if>
            <if test="phone != null and phone != ''">phone,</if>
            <if test="carId != null">car_id,</if>
            <if test="carNo != null and carNo != ''">car_no,</if>
            <if test="problem != null and problem != ''">problem,</if>
            <if test="content != null and content != ''">content,</if>
            <if test="money != null">money,</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>
            <if test="checkTime != null">checkTime,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="deptId != null">#{deptId},</if>
            <if test="userId != null">#{userId},</if>
            <if test="userName != null and userName != ''">#{userName},</if>
            <if test="coach != null and coach != ''">#{coach},</if>
            <if test="manager != null and manager != ''">#{manager},</if>
            <if test="phone != null and phone != ''">#{phone},</if>
            <if test="carId != null">#{carId},</if>
            <if test="carNo != null and carNo != ''">#{carNo},</if>
            <if test="problem != null and problem != ''">#{problem},</if>
            <if test="content != null and content != ''">#{content},</if>
            <if test="money != null">#{money},</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>
            <if test="checkTime != null">#{checkTime},</if>
         </trim>
    </insert>

    <update id="updateDriveSchoolCheck" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolCheck">
        update drive_school_check
        <trim prefix="SET" suffixOverrides=",">
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="userName != null and userName != ''">user_name = #{userName},</if>
            <if test="coach != null and coach != ''">coach = #{coach},</if>
            <if test="manager != null and manager != ''">manager = #{manager},</if>
            <if test="phone != null and phone != ''">phone = #{phone},</if>
            <if test="carId != null">car_id = #{carId},</if>
            <if test="carNo != null and carNo != ''">car_no = #{carNo},</if>
            <if test="problem != null and problem != ''">problem = #{problem},</if>
            <if test="content != null and content != ''">content = #{content},</if>
            <if test="money != null">money = #{money},</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>
            <if test="checkTime != null">checkTime = #{checkTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteDriveSchoolCheckById" parameterType="Long">
        delete from drive_school_check where id = #{id}
    </delete>

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