view.xml.ftl 2.8 KB
Newer Older
ibizdev's avatar
ibizdev committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#if sysrun.getPSDBDevInst()??>
    <#assign dbinst = sysrun.getPSDBDevInst()>
    <#assign curdate=.now?string["yyyyMMddHHmmss"]>
</#if>
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
   <#assign sequenceNumber=0>

  <#comment>输出视图信息</#comment>
<#list sys.getAllPSDataEntities() as de>
    <#if de.getStorageMode()==1>
        <#if de.getViewName?? && ((de.getViewName()!'')!='') && de.isSubSysDE()==false && de.isNoViewMode()!=true>
        <#assign sequenceNumber=sequenceNumber+1>
        <#assign deVersion=de.getVersion()?c>
        <#assign deName=de.getName()?lower_case>
        <#if !P.exists("view_",de.getViewName(),"")>
        <!--输出实体[${de.getName()}]视图结构信息 runOnChange="true"  当视图发生变更时,通过liquibase强刷prod的视图,实现视图的同步-->
     <changeSet author="${dbinst.getUserName()}" id="view-${deName}-${deVersion}-${sequenceNumber}" runOnChange="true">
         <createView fullDefinition="false" replaceIfExists="true" viewName="${de.getViewName()}">
            <#if de.getAllPSDEDataQueries?? && de.getAllPSDEDataQueries()??>
                <#assign resultDataQuery = de.getAllPSDEDataQueries()>
                <#list resultDataQuery as singleQuery>
                    <#if singleQuery.getCodeName()?lower_case=='default'>
                        <#if singleQuery.getAllPSDEDataQueryCodes()??>
                            <#assign queryCodeList = singleQuery.getAllPSDEDataQueryCodes()>
                            <#assign sql="">
                            <#comment>遍历数据查询,有oracle则输出,无则输出mysql</#comment>
                            <#list singleQuery.getAllPSDEDataQueryCodes() as dedqcode>
                                <#assign sql=srfjavasqlcode('${dedqcode.getQueryCode()}')>
                                <#assign dbtype=dedqcode.getDBType()?lower_case?replace("mysql5","mysql")>
                                <#if dbtype?lower_case=='oracle'>
                                    <#break>
                                </#if>
                            </#list>
               <![CDATA[ ${sql}]]>
                            <#break>
                        </#if>
                    </#if>
                </#list>
            </#if>
         </createView>
     </changeSet>
            </#if>
        </#if>
    </#if>
</#list>

</databaseChangeLog>