<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:e="leaf.service.exception" xmlns:o="leaf.database.local.oracle" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="ZJ_SYS_NOTIFY_TEMPLATE">
    <bm:fields>
        <bm:field name="notify_template_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="NOTIFY_TEMPLATE_ID"/>
        <bm:field name="notify_template_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="NOTIFY_TEMPLATE_CODE" prompt="模板代码"/>
        <bm:field name="description_id" databaseType="NUMBER" datatype="java.lang.Long" multiLanguage="true" multiLanguageDescField="description" physicalName="DESCRIPTION_ID"/>
        <bm:field name="description" databaseType="VARCHAR2" datatype="java.lang.String" forInsert="false" forUpdate="false" prompt="模板名称"/>
        <bm:field name="message_title" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="MESSAGE_TITLE" prompt="模板主题"/>
        <bm:field name="message_content" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="MESSAGE_CONTENT" prompt="模板内容"/>
        <bm:field name="enabled_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ENABLED_FLAG" prompt="启用"/>
        <bm:field name="workflow_type_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="WORKFLOW_TYPE_ID"/>
        <bm:field name="workflow_type" forInsert="false" forUpdate="false"/>
        <bm:field name="workflow_type_code" forInsert="false" forUpdate="false"/>
        <bm:field name="workflow_type_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="notify_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="NOTIFY_TYPE" prompt="通知类型代码"/>
        <bm:field name="notify_type_desc" forInsert="false" forUpdate="false" prompt="通知类型"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
    			select t1.notify_template_id,
				       t1.notify_template_code,
				       t1.description_id,
				       t1.description,
				       t1.message_title,
				       t1.message_content,
				       t1.enabled_flag,
				       t1.workflow_type_id,
				       t1.workflow_type,
				       t1.workflow_type_code,
				       t1.workflow_type_desc,
				       t1.notify_type,
				       t1.notify_type_desc
				  from zj_sys_notify_template_v t1
				  #WHERE_CLAUSE#
				 order by t1.notify_template_code
    		]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="delete">
            <bm:update-sql><![CDATA[
    			begin
				  DELETE FROM ZJ_SYS_NOTIFY_TEMPLATE t
				   WHERE t.NOTIFY_TEMPLATE_ID = ${@notify_template_id};
				  DELETE FROM ZJ_SYS_NOTIFY_TEMPLATE_LN L
				   WHERE L.NOTIFY_TEMPLATE_ID = ${@notify_template_id};
				end;
    		]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:features>
        <f:standard-who/>
        <f:multi-language-storage/>
        <o:sequence-pk sequenceName="ZJ_SYS_NOTIFY_TEMPLATE_S"/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="notify_template_id"/>
    </bm:primary-key>
    <bm:query-fields>
        <bm:query-field name="usage_type" queryExpression="( (${@usage_type}=&apos;WFL&apos; AND t1.workflow_type_id is not null) or (${@usage_type}=&apos;SYS&apos; AND t1.workflow_type_id is null))"/>
        <bm:query-field field="notify_template_code" queryOperator="like"/>
        <bm:query-field field="description" queryOperator="like"/>
    </bm:query-fields>
    <e:exception-descriptor-config>
        <e:exception-descriptor exception="java.sql.SQLException" handleClass="leaf.database.SQLExceptionDescriptor">
            <e:error-message code="1" message="模板代码${@notify_template_code}已经存在!"/>
        </e:exception-descriptor>
    </e:exception-descriptor-config>
</bm:model>
