<?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="cn.ezhizao.project.system.mapper.SysUserRoleMapper">

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

    <select id="selectRoleListByUserId" resultType="cn.ezhizao.project.system.domain.SysRole">
        select * from sys_role t1 left join sys_user_role t2 on t1.role_id = t2.role_id where t2.user_id = #{userId} and
        t1.del_flag = '0'
    </select>

    <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>

    <delete id="deleteUserRoleInfo" parameterType="cn.ezhizao.project.system.domain.SysUserRole">
        delete from sys_user_role where user_id=#{userId} and role_id=#{roleId}
    </delete>
</mapper>
