<?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.TextMessageLogMapper">
    
    <resultMap type="TextMessageLog" id="TextMessageLogResult">
        <result property="id"    column="id"    />
        <result property="nickName"    column="nick_name"    />
        <result property="phoneNum"    column="phone_num"    />
        <result property="content"    column="content"    />
        <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="status"    column="status"    />
    </resultMap>

    <sql id="selectTextMessageLogVo">
        select id, nick_name, phone_num, content, create_by, create_time, update_by, update_time, is_del, status from text_message_log
    </sql>

    <select id="selectTextMessageLogList" parameterType="TextMessageLog" resultMap="TextMessageLogResult">
        <include refid="selectTextMessageLogVo"/>
        <where>  
            <if test="nickName != null  and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>
            <if test="phoneNum != null  and phoneNum != ''"> and phone_num = #{phoneNum}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>
    
    <select id="selectTextMessageLogById" parameterType="Long" resultMap="TextMessageLogResult">
        <include refid="selectTextMessageLogVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTextMessageLog" parameterType="TextMessageLog" useGeneratedKeys="true" keyProperty="id">
        insert into text_message_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="nickName != null">nick_name,</if>
            <if test="phoneNum != null">phone_num,</if>
            <if test="content != null">content,</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="status != null">status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="nickName != null">#{nickName},</if>
            <if test="phoneNum != null">#{phoneNum},</if>
            <if test="content != null">#{content},</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="status != null">#{status},</if>
         </trim>
    </insert>

    <update id="updateTextMessageLog" parameterType="TextMessageLog">
        update text_message_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="nickName != null">nick_name = #{nickName},</if>
            <if test="phoneNum != null">phone_num = #{phoneNum},</if>
            <if test="content != null">content = #{content},</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="status != null">status = #{status},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTextMessageLogById" parameterType="Long">
        delete from text_message_log where id = #{id}
    </delete>

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