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

    <resultMap type="QwSopTagLogs" id="QwSopTagLogsResult">
        <result property="id"    column="id"    />
        <result property="type"    column="type"    />
        <result property="sopTagId"    column="sop_tag_id"    />
        <result property="sopUserLogsId"    column="sop_user_logs_id"    />
        <result property="addTag"    column="add_tag"    />
        <result property="delTag"    column="del_tag"    />
        <result property="extId"    column="ext_id"    />
        <result property="status"    column="status"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectQwSopTagLogsVo">
        select id, type, sop_tag_id, sop_user_logs_id, add_tag, del_tag, ext_id, status, create_time from qw_sop_tag_logs
    </sql>

    <select id="selectQwSopTagLogsList" parameterType="QwSopTagLogs" resultMap="QwSopTagLogsResult">
        <include refid="selectQwSopTagLogsVo"/>
        <where>
            <if test="type != null "> and type = #{type}</if>
            <if test="sopTagId != null "> and sop_tag_id = #{sopTagId}</if>
            <if test="sopUserLogsId != null  and sopUserLogsId != ''"> and sop_user_logs_id = #{sopUserLogsId}</if>
            <if test="addTag != null  and addTag != ''"> and add_tag = #{addTag}</if>
            <if test="delTag != null  and delTag != ''"> and del_tag = #{delTag}</if>
            <if test="extId != null "> and ext_id = #{extId}</if>
            <if test="status != null "> and status = #{status}</if>
        </where>
    </select>

    <select id="selectQwSopTagLogsById" parameterType="Long" resultMap="QwSopTagLogsResult">
        <include refid="selectQwSopTagLogsVo"/>
        where id = #{id}
    </select>

    <insert id="insertQwSopTagLogs" parameterType="QwSopTagLogs">
        insert into qw_sop_tag_logs
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="type != null">type,</if>
            <if test="sopTagId != null">sop_tag_id,</if>
            <if test="sopUserLogsId != null">sop_user_logs_id,</if>
            <if test="addTag != null">add_tag,</if>
            <if test="delTag != null">del_tag,</if>
            <if test="extId != null">ext_id,</if>
            <if test="status != null">status,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="type != null">#{type},</if>
            <if test="sopTagId != null">#{sopTagId},</if>
            <if test="sopUserLogsId != null">#{sopUserLogsId},</if>
            <if test="addTag != null">#{addTag},</if>
            <if test="delTag != null">#{delTag},</if>
            <if test="extId != null">#{extId},</if>
            <if test="status != null">#{status},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateQwSopTagLogs" parameterType="QwSopTagLogs">
        update qw_sop_tag_logs
        <trim prefix="SET" suffixOverrides=",">
            <if test="type != null">type = #{type},</if>
            <if test="sopTagId != null">sop_tag_id = #{sopTagId},</if>
            <if test="sopUserLogsId != null">sop_user_logs_id = #{sopUserLogsId},</if>
            <if test="addTag != null">add_tag = #{addTag},</if>
            <if test="delTag != null">del_tag = #{delTag},</if>
            <if test="extId != null">ext_id = #{extId},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteQwSopTagLogsById" parameterType="Long">
        delete from qw_sop_tag_logs where id = #{id}
    </delete>

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