<?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.ruoyi.system.mapper.SysUserRoleMapper">

	<resultMap type="com.ruoyi.system.domain.SysUserRole" id="SysUserRoleResult">
		<result property="userId"     column="user_id"      />
		<result property="roleId"     column="role_id"      />
	</resultMap>

	<select id="countUserRoleByRoleId" resultType="int">
	    SELECT COUNT(1)
	    FROM sys_user_role
	    WHERE role_id = #{roleId}
	</select>

	<delete id="deleteUserRoleInfo" parameterType="com.ruoyi.system.domain.SysUserRole">
		DELETE FROM sys_user_role
		WHERE user_id = #{userId}
		AND role_id = #{roleId}
	</delete>

	<delete id="deleteUserRoleByUserId" parameterType="java.lang.Long">
		DELETE FROM sys_user_role
		WHERE user_id = #{userId}
	</delete>

	<delete id="deleteUserRole" parameterType="java.lang.Long">
		DELETE FROM sys_user_role
		WHERE user_id IN
		<foreach collection="array" item="userId" open="(" separator="," close=")">
			#{userId}
		</foreach>
	</delete>

	<delete id="deleteUserRoleInfos">
		DELETE FROM sys_user_role
		WHERE role_id = #{roleId}
		AND user_id IN
		<foreach collection="userIds" item="userId" open="(" separator="," close=")">
			#{userId}
		</foreach>
	</delete>

</mapper>