<?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.ruoyi.postCheck.mapper.PostTeamUserMapper">
    
    <resultMap type="PostTeamUser" id="PostTeamUserResult">
        <result property="id"    column="id"    />
        <result property="postTeamId"    column="post_team_id"    />
        <result property="userId"    column="user_id"    />
        <result property="type"    column="type"    />
        <result property="remark"    column="remark"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="createUserId"    column="create_user_id"    />
    </resultMap>

    <sql id="selectPostTeamUserVo">
        select id, post_team_id, user_id, type, remark, del_flag, create_time, create_by, update_time, update_by, create_user_id from post_team_user
    </sql>

    <select id="selectPostTeamUserList" parameterType="PostTeamUser" resultMap="PostTeamUserResult">
        <include refid="selectPostTeamUserVo"/>
        <where>  
            <if test="postTeamId != null  and postTeamId != ''"> and post_team_id = #{postTeamId}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="createUserId != null "> and create_user_id = #{createUserId}</if>
        </where>
    </select>
    
    <select id="selectPostTeamUserById" parameterType="Long" resultMap="PostTeamUserResult">
        <include refid="selectPostTeamUserVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertPostTeamUser" parameterType="PostTeamUser">
        insert into post_team_user
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="postTeamId != null">post_team_id,</if>
            <if test="userId != null">user_id,</if>
            <if test="type != null">type,</if>
            <if test="remark != null">remark,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null and updateBy != ''">update_by,</if>
            <if test="createUserId != null">create_user_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="postTeamId != null">#{postTeamId},</if>
            <if test="userId != null">#{userId},</if>
            <if test="type != null">#{type},</if>
            <if test="remark != null">#{remark},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
            <if test="createUserId != null">#{createUserId},</if>
         </trim>
    </insert>

    <update id="updatePostTeamUser" parameterType="PostTeamUser">
        update post_team_user
        <trim prefix="SET" suffixOverrides=",">
            <if test="postTeamId != null">post_team_id = #{postTeamId},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="type != null">type = #{type},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
            <if test="createUserId != null">create_user_id = #{createUserId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePostTeamUserById" parameterType="Long">
        delete from post_team_user where id = #{id}
    </delete>

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