<?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.project.system.user.dao.IUserRoleDao">

	<resultMap type="UserRole" id="UserRoleResult">
		<result property="userId"     column="user_id"      />
		<result property="roleId"     column="role_id"      />
	</resultMap>

	<delete id="deleteUserRoleByUserId">
		delete from sys_user_role where user_id=#{userId}
	</delete>
	
	<delete id="deleteUserRoleByRoleId">
		delete from sys_user_role where role_id=#{roleId}
	</delete>
	
	<insert id="batchUserRole">
		insert into sys_user_role(user_id, role_id) values
		<foreach item="item" index="index" collection="list" separator=",">
			(#{item.userId},#{item.roleId})
		</foreach>
	</insert>
	
</mapper> 