<?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.ChannelDeptMapper">
    
    <resultMap type="com.tuoheng.admin.entity.ChannelDept" id="ChannelDeptResult">
        <result property="tenantId"    column="tenant_id"    />
        <result property="channelId"    column="channel_id"    />
        <result property="deptId"    column="dept_id"    />
    </resultMap>

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

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

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

    <select id="selectListByDeptIdList" resultType="list" resultMap="ChannelDeptResult">
        select <include refid="Base_Column_List"/>
        from th_channel_dept
        where dept_id in
        <foreach collection="list" item="deptId" separator="," open="(" close=")">
            #{deptId}
        </foreach>
    </select>

</mapper>