<?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.ruoyi.ss.msgLog.mapper.MsgLogMapper">

    <resultMap type="MsgLog" id="EtMsgLogResult">
        <result property="id"    column="id"    />
        <result property="type"    column="type"    />
        <result property="templateCode"    column="templateCode"    />
        <result property="signName"    column="signName"    />
        <result property="content"    column="content"    />
        <result property="createTime"    column="create_time"    />
        <result property="phone"    column="phone"    />
    </resultMap>

    <sql id="selectEtMsgLogVo">
        select id, type, templateCode, signName, content, create_time, phone from ss_msg_log
    </sql>

    <select id="selectEtMsgLogList" parameterType="MsgLog" resultMap="EtMsgLogResult">
        <include refid="selectEtMsgLogVo"/>
        <where>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
        </where>
    </select>

    <select id="selectEtMsgLogById" parameterType="Long" resultMap="EtMsgLogResult">
        <include refid="selectEtMsgLogVo"/>
        where id = #{id}
    </select>

    <insert id="insertEtMsgLog" parameterType="MsgLog" useGeneratedKeys="true" keyProperty="id">
        insert into ss_msg_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="type != null">type,</if>
            <if test="templateCode != null">templateCode,</if>
            <if test="signName != null">signName,</if>
            <if test="content != null">content,</if>
            <if test="createTime != null">create_time,</if>
            <if test="phone != null">phone,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="type != null">#{type},</if>
            <if test="templateCode != null">#{templateCode},</if>
            <if test="signName != null">#{signName},</if>
            <if test="content != null">#{content},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="phone != null">#{phone},</if>
         </trim>
    </insert>

    <update id="updateEtMsgLog" parameterType="MsgLog">
        update ss_msg_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="type != null">type = #{type},</if>
            <if test="templateCode != null">templateCode = #{templateCode},</if>
            <if test="signName != null">signName = #{signName},</if>
            <if test="content != null">content = #{content},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="phone != null">phone = #{phone},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteEtMsgLogById" parameterType="Long">
        delete from ss_msg_log where id = #{id}
    </delete>

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