<?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.fault.mapper.FaultConditionMapper">
    <resultMap id="FaultConditionResult" type="com.muyu.fault.domain.FaultCondition">
        <id property="carconditionId" column="carcondition_id"></id>
        <result property="carTypeId" column="car_type_id"></result>
        <result property="messageTypeId" column="message_type_id"></result>
        <result property="faultconditionIdentification" column="faultcondition_identification"></result>
        <result property="faultconditionParameter" column="faultcondition_parameter"></result>
        <result property="carTypeName" column="car_type_name"></result>
        <result property="messageTypeName" column="message_type_name"></result>
        <result property="messageTypeCode" column="message_type_code"></result>
    </resultMap>

    <sql id="selectfaultconditionlist" >
        SELECT
            car_fault_condition.*,
            car_type.car_type_name,
            car_fault_label.message_type_name,
            car_fault_label.message_type_code
        FROM
            car_fault_condition
                LEFT JOIN car_type ON car_fault_condition.car_type_id = car_type.car_type_id
                LEFT JOIN car_fault_label ON car_fault_condition.message_type_id = car_fault_label.message_type_id
    </sql>


    <select id="selectfaultconditionlist" resultType="com.muyu.fault.domain.FaultCondition">
        <include refid="selectfaultconditionlist"></include>
        <where>
            <if test="carTypeId!=null and carTypeId!=''">
                and car_type.car_type_id=#{carTypeId}
            </if>
            <if test="messageTypeId!=null and messageTypeId!=''">
                and car_fault_label.message_type_id=#{messageTypeId}
            </if>
        </where>
        limit #{pageNum},#{pageSize}
    </select>

    <select id="selectBytypeAndlabel" resultType="com.muyu.fault.domain.FaultCondition">
        SELECT
        car_fault_condition.*
        FROM
        car_fault_condition
        where
        car_fault_condition.car_type_id=#{carTypeId}
          and car_fault_condition.message_type_id=#{messageTypeId}

    </select>


</mapper>
