<?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.gz.mapper.system.MenuMapper">
    <select id="getMenusOrder" resultType="com.gz.dto.system.MenuDTO">
        select * from tab_menu where deleted = 0 order by `sort` asc
    </select>

    <select id="getRoleMenu" resultType="com.gz.dto.system.MenuDTO">
        SELECT
            m.*
        FROM
            tab_menu m
            LEFT JOIN tab_menu_role mr ON m.id = mr.menu_id
        WHERE
             m.deleted = 0
             AND mr.role_id = #{roleId}
            AND mr.role_type = 0
            AND m.type != 2
        order by m.`sort` asc
    </select>

    <select id="getRoleButtle" resultType="com.gz.dto.system.MenuDTO">
        SELECT
            m.*
        FROM
            tab_menu m
            LEFT JOIN tab_menu_role mr ON m.id = mr.menu_id
        WHERE
            m.deleted = 0
            AND mr.role_id = #{roleId}
            AND m.parent_id = #{menuId}
            AND mr.role_type = 0
            AND m.type = 2
        order by m.`sort` asc
    </select>

</mapper>
