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

    <resultMap type="QwWorkLinkUser" id="QwWorkLinkUserResult">
        <result property="id"    column="id"    />
        <result property="linkId"    column="link_id"    />
        <result property="qwUserId"    column="qw_user_id"    />
        <result property="qwUserWxId"    column="qw_user_wx_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectQwWorkLinkUserVo">
        select id, link_id, qw_user_id, qw_user_wx_id, create_time, create_by, update_by, update_time, remark from qw_work_link_user
    </sql>

    <select id="selectQwWorkLinkUserList" parameterType="QwWorkLinkUser" resultMap="QwWorkLinkUserResult">
        <include refid="selectQwWorkLinkUserVo"/>
        <where>
            <if test="linkId != null "> and link_id = #{linkId}</if>
            <if test="qwUserId != null "> and qw_user_id = #{qwUserId}</if>
            <if test="qwUserWxId != null  and qwUserWxId != ''"> and qw_user_wx_id = #{qwUserWxId}</if>
        </where>
    </select>

    <select id="selectQwWorkLinkUserById" parameterType="Long" resultMap="QwWorkLinkUserResult">
        <include refid="selectQwWorkLinkUserVo"/>
        where id = #{id}
    </select>

    <insert id="insertQwWorkLinkUser" parameterType="QwWorkLinkUser" useGeneratedKeys="true" keyProperty="id">
        insert into qw_work_link_user
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="linkId != null">link_id,</if>
            <if test="qwUserId != null">qw_user_id,</if>
            <if test="qwUserWxId != null">qw_user_wx_id,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="linkId != null">#{linkId},</if>
            <if test="qwUserId != null">#{qwUserId},</if>
            <if test="qwUserWxId != null">#{qwUserWxId},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateQwWorkLinkUser" parameterType="QwWorkLinkUser">
        update qw_work_link_user
        <trim prefix="SET" suffixOverrides=",">
            <if test="linkId != null">link_id = #{linkId},</if>
            <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
            <if test="qwUserWxId != null">qw_user_wx_id = #{qwUserWxId},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteQwWorkLinkUserById" parameterType="Long">
        delete from qw_work_link_user where id = #{id}
    </delete>

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