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

    <resultMap type="PostTeam" id="PostTeamResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="parentId"    column="parent_id"    />
        <result property="status"    column="status"    />
        <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"    />
        <result property="type"    column="type"    />
        <result property="teamType"    column="team_type"    />
    </resultMap>

    <sql id="selectPostTeamVo">
        select
            id,
            name,
            parent_id,
            status,
            remark,
            del_flag,
            create_time,
            create_by,
            update_time,
            update_by,
            create_user_id,
            type,
            team_type
        from post_team
    </sql>

    <select id="selectPostTeamList" parameterType="PostTeam" resultMap="PostTeamResult">
        <include refid="selectPostTeamVo"/>
        <where>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="parentId != null "> and parent_id = #{parentId}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="createUserId != null "> and create_user_id = #{createUserId}</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="teamType != null "> and team_type = #{teamType}</if>
        </where>
    </select>

    <select id="selectPostTeamById" parameterType="Long" resultMap="PostTeamResult">
        <include refid="selectPostTeamVo"/>
        where id = #{id}
    </select>

    <insert id="insertPostTeam" parameterType="PostTeam">
        insert into post_team
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="name != null">name,</if>
            <if test="parentId != null">parent_id,</if>
            <if test="status != null">status,</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>
            <if test="type != null">type,</if>
            <if test="teamType != null">team_type,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="name != null">#{name},</if>
            <if test="parentId != null">#{parentId},</if>
            <if test="status != null">#{status},</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>
            <if test="type != null">#{type},</if>
            <if test="teamType != null">#{teamType},</if>
         </trim>
    </insert>

    <update id="updatePostTeam" parameterType="PostTeam">
        update post_team
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="parentId != null">parent_id = #{parentId},</if>
            <if test="status != null">status = #{status},</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>
            <if test="type != null">type = #{type},</if>
            <if test="teamType != null">team_type = #{teamType},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePostTeamById" parameterType="Long">
        delete from post_team where id = #{id}
    </delete>

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