<?xml version="1.0" encoding="UTF-8"?>
<ns1:model xmlns:e="leaf.service.exception" xmlns:o="leaf.database.local.oracle" xmlns:ns1="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="fc" baseTable="sys_user">
    <ns1:fields>
        <ns1:field name="user_id" databaseType="BIGINT" datatype="java.lang.Long"/>
        <ns1:field name="user_name" databaseType="VARCHAR" datatype="java.lang.String" prompt="SYS_USER.ACCOUNT"/>
        <ns1:field name="encrypted_foundation_password" databaseType="VARCHAR" datatype="java.lang.String" forSelect="false" insertExpression="sys_login_pkg.md5(${@password})"/>
        <ns1:field name="encrypted_user_password" databaseType="VARCHAR" datatype="java.lang.String" forSelect="false" insertExpression="sys_login_pkg.md5(${@confirm_password})"/>
        <ns1:field name="password_encrypted" databaseType="VARCHAR" datatype="java.lang.String" forSelect="false" insertExpression="sys_login_pkg.md5(${@confirm_password})"/>
        <ns1:field name="start_date" databaseType="DATE" datatype="java.sql.Date" forInsert="true" forUpdate="true" prompt="HAP_START_DATE"/>
        <ns1:field name="end_date" databaseType="DATE" datatype="java.sql.Date" forInsert="true" forUpdate="true" prompt="HAP_END_DATE"/>
        <ns1:field name="last_logon_date" databaseType="DATE" datatype="java.sql.Date" forInsert="true" forUpdate="true"/>
        <ns1:field name="description" databaseType="VARCHAR" datatype="java.lang.String" prompt="SYS_USER.DESCRIPTION"/>
        <ns1:field name="password_lifespan_days" databaseType="BIGINT" datatype="java.lang.Long"/>
        <ns1:field name="password_lifespan_access" databaseType="BIGINT" datatype="java.lang.Long"/>
        <ns1:field name="employee_id" databaseType="BIGINT" datatype="java.lang.Long"/>
        
        <ns1:field name="frozen_flag" databaseType="VARCHAR" datatype="java.lang.String" prompt="SYS_USER.FROZEN_FLAG"/>
        <ns1:field name="frozen_flag_display" databaseType="VARCHAR" datatype="java.lang.String" expression="decode(fc.frozen_flag,&apos;Y&apos;,&apos;已冻结&apos;,&apos;N&apos;,&apos;未冻结&apos;)" forInsert="false" forUpdate="false" prompt="SYS_USER.IS_FROZEN"/>
        <ns1:field name="frozen_date" databaseType="DATE" datatype="java.sql.Date" forInsert="true" forUpdate="true" prompt="SYS_USER.FROZEN_DATE"/>
        <ns1:field name="password_start_date" databaseType="DATE" datatype="java.sql.Date" forInsert="true" forUpdate="true"/>
        <ns1:field name="menu_type" databaseType="VARCHAR" datatype="java.lang.String"/>
        <ns1:field name="bp_category" databaseType="VARCHAR2" datatype="java.lang.String" prompt="SYS_USER.USER_TYPE"/>
        <ns1:field name="bp_category_name" databaseType="VARCHAR2" datatype="java.lang.String" expression="(select scv.code_value_name from sys_code_values_v scv where code=&apos;USER_TYPE&apos; and scv.code_value = fc.bp_category)" forInsert="false" forUpdate="false" prompt="SYS_USER.USER_TYPE"/>
        <ns1:field name="bp_id" databaseType="NUMBER" datatype="java.lang.Long"/>
        <ns1:field name="bp_code" databaseType="VARCHAR2" datatype="java.lang.String" expression="(select hd.bp_code from hls_bp_master hd where fc.bp_id=hd.bp_id)" forInsert="false" forUpdate="false"/>
        <ns1:field name="bp_name" databaseType="VARCHAR2" datatype="java.lang.String" expression="(select hd.bp_name from hls_bp_master hd where fc.bp_id=hd.bp_id)" forInsert="false" forUpdate="false"/>
        <ns1:field name="phone" databaseType="VARCHAR2" datatype="java.lang.String"/>

        <ns1:field name="ad_user_id" databaseType="VARCHAR2" datatype="java.lang.String" expression="(select e.ad_user_id from exp_employees e where e.employee_id=fc.employee_id)" forInsert="false" forUpdate="false"/>
        <ns1:field name="ad_user_name" databaseType="VARCHAR2" datatype="java.lang.String" expression="(select e.ad_user_name from exp_employees e where e.employee_id=fc.employee_id)" forInsert="false" forUpdate="false"/>
        <ns1:field name="email" databaseType="VARCHAR2" datatype="java.lang.String" expression="(select e.email from exp_employees e where e.employee_id=fc.employee_id)" forInsert="false" forUpdate="false"/>
        <ns1:field name="ad_org_unit_id" databaseType="VARCHAR2" datatype="java.lang.String" expression="(select e.ad_org_unit_id from exp_employees e where e.employee_id=fc.employee_id)" forInsert="false" forUpdate="false"/>
    </ns1:fields>
    <ns1:primary-key>
        <ns1:pk-field name="user_id"/>
    </ns1:primary-key>
    <ns1:query-fields>
        <ns1:query-field field="user_id" queryOperator="="/>
        <ns1:query-field field="user_name" queryOperator="like"/>
        <ns1:query-field field="frozen_flag" queryOperator="="/>
    </ns1:query-fields>
    <ns1:features>
        <o:sequence-pk/>
        <f:standard-who/>
    </ns1:features>
    <ns1:ref-fields>
        <ns1:ref-field name="employee_code" prompt="EXP_EMPLOYEE.EMPLOYEE_CODE" relationName="emp" sourceField="employee_code"/>
        <ns1:ref-field name="emp_name" prompt="EXP_EMPLOYEE.NAME" relationName="emp" sourceField="name"/>
    </ns1:ref-fields>
    <ns1:relations>
        <ns1:relation name="emp" joinType="LEFT OUTER" refModel="exp.exp_employees">
            <ns1:reference foreignField="employee_id" localField="employee_id"/>
        </ns1:relation>
    </ns1:relations>
    <e:exception-descriptor-config>
        <e:exception-descriptor exception="java.sql.SQLException" handleClass="leaf.database.SQLExceptionDescriptor">
            <e:error-message code="1" message="SYS_USER.ACCOUNT_DISTICNT"/>
        </e:exception-descriptor>
    </e:exception-descriptor-config>
</ns1:model>
