<?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.fs.qw.mapper.QwFriendWelcomeItemMapper">
    
    <resultMap type="QwFriendWelcomeItem" id="QwFriendWelcomeItemResult">
        <result property="id"    column="id"    />
        <result property="friendWelcomeId"    column="friend_welcome_id"    />
        <result property="welcomeText"    column="welcome_text"    />
        <result property="attachments"    column="attachments"    />
        <result property="week"    column="week"    />
        <result property="startTime"    column="start_time"    />
        <result property="endTime"    column="end_time"    />
        <result property="createdTime"    column="created_time"    />
        <result property="updateTieme"    column="update_tieme"    />
    </resultMap>

    <sql id="selectQwFriendWelcomeItemVo">
        select id, friend_welcome_id, welcome_text, attachments, week, start_time, end_time, created_time, update_tieme from qw_friend_welcome_item
    </sql>

    <select id="selectQwFriendWelcomeItemList" parameterType="QwFriendWelcomeItem" resultMap="QwFriendWelcomeItemResult">
        <include refid="selectQwFriendWelcomeItemVo"/>
        <where>  
            <if test="friendWelcomeId != null "> and friend_welcome_id = #{friendWelcomeId}</if>
            <if test="welcomeText != null  and welcomeText != ''"> and welcome_text = #{welcomeText}</if>
            <if test="attachments != null  and attachments != ''"> and attachments = #{attachments}</if>
            <if test="week != null  and week != ''"> and week = #{week}</if>
            <if test="startTime != null "> and start_time = #{startTime}</if>
            <if test="endTime != null "> and end_time = #{endTime}</if>
            <if test="createdTime != null "> and created_time = #{createdTime}</if>
            <if test="updateTieme != null "> and update_tieme = #{updateTieme}</if>
        </where>
    </select>
    
    <select id="selectQwFriendWelcomeItemById" parameterType="Long" resultMap="QwFriendWelcomeItemResult">
        <include refid="selectQwFriendWelcomeItemVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertQwFriendWelcomeItem" parameterType="QwFriendWelcomeItem">
        insert into qw_friend_welcome_item
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="friendWelcomeId != null">friend_welcome_id,</if>
            <if test="welcomeText != null">welcome_text,</if>
            <if test="attachments != null">attachments,</if>
            <if test="week != null">week,</if>
            <if test="startTime != null">start_time,</if>
            <if test="endTime != null">end_time,</if>
            <if test="createdTime != null">created_time,</if>
            <if test="updateTieme != null">update_tieme,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="friendWelcomeId != null">#{friendWelcomeId},</if>
            <if test="welcomeText != null">#{welcomeText},</if>
            <if test="attachments != null">#{attachments},</if>
            <if test="week != null">#{week},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="endTime != null">#{endTime},</if>
            <if test="createdTime != null">#{createdTime},</if>
            <if test="updateTieme != null">#{updateTieme},</if>
         </trim>
    </insert>

    <update id="updateQwFriendWelcomeItem" parameterType="QwFriendWelcomeItem">
        update qw_friend_welcome_item
        <trim prefix="SET" suffixOverrides=",">
            <if test="friendWelcomeId != null">friend_welcome_id = #{friendWelcomeId},</if>
            <if test="welcomeText != null">welcome_text = #{welcomeText},</if>
            <if test="attachments != null">attachments = #{attachments},</if>
            <if test="week != null">week = #{week},</if>
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="endTime != null">end_time = #{endTime},</if>
            <if test="createdTime != null">created_time = #{createdTime},</if>
            <if test="updateTieme != null">update_tieme = #{updateTieme},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteQwFriendWelcomeItemById" parameterType="Long">
        delete from qw_friend_welcome_item where id = #{id}
    </delete>

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