<?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.vctgo.system.mapper.SysPlatformRoleMenuMapper">

	<resultMap type="com.vctgo.system.domain.SysPlatformRoleMenu" id="SysRoleMenuResult">
		<result property="roleId"     column="role_id"      />
		<result property="menuId"     column="menu_id"      />
		<result property="tenantId"     column="tenant_id"      />
	</resultMap>

	<select id="checkMenuExistRole" resultType="Integer">
	    select count(1) from sys_platform_role_menu where menu_id = #{menuId}
	</select>

	<delete id="deleteRoleMenuByRoleId" parameterType="Long">
		delete from sys_platform_role_menu where role_id=#{roleId}
	</delete>

	<delete id="deleteRoleMenuByTenantId" parameterType="Long">
		delete from sys_platform_role_menu where tenant_id=#{tenantId}
	</delete>

	<delete id="deleteRoleMenu" parameterType="Long">
 		delete from sys_platform_role_menu where role_id in
 		<foreach collection="array" item="roleId" open="(" separator="," close=")">
 			#{roleId}
        </foreach>
 	</delete>
	<delete id="deleteRoleMenuByTenantIds">
		delete from sys_platform_role_menu where tenant_id in
		<foreach item="id" collection="array" open="(" separator="," close=")">
			#{id}
		</foreach>
	</delete>

	<delete id="deleteRoleMenuByTenantIdAndPackage">
		delete from sys_platform_role_menu where tenant_id = #{tenantId} and menu_id in
		<foreach item="menuid" collection="menuids" open="(" separator="," close=")">
			#{menuid}
		</foreach>
	</delete>

	<insert id="batchRoleMenu">
		insert into sys_platform_role_menu(role_id, menu_id) values
		<foreach item="item" index="index" collection="list" separator=",">
			(#{item.roleId},#{item.menuId})
		</foreach>
	</insert>
	<insert id="batchRoleMenuByPackage">
		insert into sys_platform_role_menu(role_id, menu_id,tenant_id) values
		<foreach item="item" index="index" collection="list" separator=",">
			(#{item.roleId},#{item.menuId},#{item.tenantId})
		</foreach>
	</insert>

</mapper>
