<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: hty
    $Date: 2018/5/29 11:41
    $Revision: 1.0 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    v.function_id,
                    v.function_code,
                    v.function_name,
                    v.menu_id,
                    v.parent_menu_id,
                    (select function_name from sys_role_menu_v where menu_id = v.parent_menu_id) parent_function_name,
                    (select function_name from sys_role_menu_v where menu_id = (
                    select
                        parent_menu_id
                    from
                        sys_role_menu_v
                    where
                        menu_id = v.parent_menu_id)) grand_parent_function_name,
                    (select nvl(sum(1),0) from sys_role_menu_v v1 where v1.parent_menu_id=v.menu_id) sub_menu_count
                FROM
                    sys_role_menu_v v
                WHERE
                    v.function_code = ${@function_code}
                    and v.role_id = ${/session/@role_id}
                ORDER BY
                    v.layout_sequence
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>