<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author:   HAND技术
    $Date:     2013/12/12
    $Revision: 1.0
    $Purpose:  汽车车型
-->
<bm:model xmlns:o="leaf.database.local.oracle" xmlns:e="leaf.service.exception" xmlns:f="leaf.database.features" xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="v" baseTable="HLS_CAR_MODEL">
    <bm:fields>
        <bm:field name="model_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="MODEL_ID"/>
        <bm:field name="brand_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BRAND_ID"/>
        <bm:field name="series_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SERIES_ID"/>
        <bm:field name="model_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="MODEL_CODE" prompt="HLS_CAR_MODEL.BRAND_CODE"/>
        <bm:field name="description" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION" prompt="HLS_CAR_MODEL.DESCRIPTION"/>
        <bm:field name="enabled_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ENABLED_FLAG" prompt="HLS.ENABLED_FLAG"/>
        <bm:field name="price" databaseType="NUMBER" datatype="java.lang.Double" physicalName="PRICE"/>
        <bm:field name="exceed_price_flag" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="plate_name"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
				select v.brand_id,
				       v.series_id,
				       v.model_id,
				       v.model_code,
				       v.description,
				       v.enabled_flag,
				       v.price,
				       v.exceed_price_flag,
				       v.plate_name
				  from hls_car_model_vl v
				  #WHERE_CLAUSE#
				 order by v.model_code
    		]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="insert">
            <bm:parameters>
                <bm:parameter name="model_id" input="false" output="true" outputPath="@model_id"/>
            </bm:parameters>
            <bm:update-sql><![CDATA[
        		begin
				  HLS222_SAVE_PKG.model_manage(p_sql_type		=> 'INSERT',
				  							     p_brand_id     => ${@brand_id},
				  							     p_series_id    => ${@series_id},
				  							     p_model_id     => ${@model_id},
								                 p_model_code   => ${@model_code},
								                 p_description  => ${@description},
								                 p_enabled_flag => ${@enabled_flag},
								                 p_user_id      => ${/session/@user_id},
								                 p_price		=> ${@price},
								                 p_exceed_price_flag => ${@exceed_price_flag},
								                 p_plate_name   => ${@plate_name});
				end;
        	]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
        		begin
				  HLS222_SAVE_PKG.model_manage(p_sql_type		=> 'UPDATE',
				  							     p_brand_id     => ${@brand_id},
				  							     p_series_id    => ${@series_id},
				  							     p_model_id     => ${@model_id},
								                 p_model_code   => ${@model_code},
								                 p_description  => ${@description},
								                 p_enabled_flag => ${@enabled_flag},
								                 p_user_id      => ${/session/@user_id},
								                 p_price		=> ${@price},
								                 p_exceed_price_flag => ${@exceed_price_flag},
								                 p_plate_name   => ${@plate_name});
				end;
        	]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="delete">
            <bm:update-sql><![CDATA[
        		begin
				  HLS222_SAVE_PKG.model_manage(p_sql_type		=> 'DELETE',
				  							     p_brand_id     => ${@brand_id},
				  							     p_series_id    => ${@series_id},
				  							     p_model_id     => ${@model_id},
								                 p_model_code   => ${@model_code},
								                 p_description  => ${@description},
								                 p_enabled_flag => ${@enabled_flag},
								                 p_user_id      => ${/session/@user_id},
								                 p_price		=> ${@price},
								                 p_exceed_price_flag => ${@exceed_price_flag});
				end;
        	]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:data-filters>
        <bm:data-filter name="brand_id" enforceOperations="query" expression="v.brand_id=${@brand_id}"/>
        <bm:data-filter name="series_id" enforceOperations="query" expression="v.series_id=${@series_id}"/>
    </bm:data-filters>
    <bm:query-fields>
        <bm:query-field name="series_id" queryExpression="v.series_id=${@series_id}"/>
        <bm:query-field name="model_id" queryExpression="v.model_id=${@model_id}"/>
    </bm:query-fields>
    <bm:features>
        <f:standard-who/>
        <o:sequence-pk/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="model_id"/>
    </bm:primary-key>
    <e:exception-descriptor-config>
        <e:exception-descriptor exception="java.sql.SQLException" handleClass="leaf.database.SQLExceptionDescriptor">
            <e:error-message code="1" message="同一品牌车系下车型重复"/>
        </e:exception-descriptor>
    </e:exception-descriptor-config>
</bm:model>
