<?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.QwFriendWelcomeMapper">

    <resultMap type="QwFriendWelcome" id="QwFriendWelcomeResult">
        <result property="id"    column="id"    />
        <result property="qwUserIds"    column="qw_user_ids"    />
        <result property="isSendMsg"    column="is_send_msg"    />
        <result property="welcomeText"    column="welcome_text"    />
        <result property="attachments"    column="attachments"    />
        <result property="isDayparting"    column="is_dayparting"    />
        <result property="daypartingItemlist"    column="dayparting_ItemList"    />
        <result property="companyId"    column="company_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="corpId"    column="corp_id"    />
    </resultMap>

    <sql id="selectQwFriendWelcomeVo">
        select id, qw_user_ids,corp_id, is_send_msg, welcome_text, attachments, is_dayparting, dayparting_ItemList, company_id, create_time, update_time,project from qw_friend_welcome
    </sql>

    <select id="selectQwFriendWelcomeListVO" parameterType="QwFriendWelcome" resultMap="QwFriendWelcomeResult">
        <include refid="selectQwFriendWelcomeVo"/>
        <where>
            <if test="qwUserIds != null  and qwUserIds != ''"> and FIND_IN_SET(#{qwUserIds},REPLACE(REPLACE(REPLACE(qw_user_ids, '[', ''), ']', ''), ' ', '')) > 0  </if>
            <if test="isSendMsg != null "> and is_send_msg = #{isSendMsg}</if>
            <if test="welcomeText != null  and welcomeText != ''"> and welcome_text = #{welcomeText}</if>
            <if test="isDayparting != null "> and is_dayparting = #{isDayparting}</if>
            <if test="companyId != null "> and company_id = #{companyId}</if>
            <if test="createTime != null "> and create_time = #{createTime}</if>
            <if test="corpId != null "> and corp_id = #{corpId}</if>
            <if test="updateTime != null "> and update_time = #{updateTime}</if>
            <if test="project != null "> and project = #{project}</if>
        </where>
    </select>

    <select id="selectQwFriendWelcomeById" parameterType="Long" resultMap="QwFriendWelcomeResult">
        <include refid="selectQwFriendWelcomeVo"/>
        where id = #{id}
    </select>

    <insert id="insertQwFriendWelcomeVO" parameterType="QwFriendWelcome" useGeneratedKeys="true" keyProperty="id">
        insert into qw_friend_welcome
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="qwUserIds != null">qw_user_ids,</if>
            <if test="isSendMsg != null">is_send_msg,</if>
            <if test="welcomeText != null">welcome_text,</if>
            <if test="attachments != null">attachments,</if>
            <if test="isDayparting != null">is_dayparting,</if>
            <if test="daypartingItemlist != null">dayparting_ItemList,</if>
            <if test="companyId != null">company_id,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="corpId != null">corp_id,</if>
            <if test="project != null">project,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="qwUserIds != null">#{qwUserIds},</if>
            <if test="isSendMsg != null">#{isSendMsg},</if>
            <if test="welcomeText != null">#{welcomeText},</if>
            <if test="attachments != null">#{attachments},</if>
            <if test="isDayparting != null">#{isDayparting},</if>
            <if test="daypartingItemlist != null">#{daypartingItemlist},</if>
            <if test="companyId != null">#{companyId},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="corpId != null">#{corpId},</if>
            <if test="project != null">#{project},</if>
         </trim>
    </insert>

    <update id="updateQwFriendWelcome" parameterType="QwFriendWelcome">
        update qw_friend_welcome
        <trim prefix="SET" suffixOverrides=",">
            <if test="qwUserIds != null">qw_user_ids = #{qwUserIds},</if>
            <if test="isSendMsg != null">is_send_msg = #{isSendMsg},</if>
            <if test="welcomeText != null">welcome_text = #{welcomeText},</if>
            <if test="attachments != null">attachments = #{attachments},</if>
            <if test="isDayparting != null">is_dayparting = #{isDayparting},</if>
            <if test="daypartingItemlist != null">dayparting_ItemList = #{daypartingItemlist},</if>
            <if test="companyId != null">company_id = #{companyId},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="corpId != null">corp_id = #{corpId},</if>
            <if test="project != null">project = #{project},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteQwFriendWelcomeById" parameterType="Long">
        delete from qw_friend_welcome where id = #{id}
    </delete>

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