<?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.system.mapper.TextMessageMapper">
    
    <resultMap type="TextMessage" id="TextMessageResult">
        <result property="id"    column="id"    />
        <result property="accessKeyId"    column="access_key_id"    />
        <result property="accessKeySecret"    column="access_key_secret"    />
        <result property="signName"    column="sign_name"    />
        <result property="templateCode"    column="template_code"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
        <result property="messageOperators"    column="message_operators"    />
    </resultMap>

    <sql id="selectTextMessageVo">
        select id, access_key_id, access_key_secret, sign_name, template_code, create_by, create_time, update_by, update_time, is_del, message_operators from text_message
    </sql>

    <select id="selectTextMessageList" parameterType="TextMessage" resultMap="TextMessageResult">
        <include refid="selectTextMessageVo"/>
        <where>  
            <if test="accessKeyId != null  and accessKeyId != ''"> and access_key_id = #{accessKeyId}</if>
            <if test="accessKeySecret != null  and accessKeySecret != ''"> and access_key_secret = #{accessKeySecret}</if>
            <if test="signName != null  and signName != ''"> and sign_name like concat('%', #{signName}, '%')</if>
            <if test="templateCode != null  and templateCode != ''"> and template_code = #{templateCode}</if>
            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
            <if test="messageOperators != null  and messageOperators != ''"> and message_operators = #{messageOperators}</if>
        </where>
    </select>
    
    <select id="selectTextMessageById" parameterType="Long" resultMap="TextMessageResult">
        <include refid="selectTextMessageVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTextMessage" parameterType="TextMessage">
        insert into text_message
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="accessKeyId != null">access_key_id,</if>
            <if test="accessKeySecret != null">access_key_secret,</if>
            <if test="signName != null">sign_name,</if>
            <if test="templateCode != null">template_code,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null">is_del,</if>
            <if test="messageOperators != null">message_operators,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="accessKeyId != null">#{accessKeyId},</if>
            <if test="accessKeySecret != null">#{accessKeySecret},</if>
            <if test="signName != null">#{signName},</if>
            <if test="templateCode != null">#{templateCode},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="messageOperators != null">#{messageOperators},</if>
         </trim>
    </insert>

    <update id="updateTextMessage" parameterType="TextMessage">
        update text_message
        <trim prefix="SET" suffixOverrides=",">
            <if test="accessKeyId != null">access_key_id = #{accessKeyId},</if>
            <if test="accessKeySecret != null">access_key_secret = #{accessKeySecret},</if>
            <if test="signName != null">sign_name = #{signName},</if>
            <if test="templateCode != null">template_code = #{templateCode},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="messageOperators != null">message_operators = #{messageOperators},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTextMessageById" parameterType="Long">
        delete from text_message where id = #{id}
    </delete>

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