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

    <resultMap type="cn.iocoder.yudao.module.jx.domain.DriveSchoolUpkeep" id="DriveSchoolUpkeepResult">
        <result property="id"    column="id"    />
        <result property="carId"    column="car_id"    />
        <result property="maintenanceDate"    column="maintenance_date"    />
        <result property="maintenanceMileage"    column="maintenance_mileage"    />
        <result property="inspectionDate"    column="inspection_date"    />
        <result property="insuranceDate"    column="insurance_date"    />
        <result property="nextMaintenanceDate"    column="next_maintenance_date"    />
        <result property="nextMaintenanceMileage"    column="next_maintenance_mileage"    />
        <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="selectDriveSchoolUpkeepVo">
        select id, car_id, maintenance_date, maintenance_mileage, inspection_date, insurance_date, next_maintenance_date, next_maintenance_mileage, create_time, creator, update_time, updater from drive_school_upkeep
    </sql>

    <select id="selectDriveSchoolUpkeepList" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolUpkeep" resultMap="DriveSchoolUpkeepResult">
        <include refid="selectDriveSchoolUpkeepVo"/>
        <where>
            deleted = 0
            <if test="entity.carId != null "> and car_id = #{entity.carId}</if>
            <if test="entity.maintenanceDate != null "> and maintenance_date = #{entity.maintenanceDate}</if>
            <if test="entity.maintenanceMileage != null "> and maintenance_mileage = #{entity.maintenanceMileage}</if>
            <if test="entity.inspectionDate != null "> and inspection_date = #{entity.inspectionDate}</if>
            <if test="entity.insuranceDate != null "> and insurance_date = #{entity.insuranceDate}</if>
            <if test="entity.nextMaintenanceDate != null "> and next_maintenance_date = #{entity.nextMaintenanceDate}</if>
            <if test="entity.nextMaintenanceMileage != null "> and next_maintenance_mileage = #{entity.nextMaintenanceMileage}</if>
        </where>
    </select>

    <select id="selectDriveSchoolUpkeepById" parameterType="Long" resultMap="DriveSchoolUpkeepResult">
        <include refid="selectDriveSchoolUpkeepVo"/>
        where id = #{id}
    </select>

    <insert id="insertDriveSchoolUpkeep" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolUpkeep" useGeneratedKeys="true" keyProperty="id">
        insert into drive_school_upkeep
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="carId != null">car_id,</if>
            <if test="maintenanceDate != null">maintenance_date,</if>
            <if test="maintenanceMileage != null">maintenance_mileage,</if>
            <if test="inspectionDate != null">inspection_date,</if>
            <if test="insuranceDate != null">insurance_date,</if>
            <if test="nextMaintenanceDate != null">next_maintenance_date,</if>
            <if test="nextMaintenanceMileage != null">next_maintenance_mileage,</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="carId != null">#{carId},</if>
            <if test="maintenanceDate != null">#{maintenanceDate},</if>
            <if test="maintenanceMileage != null">#{maintenanceMileage},</if>
            <if test="inspectionDate != null">#{inspectionDate},</if>
            <if test="insuranceDate != null">#{insuranceDate},</if>
            <if test="nextMaintenanceDate != null">#{nextMaintenanceDate},</if>
            <if test="nextMaintenanceMileage != null">#{nextMaintenanceMileage},</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="updateDriveSchoolUpkeep" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolUpkeep">
        update drive_school_upkeep
        <trim prefix="SET" suffixOverrides=",">
            <if test="carId != null">car_id = #{carId},</if>
            <if test="maintenanceDate != null">maintenance_date = #{maintenanceDate},</if>
            <if test="maintenanceMileage != null">maintenance_mileage = #{maintenanceMileage},</if>
            <if test="inspectionDate != null">inspection_date = #{inspectionDate},</if>
            <if test="insuranceDate != null">insurance_date = #{insuranceDate},</if>
            <if test="nextMaintenanceDate != null">next_maintenance_date = #{nextMaintenanceDate},</if>
            <if test="nextMaintenanceMileage != null">next_maintenance_mileage = #{nextMaintenanceMileage},</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="deleteDriveSchoolUpkeepById" parameterType="Long">
        delete from drive_school_upkeep where id = #{id}
    </delete>

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