<?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.srs.stureg.mapper.SrsMsgQueueMapper">
    
    <resultMap type="SrsMsgQueue" id="SrsMsgQueueResult">
        <result property="id"    column="id"    />
        <result property="XH"    column="XH"    />
        <result property="phone"    column="phone"    />
        <result property="content"    column="content"    />
        <result property="status"    column="status"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectSrsMsgQueueVo">
        select id, XH, phone, content, status, create_time, create_by, update_time, update_by, del_flag from srs_msg_queue
    </sql>

    <select id="selectSrsMsgQueueList" parameterType="SrsMsgQueue" resultMap="SrsMsgQueueResult">
        <include refid="selectSrsMsgQueueVo"/>
        <where>  
            <if test="XH != null  and XH != ''"> and XH = #{XH}</if>
            <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>
    
    <select id="selectSrsMsgQueueById" parameterType="Long" resultMap="SrsMsgQueueResult">
        <include refid="selectSrsMsgQueueVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSrsMsgQueue" parameterType="SrsMsgQueue" useGeneratedKeys="true" keyProperty="id">
        insert into srs_msg_queue
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="XH != null">XH,</if>
            <if test="phone != null">phone,</if>
            <if test="content != null">content,</if>
            <if test="status != null">status,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="delFlag != null">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="XH != null">#{XH},</if>
            <if test="phone != null">#{phone},</if>
            <if test="content != null">#{content},</if>
            <if test="status != null">#{status},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="delFlag != null">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updateSrsMsgQueue" parameterType="SrsMsgQueue">
        update srs_msg_queue
        <trim prefix="SET" suffixOverrides=",">
            <if test="XH != null">XH = #{XH},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="content != null">content = #{content},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSrsMsgQueueById" parameterType="Long">
        delete from srs_msg_queue where id = #{id}
    </delete>

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