<?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.tuoheng.admin.mapper.UserRoleMapper">

    <!-- 获取用户角色 -->
    <select id="getRolesByUserId" resultType="com.tuoheng.admin.entity.Role">
        SELECT r.* FROM th_role AS r
        INNER JOIN th_user_role AS ur ON r.id=ur.role_id
        WHERE ur.user_id=#{userId} AND r.mark=1;
    </select>

    <!-- 获取用户ID -->
    <select id="getUsersByURoleId" resultType="String">
        SELECT user_id FROM th_user_role WHERE role_id = #{roleId};
    </select>

    <select id="getListByRoleId" resultType="com.tuoheng.admin.dto.UserRoleDto">
        SELECT *
        FROM sys_user_role
        WHERE sys_user_role.role_id = #{roleId}
          and sys_user_role.tenant_id = #{tenantId}
    </select>

</mapper>
