<?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.ics.system.mapper.RoleDeptMapper">

    <resultMap type="com.ics.system.domain.RoleDept" id="SysRoleDeptResult">
        <result property="roleId" column="role_id"/>
        <result property="deptId" column="dept_id"/>
    </resultMap>

    <delete id="deleteRoleDeptByRoleId" parameterType="Long">
		DELETE FROM sys_role_dept WHERE role_id=#{roleId}
	</delete>

    <select id="selectCountRoleDeptByDeptId" resultType="Integer">
	    SELECT COUNT(1) FROM sys_role_dept WHERE dept_id=#{deptId}
	</select>

    <delete id="deleteRoleDept" parameterType="Long">
        DELETE FROM sys_role_dept WHERE role_id IN
        <foreach collection="array" item="roleId" open="(" separator="," close=")">
            #{roleId}
        </foreach>
    </delete>

    <insert id="batchRoleDept">
        INSERT INTO sys_role_dept(role_id, dept_id) VALUES
        <foreach item="item" index="index" collection="list" separator=",">
            (#{item.roleId},#{item.deptId})
        </foreach>
    </insert>

</mapper> 