<?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.czg.service.account.mapper.SysMenuMapper">

    <select id="selectByUserId" resultType="com.czg.account.entity.SysMenu">
        select c.*
        from sys_users_roles as a
        left join sys_roles_menus as b on a.role_id = b.role_id
        left join sys_menu as c on c.menu_id = b.menu_id
        where a.user_id = #{userId} and c.menu_id is not null
        <if test="type != null">
            and c.type=#{type}
        </if>
        order by menu_sort desc
    </select>
</mapper>
