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

    <resultMap type="QwSopTag" id="QwSopTagResult">
        <result property="id"    column="id"    />
        <result property="type"    column="type"    />
        <result property="status"    column="status"    />
        <result property="sopUserLogsId"    column="sop_user_logs_id"    />
        <result property="addTags"    column="add_tags"    />
        <result property="delTags"    column="del_tags"    />
        <result property="corpId"    column="corp_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="sendTime"    column="send_time"    />
    </resultMap>

    <sql id="selectQwSopTagVo">
        select id, type, status, sop_user_logs_id,send_time, add_tags, del_tags, corp_id, create_time, update_time from qw_sop_tag
    </sql>

    <select id="selectQwSopTagList" parameterType="QwSopTag" resultMap="QwSopTagResult">
        <include refid="selectQwSopTagVo"/>
        <where>
            <if test="type != null "> and type = #{type}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="sopUserLogsId != null  and sopUserLogsId != ''"> and sop_user_logs_id = #{sopUserLogsId}</if>
            <if test="addTags != null  and addTags != ''"> and add_tags = #{addTags}</if>
            <if test="delTags != null  and delTags != ''"> and del_tags = #{delTags}</if>
            <if test="corpId != null  and corpId != ''"> and corp_id = #{corpId}</if>
        </where>
    </select>

    <select id="selectQwSopTagById" parameterType="Long" resultMap="QwSopTagResult">
        <include refid="selectQwSopTagVo"/>
        where id = #{id}
    </select>

    <insert id="insertQwSopTag" parameterType="QwSopTag">
        insert into qw_sop_tag
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="type != null">type,</if>
            <if test="status != null">status,</if>
            <if test="sopUserLogsId != null">sop_user_logs_id,</if>
            <if test="addTags != null">add_tags,</if>
            <if test="delTags != null">del_tags,</if>
            <if test="corpId != null">corp_id,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="sendTime != null">send_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="type != null">#{type},</if>
            <if test="status != null">#{status},</if>
            <if test="sopUserLogsId != null">#{sopUserLogsId},</if>
            <if test="addTags != null">#{addTags},</if>
            <if test="delTags != null">#{delTags},</if>
            <if test="corpId != null">#{corpId},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="sendTime != null">#{sendTime},</if>
         </trim>
    </insert>

    <update id="updateQwSopTag" parameterType="QwSopTag">
        update qw_sop_tag
        <trim prefix="SET" suffixOverrides=",">
            <if test="type != null">type = #{type},</if>
            <if test="status != null">status = #{status},</if>
            <if test="sopUserLogsId != null">sop_user_logs_id = #{sopUserLogsId},</if>
            <if test="addTags != null">add_tags = #{addTags},</if>
            <if test="delTags != null">del_tags = #{delTags},</if>
            <if test="corpId != null">corp_id = #{corpId},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="sendTime != null">send_time = #{sendTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteQwSopTagById" parameterType="Long">
        delete from qw_sop_tag where id = #{id}
    </delete>

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