<?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="net.chenlin.dp.modules.sys.dao.SysRoleMenuMapper">
	
	<insert id="save">
		INSERT INTO sys_role_menu (
			role_id,
			menu_id
		)
		VALUES
		<foreach collection="menuIdList" item="item" index="index" separator="," >
		(
			#{roleId}, 
			#{item} 
		)
		</foreach>
	</insert>
	
	<select id="listMenuId" resultType="long">
		SELECT
			menu_id
		FROM
			sys_role_menu
		WHERE
			role_id = #{id}
	</select>
	
	<delete id="batchRemoveByMenuId">
		DELETE
		FROM
			sys_role_menu
		WHERE
			menu_id IN 
		<foreach item="id" collection="array" open="(" separator="," close=")">
			#{id}
		</foreach>
	</delete>
	
	<delete id="batchRemoveByRoleId">
		DELETE
		FROM
			sys_role_menu
		WHERE
			role_id IN 
		<foreach item="id" collection="array" open="(" separator="," close=")">
			#{id}
		</foreach>
	</delete>
	
	<delete id="remove">
		DELETE
		FROM 
			sys_role_menu
		WHERE 
			role_id = #{value}
	</delete>

</mapper>