<?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.bonus.material.basic.mapper.BmUserRoleMapper">

    <select id="getUserRoleListByDeptId" resultType="com.bonus.material.basic.domain.dto.SysUserRoleVo">
        SELECT
            su.user_id as userId, su.user_name as userName, su.dept_id as deptId, sr.role_name as roleName, sr.role_id as roleId,
            sd.ancestors as ancestors
        FROM
            sys_user su
        LEFT JOIN
            sys_user_role sur ON su.user_id = sur.user_id
        LEFT JOIN
            sys_dept sd ON su.dept_id = sd.dept_id
        LEFT JOIN
            sys_role sr ON sur.role_id = sr.role_id
        WHERE su.dept_id = #{deptId} AND sr.role_id = #{roleId}
    </select>
</mapper>