<?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.xingxi.business.UserRefuseTag.mapper.UserRefuseTagMapper">
    <resultMap type="UserRefuseTag" id="UserRefuseTagResult">
        <result property="userRefuseid"    column="userRefuseid"    />
        <result property="userId"    column="user_id"    />
        <result property="tagId"    column="tagId"    />
        <result property="delFlag"    column="delFlag"    />
        <result property="createUser"    column="createUser"    />
        <result property="createTime"    column="createTime"    />
        <result property="updateUser"    column="updateUser"    />
        <result property="updateTime"    column="updateTime"    />
    </resultMap>

    <sql id="selectUserRefuseTag">
        select userRefuseid, user_id, tagId, delFlag, createUser, createTime, updateUser, updateTime from t_user_refuse_tag
    </sql>

    <sql id="selectUserRefuseTagExt">
        select
            ${tableAlias}.userRefuseid,
            ${tableAlias}.user_id,
            ${tableAlias}.tagId,
            ${tableAlias}.delFlag,
            ${tableAlias}.createUser,
            ${tableAlias}.createTime,
            ${tableAlias}.updateUser,
            ${tableAlias}.updateTime
        from t_user_refuse_tag ${tableAlias}
    </sql>

    <select id="selectUserRefuseTagList" parameterType="UserRefuseTag" resultMap="UserRefuseTagResult">
        <include refid="selectUserRefuseTag"/>
        <where>  
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="tagId != null "> and tagId = #{tagId}</if>
            <if test="delFlag != null  and delFlag != ''"> and delFlag = #{delFlag}</if>
            <if test="createUser != null  and createUser != ''"> and createUser = #{createUser}</if>
            <if test="createTime != null "> and createTime = #{createTime}</if>
            <if test="updateUser != null  and updateUser != ''"> and updateUser = #{updateUser}</if>
            <if test="updateTime != null "> and updateTime = #{updateTime}</if>
        </where>
    </select>
    
    <select id="selectUserRefuseTagByUserRefuseid" parameterType="Long" resultMap="UserRefuseTagResult">
        <include refid="selectUserRefuseTag"/>
        where userRefuseid = #{userRefuseid}
    </select>
        
    <insert id="insertUserRefuseTag" parameterType="UserRefuseTag" useGeneratedKeys="true" keyProperty="userRefuseid">
        insert into t_user_refuse_tag
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="tagId != null">tagId,</if>
            <if test="delFlag != null">delFlag,</if>
            <if test="createUser != null">createUser,</if>
            <if test="createTime != null">createTime,</if>
            <if test="updateUser != null">updateUser,</if>
            <if test="updateTime != null">updateTime,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="tagId != null">#{tagId},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createUser != null">#{createUser},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateUser != null">#{updateUser},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <insert id="batchInsertUserRefuseTag">
        insert into t_user_refuse_tag( user_id, tagId, delFlag, createUser, createTime, updateUser, updateTime) values
        <foreach item="item" index="index" collection="list" separator=",">
            ( #{item.userId}, #{item.tagId}, #{item.delFlag}, #{item.createUser}, #{item.createTime}, #{item.updateUser}, #{item.updateTime})
        </foreach>
    </insert>

    <update id="updateUserRefuseTag" parameterType="UserRefuseTag">
        update t_user_refuse_tag
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="tagId != null">tagId = #{tagId},</if>
            <if test="delFlag != null">delFlag = #{delFlag},</if>
            <if test="createUser != null">createUser = #{createUser},</if>
            <if test="createTime != null">createTime = #{createTime},</if>
            <if test="updateUser != null">updateUser = #{updateUser},</if>
            <if test="updateTime != null">updateTime = #{updateTime},</if>
        </trim>
        where userRefuseid = #{userRefuseid}
    </update>

    <delete id="deleteUserRefuseTagByUserRefuseid" parameterType="Long">
        delete from t_user_refuse_tag where userRefuseid = #{userRefuseid}
    </delete>

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

    <update id="logicDeleteUserRefuseTagByUserRefuseid" parameterType="Long">
        update t_user_refuse_tag
            set delFlag = '1'
        where userRefuseid = #{userRefuseid}
    </update>

    <update id="logicDeleteUserRefuseTagByUserRefuseids" parameterType="String">
        update t_user_refuse_tag
        set delFlag = '1'
        where userRefuseid in
        <foreach item="userRefuseid" collection="array" open="(" separator="," close=")">
            #{userRefuseid}
        </foreach>
    </update>

    <update id="logicDeleteUserRefuseTagByCondition" parameterType="UserRefuseTag">
        update t_user_refuse_tag
        set delFlag = '1'
        <where>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="tagId != null "> and tagId = #{tagId}</if>
            <if test="delFlag != null  and delFlag != ''"> and delFlag = #{delFlag}</if>
            <if test="createUser != null  and createUser != ''"> and createUser = #{createUser}</if>
            <if test="createTime != null "> and createTime = #{createTime}</if>
            <if test="updateUser != null  and updateUser != ''"> and updateUser = #{updateUser}</if>
            <if test="updateTime != null "> and updateTime = #{updateTime}</if>
        </where>
    </update>
</mapper>