<?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.muyu.mapper.FaultLogMapper">
    <resultMap id="FaultCodeLogResult" type="com.muyu.domain.FaultLog">
        <id property="logId" column="log_id"></id>
        <result property="faultcodeId" column="faultcode_id"></result>
        <result property="carInformationId" column="car_information_id"></result>
        <result property="carVin" column="car_vin"></result>
        <result property="startwarningTime" column="startwarning_time"></result>
        <result property="endwarningTime" column="endwarning_time"></result>
        <result property="carInformationVIN" column="car_information_VIN"></result>
        <result property="faultcodeNumber" column="faultcode_number"></result>
    </resultMap>

    <sql id="selectfaultloglist">
        SELECT
            car_fault_log.*,
            car_faultcode.faultcode_number,
            car_information.car_information_VIN
        FROM
            car_fault_log
                LEFT JOIN car_faultcode ON car_fault_log.faultcode_id = car_faultcode.faultcode_id
                LEFT JOIN car_information ON car_fault_log.car_information_id = car_information.car_information_id
    </sql>

    <!--日志列表-->
    <select id="selectfaultLogMapper" resultType="com.muyu.domain.FaultLog">
        <include refid="selectfaultloglist"></include>
        <where>
            <if test="carVin!=null and carVin!=''">
                and car_fault_log.car_vin=#{carVin}
            </if>
            <if test="startwarningTime!=null and startwarningTime!=''">
                and car_fault_log.startwarning_time=#{startwarningTime}
            </if>
            <if test="endwarningTime!=null and endwarningTime!=''">
                and car_fault_log.endwarning_time=#{endwarningTime}
            </if>
        </where>
        limit #{pageNum},#{pageSize}
    </select>
</mapper>
