<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2013-12-10 下午03:41:29  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:e="leaf.service.exception" xmlns:f="leaf.database.features" xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1" baseTable="AUT_OWNER_USER_BATCH_TMP">
    <bm:operations>
        <!-- <bm:operation name="query">
            <bm:query-sql><![CDATA[
				select v.user_id,
				       v.user_name,
				       v.description authorized_user_desc,
				       v.employee_code,
				       v.employee_name,
				       t.session_id
				  from sys_user_v v, aut_owner_user_batch_tmp t
				 where v.user_id(+) = t.user_id
				   and t.session_id = ${/session/@session_id}
			]]></bm:query-sql>
        </bm:operation> -->
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            select t1.* from
				(select v.user_id,
				       v.user_name,
				       v.description authorized_user_desc,
				       v.employee_code,
				       v.employee_name,
				       ${/session/@session_id} session_id,
				       decode(v.bp_category,'EMPLOYEE','员工','AGENT','代理商')bp_category,
				       v.extra_nam,
				       v.bp_name,
				       v.unit_name,
				       v.position_desc,
				       v.bp_code
				  from sys_user_v v, aut_owner_user_default t
				  where v.user_id(+)=t.user_id ) t1
				  #WHERE_CLAUSE#
			]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="delete">
            <bm:update-sql><![CDATA[
				begin
                    DELETE
                    FROM
                        AUT_OWNER_USER_BATCH_TMP ;
                        
                        end;
			]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="insert">
            <bm:update-sql><![CDATA[
                DECLARE
                BEGIN
                   
                    INSERT
                    INTO
                        AUT_OWNER_USER_BATCH_TMP
                        (
                            SESSION_ID,
                            USER_ID,
                            CREATED_BY,
                            CREATION_DATE,
                            LAST_UPDATED_BY,
                            LAST_UPDATE_DATE
                        )
                        VALUES
                        (
                            ${@session_id},
                            ${@user_id},
                            ${/session/@user_id},
                            sysdate,
                            ${/session/@user_id},
                            sysdate
                        );
                END;
            ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="bp_category"/>
        <bm:field name="extra_nam"/>
        <bm:field name="bp_name"/>
        <bm:field name="unit_name"/>
        <bm:field name="position_desc"/>
        <bm:field name="bp_code"/>
        <bm:field name="user_name" forInsert="false" forUpdate="false"/>
        <bm:field name="employee_name" forInsert="false" forUpdate="false"/>
        <bm:field name="authorized_user_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="employee_code" forInsert="false" forUpdate="false"/>
        <!-- <bm:field name="session_id" databaseType="NUMBER" datatype="java.lang.Long"  physicalName="SESSION_ID" prompt="AUT_OWNER_USER_BATCH_TMP.SESSION_ID"/> -->
        <bm:field name="session_id" databaseType="NUMBER" datatype="java.lang.Long" insertExpression="${/session/@session_id}" physicalName="SESSION_ID" prompt="AUT_OWNER_USER_BATCH_TMP.SESSION_ID"/>
        <bm:field name="user_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="USER_ID" prompt="AUT_OWNER_USER_BATCH_TMP.USER_ID"/>
    </bm:fields>
    <bm:primary-key>
        <bm:pk-field name="session_id"/>
        <bm:pk-field name="user_id"/>
    </bm:primary-key>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <!--  <e:exception-descriptor-config>
        <e:exception-descriptor exception="java.sql.SQLException" handleClass="leaf.database.SQLExceptionDescriptor">
            <e:error-message code="1" message="AUT106.USER_ID_UNIQUE_ERROR"/>
        </e:exception-descriptor>
    </e:exception-descriptor-config> -->
    <bm:query-fields>
        <bm:query-field field="bp_category" queryOperator="like"/>
        <bm:query-field field="extra_nam" queryOperator="like"/>
        <bm:query-field field="bp_name" queryOperator="like"/>
        <bm:query-field field="unit_name" queryOperator="like"/>
        <bm:query-field field="position_desc" queryOperator="like"/>
        <bm:query-field field="bp_code" queryOperator="like"/>
        <bm:query-field field="employee_name" queryOperator="like"/>
    </bm:query-fields>
</bm:model>
