<?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.jeeplus.business.drive.mapper.DriveAccountMapper">
    <select id="findByApplyId" resultType="com.jeeplus.business.drive.service.dto.DriveAccountDTO">
        select
            id,
            start_mileage,
            end_mileage,
            mileage_count,
            apply_id,
            proc_ins_id,
            process_definition_id,
            status
        from jy_drive_account where apply_id=#{applyId}
    </select>

    <update id="updateStatusByApplyId">
        update jy_drive_account set status=#{status} where apply_id = #{applyId}
    </update>

    <update id="updateInfoById">
        UPDATE
            jy_drive_account
        SET
            <if test="null != driveAccount.updateById and driveAccount.updateById != '' ">
                  update_by_id =#{driveAccount.updateById},
            </if>
            <if test="null != driveAccount.updateTime">
                  update_time = #{driveAccount.updateTime},
            </if>
            <if test="null != driveAccount.startMileage and driveAccount.startMileage != '' ">
                  start_mileage = #{driveAccount.startMileage},
            </if>
            <if test="null != driveAccount.endMileage and driveAccount.endMileage != '' ">
                  end_mileage = #{driveAccount.endMileage},
            </if>
            <if test="null != driveAccount.mileageCount and driveAccount.mileageCount != '' ">
                  mileage_count = #{driveAccount.mileageCount}
            </if>
        WHERE
            id = #{driveAccount.id}
    </update>
</mapper>