<?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.car.mapper.SysMessageTypeMapper">

    <resultMap type="SysMessageType" id="SysMessageTypeResult">
        <result property="id"    column="id"    />
        <result property="messageCode"    column="message_code"    />
        <result property="messageName"    column="message_name"    />
        <result property="messageType"    column="message_type"    />
    </resultMap>

    <sql id="selectSysMessageTypeVo">
        select id, message_code, message_name, message_type from sys_message_type
    </sql>

    <select id="selectSysMessageTypeList" parameterType="SysMessageType" resultMap="SysMessageTypeResult">
        <include refid="selectSysMessageTypeVo"/>
        <where>
            <if test="messageName != null  and messageName != ''"> and message_name like concat('%', #{messageName}, '%')</if>
            <if test="messageType != null  and messageType != ''"> and message_type = #{messageType}</if>
        </where>
    </select>

    <select id="selectSysMessageTypeById" parameterType="Long" resultMap="SysMessageTypeResult">
        <include refid="selectSysMessageTypeVo"/>
        where id = #{id}
    </select>

    <insert id="insertSysMessageType" parameterType="SysMessageType" useGeneratedKeys="true" keyProperty="id">
        insert into sys_message_type
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="messageCode != null">message_code,</if>
            <if test="messageName != null">message_name,</if>
            <if test="messageType != null">message_type,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="messageCode != null">#{messageCode},</if>
            <if test="messageName != null">#{messageName},</if>
            <if test="messageType != null">#{messageType},</if>
         </trim>
    </insert>

    <update id="updateSysMessageType" parameterType="SysMessageType">
        update sys_message_type
        <trim prefix="SET" suffixOverrides=",">
            <if test="messageCode != null">message_code = #{messageCode},</if>
            <if test="messageName != null">message_name = #{messageName},</if>
            <if test="messageType != null">message_type = #{messageType},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysMessageTypeById" parameterType="Long">
        delete from sys_message_type where id = #{id}
    </delete>

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