<?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.openbusiness.mapper.SysCarMessageMapper">

    <resultMap type="SysCarMessage" id="SysCarMessageResult">
        <result property="id"    column="id"    />
        <result property="modelCode"    column="model_code"    />
        <result property="messageTypeCode"    column="message_type_code"    />
        <result property="messageStartIndex"    column="message_start_index"    />
        <result property="messageEndIndex"    column="message_end_index"    />
    </resultMap>

    <sql id="selectSysCarMessageVo">
        select id, model_code, message_type_code, message_start_index, message_end_index from sys_car_message
    </sql>

    <select id="selectSysCarMessageList" parameterType="SysCarMessage" resultMap="SysCarMessageResult">
        <include refid="selectSysCarMessageVo"/>
        <where>
            <if test="modelCode != null  and modelCode != ''"> and model_code = #{modelCode}</if>
        </where>
    </select>

    <select id="selectSysCarMessageById" parameterType="Long" resultMap="SysCarMessageResult">
        <include refid="selectSysCarMessageVo"/>
        where id = #{id}
    </select>

    <insert id="insertSysCarMessage" parameterType="SysCarMessage" useGeneratedKeys="true" keyProperty="id">
        insert into sys_car_message
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="modelCode != null">model_code,</if>
            <if test="messageTypeCode != null">message_type_code,</if>
            <if test="messageStartIndex != null">message_start_index,</if>
            <if test="messageEndIndex != null">message_end_index,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="modelCode != null">#{modelCode},</if>
            <if test="messageTypeCode != null">#{messageTypeCode},</if>
            <if test="messageStartIndex != null">#{messageStartIndex},</if>
            <if test="messageEndIndex != null">#{messageEndIndex},</if>
         </trim>
    </insert>

    <update id="updateSysCarMessage" parameterType="SysCarMessage">
        update sys_car_message
        <trim prefix="SET" suffixOverrides=",">
            <if test="modelCode != null">model_code = #{modelCode},</if>
            <if test="messageTypeCode != null">message_type_code = #{messageTypeCode},</if>
            <if test="messageStartIndex != null">message_start_index = #{messageStartIndex},</if>
            <if test="messageEndIndex != null">message_end_index = #{messageEndIndex},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysCarMessageById" parameterType="Long">
        delete from sys_car_message where id = #{id}
    </delete>

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