<?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.kmall.admin.fromcomm.dao.SysUserRoleDao">

	<select id="queryList" resultType="com.kmall.admin.fromcomm.entity.SysUserRoleEntity">
		select * from sys_user_role 
		<where>
			<if test="userId != null">
				user_id = #{userId}
			</if>
			<if test="roleId != null">
				role_id = #{roleId}
			</if>
		</where>
	</select>
 
	<insert id="save">
		insert into sys_user_role
		(
			`user_id`, 
			`role_id`
		)
		values
		(
			#{userId}, 
			#{roleId}
		)
	</insert>
	
	<delete id="delete">
		delete from sys_user_role where user_id = #{value}
	</delete>

	<delete id="deleteByRoleId">
		delete from sys_user_role where role_id = #{value}
	</delete>
	
	<select id="queryRoleIdList" resultType="long">
		select role_id from sys_user_role where user_id = #{value}
	</select>
</mapper>