<?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.tuoheng.admin.mapper.SectionDeptMapper">
    
    <resultMap type="com.tuoheng.admin.entity.SectionDept" id="SectionDeptResult">
        <result property="tenantId"    column="tenant_id"    />
        <result property="sectionId"    column="section_id"    />
        <result property="deptId"    column="dept_id"    />
    </resultMap>

    <sql id="Base_Column_List">
        tenant_id, section_id, dept_id
    </sql>

    <!-- 批量新增数据 -->
    <insert id="insertBatch" parameterType="com.tuoheng.admin.entity.SectionDept">
        insert into th_section_dept (<include refid="Base_Column_List"/>)
        VALUES
        <foreach collection="list" item="item" index="index" separator=",">
            ( #{item.tenantId, jdbcType=INTEGER}, #{item.sectionId,jdbcType=VARCHAR}, #{item.deptId, jdbcType=VARCHAR} )
        </foreach>
    </insert>

    <!-- 批量删除数据 -->
    <delete id="deleteBatchByMap" parameterType="hashmap">
        delete from th_section_dept
        where tenant_id = #{tenantId} and dept_id = #{deptId}
        <if test="sectionIdList != null and sectionIdList.size() >0 ">
            and section_id in
            <foreach collection="sectionIdList" item="sectionId" separator="," open="(" close=")">
                #{sectionId}
            </foreach>
        </if>
    </delete>

</mapper>