<?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.central.user.mapper.SysUserRoleMapper">
	<delete id="deleteUserRole">
		delete from sys_role_user
		<where>
			<if test="userId != null">
				and user_id = #{userId}
			</if>
			<if test="roleId != null">
				and role_id = #{roleId}
			</if>
		</where>
	</delete>

	<select id="findRolesByUserId" resultType="com.central.common.model.SysRole">
		select r.* from sys_role r
		inner join sys_role_user ru on r.id = ru.role_id and ru.user_id = #{userId}
	</select>
</mapper>