<?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.sop.mapper.QwSopLogsDetalisMapper">

    <resultMap type="QwSopLogsDetalis" id="QwSopLogsDetalisResult">
        <result property="id"    column="id"    />
        <result property="type"    column="type"    />
        <result property="externalUserId"    column="external_user_id"    />
        <result property="qwUserId"    column="qw_user_id"    />
        <result property="corpId"    column="corp_id"    />
        <result property="sendList"    column="send_list"    />
        <result property="nextExternalUserId"    column="next_external_user_id"    />
    </resultMap>

    <sql id="selectQwSopLogsDetalisVo">
        select id, type, external_user_id, qw_user_id, corp_id, send_list, next_external_user_id from qw_sop_logs_detalis
    </sql>

    <select id="selectQwSopLogsDetalisList" parameterType="QwSopLogsDetalis" resultMap="QwSopLogsDetalisResult">
        <include refid="selectQwSopLogsDetalisVo"/>
        <where>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="externalUserId != null  and externalUserId != ''"> and external_user_id = #{externalUserId}</if>
            <if test="qwUserId != null  and qwUserId != ''"> and qw_user_id = #{qwUserId}</if>
            <if test="corpId != null  and corpId != ''"> and corp_id = #{corpId}</if>
            <if test="sendList != null  and sendList != ''"> and send_list = #{sendList}</if>
            <if test="nextExternalUserId != null  and nextExternalUserId != ''"> and next_external_user_id = #{nextExternalUserId}</if>
        </where>
    </select>

    <select id="selectQwSopLogsDetalisById" parameterType="Long" resultMap="QwSopLogsDetalisResult">
        <include refid="selectQwSopLogsDetalisVo"/>
        where id = #{id}
    </select>

    <insert id="insertQwSopLogsDetalis" parameterType="QwSopLogsDetalis">
        insert into qw_sop_logs_detalis
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="type != null">type,</if>
            <if test="externalUserId != null">external_user_id,</if>
            <if test="qwUserId != null">qw_user_id,</if>
            <if test="corpId != null">corp_id,</if>
            <if test="sendList != null">send_list,</if>
            <if test="nextExternalUserId != null">next_external_user_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="type != null">#{type},</if>
            <if test="externalUserId != null">#{externalUserId},</if>
            <if test="qwUserId != null">#{qwUserId},</if>
            <if test="corpId != null">#{corpId},</if>
            <if test="sendList != null">#{sendList},</if>
            <if test="nextExternalUserId != null">#{nextExternalUserId},</if>
         </trim>
    </insert>

    <update id="updateQwSopLogsDetalis" parameterType="QwSopLogsDetalis">
        update qw_sop_logs_detalis
        <trim prefix="SET" suffixOverrides=",">
            <if test="type != null">type = #{type},</if>
            <if test="externalUserId != null">external_user_id = #{externalUserId},</if>
            <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
            <if test="corpId != null">corp_id = #{corpId},</if>
            <if test="sendList != null">send_list = #{sendList},</if>
            <if test="nextExternalUserId != null">next_external_user_id = #{nextExternalUserId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteQwSopLogsDetalisById" parameterType="Long">
        delete from qw_sop_logs_detalis where id = #{id}
    </delete>

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