<?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.enterprise.mapper.RuleMapper">
    <insert id="insertFault">
        INSERT INTO `vehicle-basic`.`rule` ( `message_id`, `car_id`, `c_id`, `t_id`, `rule_value`)
        VALUES ( #{messageId}, #{carId}, #{cId}, #{tId}, #{ruleValue})

    </insert>

    <update id="updateFault">
        UPDATE `rule`
        SET `message_id`=#{messageId},
            `car_id` = #{carId},
            `c_id` = #{cId},
            `t_id` = #{tId},
            `rule_value` = #{ruleValue}
        WHERE `id` = #{id};

    </update>
    <select id="pageQueryRule" resultType="com.muyu.domain.vo.RuleVo">
        SELECT
            rule.id,
            rule.car_id,
            rule.c_id,
            rule.t_id,
            rule.message_id,
            rule_value,
            custom_name AS customName,
            type_name AS typeName,
            car.car_name AS carName,
            message_value.message_label AS messageLabel
        FROM
            rule
                LEFT JOIN custom ON rule.c_id = custom.c_id
                LEFT JOIN type ON rule.t_id = type.t_id
                LEFT JOIN car ON rule.car_id = car.car_id
                LEFT JOIN message_value ON rule.message_id = message_value.message_id
    </select>
    <select id="pageQueryList" resultType="com.muyu.domain.Custom">
        select * from custom
    </select>
    <select id="pageQueryCar" resultType="com.muyu.domain.Vehicle">
        select * from vehicle
    </select>
    <select id="pageQueryType" resultType="com.muyu.domain.Type">
        select * from type
    </select>
    <select id="pageQueryMessageValue" resultType="com.muyu.domain.MessageValue">
        select * from message_value
    </select>

</mapper>
