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

    <resultMap type="cn.iocoder.yudao.module.jx.domain.DriveSchoolCar" id="DriveSchoolCarResult">
        <result property="id"    column="id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="brand"    column="brand"    />
        <result property="carModel"    column="car_model"    />
        <result property="carNo"    column="car_no"    />
        <result property="carPhoto"    column="car_photo"    />
        <result property="carRegisterDate"    column="car_register_date"    />
        <result property="inspectionDate"    column="inspection_date"    />
        <result property="userName"    column="user_name"    />
        <result property="userPhone"    column="user_phone"    />
        <result property="carBlong"    column="car_blong"    />
        <result property="drivingLicence"    column="driving_licence"    />
        <result property="operationCertificate"    column="operation_certificate"    />
        <result property="outlineDate"    column="outline_date"    />
        <result property="repairDate"    column="repair_date"    />
        <result property="createTime"    column="create_time"    />
        <result property="creator"    column="creator"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updater"    column="updater"    />
        <result property="baoxianSttime"    column="baoxian_sttime"    />
        <result property="baoxianEntime"    column="baoxian_entime"    />
        <result property="company"    column="company"    />
        <result property="content"    column="content"    />
    </resultMap>

    <sql id="selectDriveSchoolCarVo">
        select * from drive_school_car
    </sql>

    <select id="selectDriveSchoolCarList" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolCar" resultMap="DriveSchoolCarResult">
        <include refid="selectDriveSchoolCarVo"/>
        <where>
            deleted = 0
            <if test="entity.deptId != null "> and dept_id = #{entity.deptId}</if>
            <if test="entity.brand != null  and entity.brand != ''"> and brand = #{entity.brand}</if>
            <if test="entity.carModel != null  and entity.carModel != ''"> and car_model = #{entity.carModel}</if>
            <if test="entity.carNo != null  and entity.carNo != ''"> and car_no = #{entity.carNo}</if>
            <if test="entity.carPhoto != null  and vcarPhoto != ''"> and car_photo = #{entity.carPhoto}</if>
            <if test="entity.carRegisterDate != null "> and car_register_date = #{entity.carRegisterDate}</if>
            <if test="entity.inspectionDate != null "> and inspection_date = #{entity.inspectionDate}</if>
            <if test="entity.userName != null  and entity.userName != ''"> and user_name like concat('%', #{entity.userName}, '%')</if>
            <if test="entity.userPhone != null  and entity.userPhone != ''"> and user_phone = #{entity.userPhone}</if>
            <if test="entity.carBlong != null  and entity.carBlong != ''"> and car_blong = #{entity.carBlong}</if>
            <if test="entity.drivingLicence != null  and entity.drivingLicence != ''"> and driving_licence = #{entity.drivingLicence}</if>
            <if test="entity.operationCertificate != null  and entity.operationCertificate != ''"> and operation_certificate = #{entity.operationCertificate}</if>
            <if test="entity.outlineDate != null "> and outline_date = #{entity.outlineDate}</if>
            <if test="entity.repairDate != null "> and repair_date = #{entity.repairDate}</if>
        </where>
        order by create_time desc
    </select>

    <select id="selectDriveSchoolCarListAll" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolCar" resultMap="DriveSchoolCarResult">
        <include refid="selectDriveSchoolCarVo"/>
        <where>
            deleted = 0
            <if test="entity.deptId != null "> and dept_id = #{entity.deptId}</if>
            <if test="entity.brand != null  and entity.brand != ''"> and brand = #{entity.brand}</if>
            <if test="entity.carModel != null  and entity.carModel != ''"> and car_model = #{entity.carModel}</if>
            <if test="entity.carNo != null  and entity.carNo != ''"> and car_no = #{entity.carNo}</if>
            <if test="entity.carPhoto != null  and vcarPhoto != ''"> and car_photo = #{entity.carPhoto}</if>
            <if test="entity.carRegisterDate != null "> and car_register_date = #{entity.carRegisterDate}</if>
            <if test="entity.inspectionDate != null "> and inspection_date = #{entity.inspectionDate}</if>
            <if test="entity.userName != null  and entity.userName != ''"> and user_name like concat('%', #{entity.userName}, '%')</if>
            <if test="entity.userPhone != null  and entity.userPhone != ''"> and user_phone = #{entity.userPhone}</if>
            <if test="entity.carBlong != null  and entity.carBlong != ''"> and car_blong = #{entity.carBlong}</if>
            <if test="entity.drivingLicence != null  and entity.drivingLicence != ''"> and driving_licence = #{entity.drivingLicence}</if>
            <if test="entity.operationCertificate != null  and entity.operationCertificate != ''"> and operation_certificate = #{entity.operationCertificate}</if>
            <if test="entity.outlineDate != null "> and outline_date = #{entity.outlineDate}</if>
            <if test="entity.repairDate != null "> and repair_date = #{entity.repairDate}</if>
        </where>
        order by create_time desc
    </select>

    <select id="selectDriveSchoolCarById" parameterType="Long" resultMap="DriveSchoolCarResult">
        <include refid="selectDriveSchoolCarVo"/>
        where id = #{id}
    </select>

    <insert id="insertDriveSchoolCar" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolCar" useGeneratedKeys="true" keyProperty="id">
        insert into drive_school_car
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="deptId != null">dept_id,</if>
            <if test="brand != null and brand != ''">brand,</if>
            <if test="carModel != null and carModel != ''">car_model,</if>
            <if test="carNo != null and carNo != ''">car_no,</if>
            <if test="carPhoto != null and carPhoto != ''">car_photo,</if>
            <if test="carRegisterDate != null">car_register_date,</if>
            <if test="inspectionDate != null">inspection_date,</if>
            <if test="userName != null and userName != ''">user_name,</if>
            <if test="userPhone != null and userPhone != ''">user_phone,</if>
            <if test="carBlong != null and carBlong != ''">car_blong,</if>
            <if test="drivingLicence != null and drivingLicence != ''">driving_licence,</if>
            <if test="operationCertificate != null and operationCertificate != ''">operation_certificate,</if>
            <if test="outlineDate != null">outline_date,</if>
            <if test="repairDate != null">repair_date,</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="baoxianSttime != null">baoxian_sttime,</if>
            <if test="baoxianEntime != null">baoxian_entime,</if>
            <if test="company != null">company,</if>
            <if test="content != null">content,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="deptId != null">#{deptId},</if>
            <if test="brand != null and brand != ''">#{brand},</if>
            <if test="carModel != null and carModel != ''">#{carModel},</if>
            <if test="carNo != null and carNo != ''">#{carNo},</if>
            <if test="carPhoto != null and carPhoto != ''">#{carPhoto},</if>
            <if test="carRegisterDate != null">#{carRegisterDate},</if>
            <if test="inspectionDate != null">#{inspectionDate},</if>
            <if test="userName != null and userName != ''">#{userName},</if>
            <if test="userPhone != null and userPhone != ''">#{userPhone},</if>
            <if test="carBlong != null and carBlong != ''">#{carBlong},</if>
            <if test="drivingLicence != null and drivingLicence != ''">#{drivingLicence},</if>
            <if test="operationCertificate != null and operationCertificate != ''">#{operationCertificate},</if>
            <if test="outlineDate != null">#{outlineDate},</if>
            <if test="repairDate != null">#{repairDate},</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="baoxianSttime != null">#{baoxianSttime},</if>
            <if test="baoxianEntime != null">#{baoxianEntime},</if>
            <if test="company != null">#{company},</if>
            <if test="content != null">#{content},</if>
         </trim>
    </insert>

    <update id="updateDriveSchoolCar" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolCar">
        update drive_school_car
        <trim prefix="SET" suffixOverrides=",">
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="brand != null and brand != ''">brand = #{brand},</if>
            <if test="carModel != null and carModel != ''">car_model = #{carModel},</if>
            <if test="carNo != null and carNo != ''">car_no = #{carNo},</if>
            <if test="carPhoto != null and carPhoto != ''">car_photo = #{carPhoto},</if>
            <if test="carRegisterDate != null">car_register_date = #{carRegisterDate},</if>
            <if test="inspectionDate != null">inspection_date = #{inspectionDate},</if>
            <if test="userName != null and userName != ''">user_name = #{userName},</if>
            <if test="userPhone != null and userPhone != ''">user_phone = #{userPhone},</if>
            <if test="carBlong != null and carBlong != ''">car_blong = #{carBlong},</if>
            <if test="drivingLicence != null and drivingLicence != ''">driving_licence = #{drivingLicence},</if>
            <if test="operationCertificate != null and operationCertificate != ''">operation_certificate = #{operationCertificate},</if>
            <if test="outlineDate != null">outline_date = #{outlineDate},</if>
            <if test="repairDate != null">repair_date = #{repairDate},</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="baoxianSttime != null">baoxian_sttime = #{baoxianSttime},</if>
            <if test="baoxianEntime != null">baoxian_entime = #{baoxianEntime},</if>
            <if test="company != null">company = #{company},</if>
            <if test="content != null">content = #{content},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteDriveSchoolCarById" parameterType="Long">
        delete from drive_school_car where id = #{id}
    </delete>

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

    <select id="selectByCarNo" parameterType="String" resultMap="DriveSchoolCarResult">
        <include refid="selectDriveSchoolCarVo"/>
        where deleted = 0 and car_no = #{carNo}
    </select>


</mapper>
