<?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.qmth.themis.business.dao.TBPrivilegeMapper">

    <select id="getMenu" resultType="com.qmth.themis.business.entity.TBPrivilege">
          select
                tbp.*
            from
                t_b_privilege tbp
            left join t_b_role_privilege tbrp on
                tbrp.privilege_id = tbp.id
            left join t_b_role tbr on
                tbr.role_code = tbrp.role_code
            left join t_b_user_role tbur on
                tbur.role_code = tbr.role_code
            left join t_b_user tbu on
                tbu.id = tbur.user_id
            where
                tbp.`type` = 'MENU'
                and tbu.id = #{userId}
            order by
                tbp.parent_id,
                tbp.`sequence`
    </select>
</mapper>
