<?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.backendsys.modules.system.dao.SysUserRolePermissionRelationDao">

    <select id="selectUserRolePermissionIdsByRoleIds" resultType="java.lang.String">
        SELECT permission_id
        FROM sys_user_role_permission_relation
        WHERE role_id IN
        <foreach item="role_id" index="index" collection="role_ids" open="(" separator="," close=")">
            #{role_id}
        </foreach>
    </select>

    <resultMap id="resultMapRolePermission" type="com.backendsys.modules.system.entity.SysUserRolePermission">
        <result property="id" column="id"/>
        <result property="parent_id" column="parent_id"/>
        <result property="permission_name" column="permission_name" />
    </resultMap>
    <select id="selectUserRolePermissionByRoleId" resultMap="resultMapRolePermission">
        SELECT surm.id, surm.parent_id, surm.permission_name
        FROM sys_user_role_permission_relation surmr
        LEFT JOIN sys_user_role_permission surm ON surm.id = surmr.permission_id
        WHERE surmr.role_id = #{role_id}
    </select>


</mapper>