<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: DJ  
    $Date: 2013-4-14 下午02:19:46  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <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,
                    case when v.menu_type = 'MENU' then
                    (case   when (select count(*) from sys_role_module_home_page srmw where srmw.function_group_id = v.function_id and srmw.role_id = v.role_id and srmw.subject = ${/session/@subject}) > 0 then 'role_module'
                            when (select count(*) from sys_module_home_page smhp where smhp.function_group_id = v.function_id and smhp.subject = ${/session/@subject}) > 0 then 'module'
                            else 'none' end
                    )else 'none' end module_flag,
                    (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_CLAUSE#
                ORDER BY
                    v.layout_sequence
            ]]></bm:query-sql>
</bm:operation>
        </bm:operations>
<bm:data-filters>
<bm:data-filter enforceOperations="query" expression="(v.role_code not in('0018','0019')  or   (v.role_code in('0018','0019') and hl_asset_manage_fee_pkg.check_function_show(v.role_code, ${/session/@user_id},v.function_code)='Y' ))" ></bm:data-filter>
<bm:data-filter enforceOperations="query" expression="v.role_id=${/session/@role_id}"/>
<bm:data-filter enforceOperations="query" expression="((not exists (select 1 from sys_role_user_function f where f.role_id = v.role_id and f.function_id = v.function_id)) or (exists  (select 1 from sys_role_user_function f where f.role_id = v.role_id and f.user_id = ${/session/@user_id} and f.function_id = v.function_id)))"/>
<!--<bm:data-filter enforceOperations="query" expression="((v.function_code != 'CON3200') or(v.function_code = 'CON3200' AND ((v.role_code not in ('0018', '0019')) or  (v.role_code in ('0018', '0019') and exists  (select 1  from sys_user u, sys_user_role_groups r  where u.user_id = r.user_id  and r.role_id = v.role_id  AND u.user_id = ${/session/@user_id}  and u.user_name in ('MJ001', 'MJ002'))))))"/>
-->
</bm:data-filters>
</bm:model>
