%DE_PKGPATH%-service-base.ts.ftl 45.5 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
<#ibiztemplate>
TARGET=PSAPPDATAENTITY
</#ibiztemplate>
import { Http,Util } from '@/utils';
import EntityService from '../entity-service';
<#if item.getAllPSAppDELogics()??>
<#list item.getAllPSAppDELogics() as singleLogic>
<#if !P.exists("importService", singleLogic.getId(), "")>
<#if singleLogic.getLogicHolder() == 2 || singleLogic.getLogicHolder() == 3>
import ${srfclassname('${singleLogic.getCodeName()}')}Logic from '@/service/${srffilepath2(singleLogic.getPSAppDataEntity().getCodeName())}/${srffilepath2(singleLogic.getCodeName())}-logic';
</#if>
</#if>
</#list>
</#if>

<#-- 设置本地缓存 -->
<#macro setStore appEntity>
        <#if appEntity.getMajorPSAppDERSs()??>
        <#list appEntity.getMajorPSAppDERSs() as deReRs>
        <#-- 主实体 -->
        <#assign majorPSAppDataEntity = deReRs.getMajorPSAppDataEntity() />
        <#-- 从实体 -->
        <#assign minorPSAppDataEntity = deReRs.getMinorPSAppDataEntity() />
24 25 26 27
        <#-- 从实体支持临时数据模式为true,才设置本地缓存 start -->
        <#-- @author zpc -->
        <#-- @update 2020.7.13 15:00 -->
        <#if minorPSAppDataEntity.isEnableTempData()>
28
            this.tempStorage.setItem(context.srfsessionkey+'_${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}',JSON.stringify(res.data.${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}?res.data.${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}:[]));
29 30
        </#if>
        <#-- 从实体支持临时数据模式为true,才设置本地缓存 end -->
ibizdev's avatar
ibizdev committed
31 32 33 34 35 36 37 38 39 40 41 42
        </#list>
        </#if>
</#macro>

<#-- 获取本地缓存 -->
<#macro getStore appEntity>
        <#if appEntity.getMajorPSAppDERSs()??>
        <#list appEntity.getMajorPSAppDERSs() as deReRs>
        <#-- 主实体 -->
        <#assign majorPSAppDataEntity = deReRs.getMajorPSAppDataEntity() />
        <#-- 从实体 -->
        <#assign minorPSAppDataEntity = deReRs.getMinorPSAppDataEntity() />
43 44 45 46
        <#-- 从实体支持临时数据模式为true,才从前端缓存拿取数据,组装数据给后台 start -->
        <#-- @author zpc -->
        <#-- @update 2020.7.13 15:00 -->
        <#if minorPSAppDataEntity.isEnableTempData()>
ibizdev's avatar
ibizdev committed
47 48 49 50 51 52 53 54
        let ${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}Data:any = [];
        if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}'),'undefined')){
            ${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}Data = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}') as any);
            if(${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}Data && ${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}Data.length && ${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}Data.length > 0){
                ${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}Data.forEach((item:any) => {
                    if(item.srffrontuf){
                        if(Object.is(item.srffrontuf,"0")){
                            item.${minorPSAppDataEntity.getKeyPSAppDEField().getCodeName()?lower_case} = null;
tony001's avatar
tony001 committed
55 56
                            <#-- 置空父键 -->
                            if(item.hasOwnProperty('${majorPSAppDataEntity.getKeyPSAppDEField().getCodeName()?lower_case}') && item.${majorPSAppDataEntity.getKeyPSAppDEField().getCodeName()?lower_case}) item.${majorPSAppDataEntity.getKeyPSAppDEField().getCodeName()?lower_case} = null;
ibizdev's avatar
ibizdev committed
57 58 59 60 61 62 63
                        }
                        delete item.srffrontuf;
                    }
                });
            }
        }
        masterData.${srfpluralize(minorPSAppDataEntity.codeName)?lower_case} = ${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}Data;
64 65
        </#if>
        <#-- 从实体支持临时数据模式为true,才从前端缓存拿取数据,组装数据给后台 end -->
ibizdev's avatar
ibizdev committed
66 67 68 69
        </#list>
        </#if>
</#macro>

tony001's avatar
tony001 committed
70
<#-- 本地供数satrt -->
71
<#macro local_supply item singleAppMethod>
tony001's avatar
tony001 committed
72
<#if singleAppMethod.getPredefinedType?? && singleAppMethod.getPredefinedType()??>
73
<#-- 预定义类型为索引实体start -->
tony001's avatar
tony001 committed
74 75 76
<#if singleAppMethod.getPredefinedType() == "INDEXDE">
<#if singleAppMethod.getPSAppCodeList?? && singleAppMethod.getPSAppCodeList()??>
<#assign appCodeList = singleAppMethod.getPSAppCodeList() />
77 78 79 80 81 82 83 84 85 86
        let codelistModel:any = {tag:'${appCodeList.codeName}',codelistType:'${appCodeList.getCodeListType()}'};
        let res:any = await this.getCodeList(codelistModel.tag,codelistModel.codelistType,context,data);
        if(res && res.length > 0){
            res.forEach((ele:any) => {
                // 仿真返回数据集
                ele.${item.getKeyPSAppDEField().getCodeName()?lower_case} = ele.value;
                ele.${item.getMajorPSAppDEField().getCodeName()?lower_case} = ele.text
            });
        } 
        return {status:200,data:res};
tony001's avatar
tony001 committed
87
</#if>
tony001's avatar
tony001 committed
88 89
<#else>
        <@service_block item=item singleAppMethod=singleAppMethod />
tony001's avatar
tony001 committed
90
</#if>
91
<#-- 预定义类型为索引实体end -->
tony001's avatar
tony001 committed
92 93 94 95
</#if>
</#macro>
<#-- 本地供数end -->

96 97 98
<#-- 检查行为是否可以执行 start -->
<#-- @author zpc -->
<#-- @update 2020.7.13 18:00 -->
99 100
<#-- 获取测试行为的修饰符和名称 start -->
<#macro getTestActionModifier appdeAction>
101
<#compress>
102
<#if appdeAction.getTestActionMode() == 1>private</#if><#if appdeAction.getTestActionMode() == 3>public</#if>
103
</#compress>
104 105 106
</#macro>
<#-- 获取测试行为的修饰符和名称 end -->

ibizdev's avatar
ibizdev committed
107
<#-- 定义service_block start -->
108
<#macro service_block item singleAppMethod afterActionStr = "">
tony001's avatar
tony001 committed
109 110
 <#if item.getPSAppDERSPathCount() gt 0 && singleAppMethod.getPSDEServiceAPIMethod?? &&  singleAppMethod.getPSDEServiceAPIMethod()??>
    <#assign singleServiceApi = singleAppMethod.getPSDEServiceAPIMethod()/>
ibizdev's avatar
ibizdev committed
111 112 113 114 115 116 117 118 119 120 121 122 123 124
    <#list 1..item.getPSAppDERSPathCount() as count>
        <#assign path = ''/>
        <#assign condition = ''/>
        <#list item.getPSAppDERSPath(count_index)  as deRSPath>
            <#if deRSPath.getMajorPSAppDataEntity?? && deRSPath.getMajorPSAppDataEntity()??>
                <#assign _dataEntity = deRSPath.getMajorPSAppDataEntity()/>
                <#assign condition>${condition}context.${_dataEntity.getCodeName()?lower_case} && </#assign>
                <#assign path>${path}${srfpluralize(_dataEntity.codeName)?lower_case}/<#noparse>$</#noparse>{context.${_dataEntity.getCodeName()?lower_case}}/</#assign>
            </#if>
        </#list>
        <#-- 方法类型为SELECT -->
        <#if singleAppMethod.getMethodType() == "SELECT">
        if(${condition}context.${item.getCodeName()?lower_case}){
            <#if singleServiceApi.getRequestMethod() == 'PUT' ||  singleServiceApi.getRequestMethod() == 'POST'>
tony001's avatar
tony001 committed
125
            let res:any = Http.getInstance().${singleServiceApi.getRequestMethod()?lower_case}(`/${path}${srfpluralize(item.codeName)?lower_case}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,data,isloading);
ibizdev's avatar
ibizdev committed
126
            <#else>
tony001's avatar
tony001 committed
127
            let res:any = Http.getInstance().${singleServiceApi.getRequestMethod()?lower_case}(`/${path}${srfpluralize(item.codeName)?lower_case}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,isloading);
tony001's avatar
tony001 committed
128
            </#if><#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
tony001's avatar
tony001 committed
129
            return res;
ibizdev's avatar
ibizdev committed
130 131 132 133 134
        }
        <#-- 方法类型为FETCH -->
        <#elseif singleAppMethod.getMethodType() == "FETCH">
        if(${condition}true){
            let tempData:any = JSON.parse(JSON.stringify(data));
135
            let res:any = Http.getInstance().${singleServiceApi.getRequestMethod()?lower_case}(`/${path}${srfpluralize(item.codeName)?lower_case}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,tempData,isloading);<#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
tony001's avatar
tony001 committed
136
            return res;
ibizdev's avatar
ibizdev committed
137 138 139 140
        }
        <#-- 方法类型为FETCHTEMP -->
        <#elseif singleAppMethod.getMethodType() == "FETCHTEMP">
        if(${condition}true){
141
            let res:any = Http.getInstance().${singleServiceApi.getRequestMethod()?lower_case}(`/${path}${srfpluralize(item.codeName)?lower_case}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,data,isloading);<#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
tony001's avatar
tony001 committed
142
            return res;
ibizdev's avatar
ibizdev committed
143 144 145 146 147 148
        }
        <#else>
        <#-- 方法类型为DEACTION start -->
            <#if singleServiceApi.getRequestParamType() == "NONE">
            <#-- 无参数情况start -->
        if(${condition}true){
149 150
            let res:any = await Http.getInstance().${singleServiceApi.getRequestMethod()?lower_case}(`/${path}${srfpluralize(item.codeName)?lower_case}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,isloading);
            res.data.${item.getCodeName()?lower_case} = data.${item.getCodeName()?lower_case};
tony001's avatar
tony001 committed
151
            <@setStore appEntity=item /><#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
152
            return res;
ibizdev's avatar
ibizdev committed
153 154 155 156 157
        }
            <#-- 无参数情况end -->
            <#elseif singleServiceApi.getRequestParamType() == "FIELD">
            <#-- 指定属性情况start -->
        if(${condition}context.${item.getCodeName()?lower_case}){
158 159 160 161
            <#-- 指定属性情况start -->
            <#-- GET -->
            <#if singleServiceApi.getRequestMethod() == "GET">
            let res:any = await Http.getInstance().${singleServiceApi.getRequestMethod()?lower_case}(`/${path}${srfpluralize(item.codeName)?lower_case}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,isloading);
tony001's avatar
tony001 committed
162
            <@setStore appEntity=item /><#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
163
            return res;
164
            <#elseif singleServiceApi.getRequestMethod() == "POST">
tony001's avatar
tony001 committed
165
            let res:any = Http.getInstance().${singleServiceApi.getRequestMethod()?lower_case}(`/${path}${srfpluralize(item.codeName)?lower_case}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,data,isloading);<#if afterActionStr?? && afterActionStr !="" >
166
            ${afterActionStr}</#if>
tony001's avatar
tony001 committed
167
            return res;
168
            <#else>
tony001's avatar
tony001 committed
169
            let res:any = Http.getInstance().${singleServiceApi.getRequestMethod()?lower_case}(`/${path}${srfpluralize(item.codeName)?lower_case}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,isloading);<#if afterActionStr?? && afterActionStr !="" >
170
            ${afterActionStr}</#if>
tony001's avatar
tony001 committed
171
            return res;
172 173
            </#if>
            <#-- 指定属性情况end -->
ibizdev's avatar
ibizdev committed
174 175 176 177 178 179
        }
            <#-- 指定属性情况start -->
            <#elseif singleServiceApi.getRequestParamType() == "ENTITY">
            <#-- 提交对象数据情况start -->
            <#if singleAppMethod.getCodeName() == 'Create'>
        if(${condition}true){
180 181 182
            let masterData:any = {};
            <@getStore appEntity=item />
            Object.assign(data,masterData);
ibizdev's avatar
ibizdev committed
183 184 185 186 187 188
            if(!data.srffrontuf || data.srffrontuf !== "1"){
                data[this.APPDEKEY] = null;
            }
            if(data.srffrontuf){
                delete data.srffrontuf;
            }
189 190 191 192 193 194 195 196
            let tempContext:any = JSON.parse(JSON.stringify(context));
            let res:any = await Http.getInstance().${singleServiceApi.getRequestMethod()?lower_case}(`/${path}${srfpluralize(item.codeName)?lower_case}`,data,isloading);
            <#if item.getMajorPSAppDERSs()??>
            <#list item.getMajorPSAppDERSs() as deReRs>
            <#-- 主实体 -->
            <#assign majorPSAppDataEntity = deReRs.getMajorPSAppDataEntity() />
            <#-- 从实体 -->
            <#assign minorPSAppDataEntity = deReRs.getMinorPSAppDataEntity() />
197
            this.tempStorage.setItem(tempContext.srfsessionkey+'_${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}',JSON.stringify(res.data.${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}?res.data.${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}:[]));
198
            </#list>
tony001's avatar
tony001 committed
199
            </#if><#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
200
            return res;
ibizdev's avatar
ibizdev committed
201 202 203
        }
            <#else>
        if(${condition}context.${item.getCodeName()?lower_case}){
204 205 206 207
            let masterData:any = {};
            <@getStore appEntity=item />
            Object.assign(data,masterData);
            let res:any = await Http.getInstance().${singleServiceApi.getRequestMethod()?lower_case}(`/${path}${srfpluralize(item.codeName)?lower_case}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,data,isloading);
tony001's avatar
tony001 committed
208
            <@setStore appEntity=item /><#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
209
            return res;
ibizdev's avatar
ibizdev committed
210 211
        }
            </#if>
212
            <#-- 提交对象数据情况end -->
ibizdev's avatar
ibizdev committed
213 214 215 216 217 218 219 220 221
            <#else>
            <#-- URI参数传递情况start -->
        // URI参数传递情况未实现
            <#-- URI参数传递情况start -->
            </#if>
         <#-- 方法类型为DEACTION end -->
        </#if>
    </#list>
    </#if>
tony001's avatar
tony001 committed
222 223
    <#if item.isMajor() && singleAppMethod.getPSDEServiceAPIMethod?? &&  singleAppMethod.getPSDEServiceAPIMethod()??>
        <#assign singleServiceApi = singleAppMethod.getPSDEServiceAPIMethod()/>
ibizdev's avatar
ibizdev committed
224 225 226 227
        <#-- 方法类型为SELECT -->
        <#if singleAppMethod.getMethodType() == "SELECT">
        <#--  if(context.${item.getCodeName()?lower_case}){  -->
            <#if singleServiceApi.getRequestMethod() == 'PUT' ||  singleServiceApi.getRequestMethod() == 'POST'>
tony001's avatar
tony001 committed
228
            let res:any = Http.getInstance().${singleServiceApi.getRequestMethod()?lower_case}(`/${srfpluralize(item.codeName)?lower_case}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,data,isloading);
ibizdev's avatar
ibizdev committed
229
            <#else>
tony001's avatar
tony001 committed
230
            let res:any = Http.getInstance().${singleServiceApi.getRequestMethod()?lower_case}(`/${srfpluralize(item.codeName)?lower_case}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,isloading);
tony001's avatar
tony001 committed
231
            </#if><#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
tony001's avatar
tony001 committed
232
            return res;
ibizdev's avatar
ibizdev committed
233 234 235 236
        <#--  }  -->
        <#-- 方法类型为FETCH -->
        <#elseif singleAppMethod.getMethodType() == "FETCH">
        let tempData:any = JSON.parse(JSON.stringify(data));
237
        let res:any = Http.getInstance().${singleServiceApi.getRequestMethod()?lower_case}(`/${srfpluralize(item.codeName)?lower_case}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,tempData,isloading);<#if afterActionStr?? && afterActionStr !="" >
238
        ${afterActionStr}</#if>
tony001's avatar
tony001 committed
239
        return res;
ibizdev's avatar
ibizdev committed
240 241
        <#-- 方法类型为FETCHTEMP -->
        <#elseif singleAppMethod.getMethodType() == "FETCHTEMP">
242
        let res:any =  Http.getInstance().${singleServiceApi.getRequestMethod()?lower_case}(`/${srfpluralize(item.codeName)?lower_case}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,data,isloading);<#if afterActionStr?? && afterActionStr !="" >
243
        ${afterActionStr}</#if>
tony001's avatar
tony001 committed
244
        return res;
ibizdev's avatar
ibizdev committed
245 246 247 248 249 250
        <#else>
        <#-- 方法类型为DEACTION start -->
            <#if singleServiceApi.getRequestParamType() == "NONE">
        <#-- 无参数情况start -->
        let res:any = await  Http.getInstance().${singleServiceApi.getRequestMethod()?lower_case}(`/${srfpluralize(item.codeName)?lower_case}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,isloading);
        res.data.${item.getCodeName()?lower_case} = data.${item.getCodeName()?lower_case};
tony001's avatar
tony001 committed
251
        <@setStore appEntity=item /><#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
252
        return res;
ibizdev's avatar
ibizdev committed
253 254 255 256 257 258
            <#-- 无参数情况end -->
            <#elseif singleServiceApi.getRequestParamType() == "FIELD">
            <#-- 指定属性情况start -->
            <#-- GET -->
            <#if singleServiceApi.getRequestMethod() == "GET">
        <#--  if(context.${item.getCodeName()?lower_case}){  -->
259
            let res:any = await Http.getInstance().${singleServiceApi.getRequestMethod()?lower_case}(`/${srfpluralize(item.codeName)?lower_case}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,isloading);
tony001's avatar
tony001 committed
260
            <@setStore appEntity=item /><#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
261
            return res;
ibizdev's avatar
ibizdev committed
262 263 264 265
        <#--  }  -->
            <#elseif singleServiceApi.getRequestMethod() == "POST">
            <#-- REMOVE -->
        <#--  if(context.${item.getCodeName()?lower_case}){  -->
tony001's avatar
tony001 committed
266
            let res:any = Http.getInstance().${singleServiceApi.getRequestMethod()?lower_case}(`/${srfpluralize(item.codeName)?lower_case}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,data,isloading);<#if afterActionStr?? && afterActionStr !="" >
267
            ${afterActionStr}</#if>
tony001's avatar
tony001 committed
268
            return res;
ibizdev's avatar
ibizdev committed
269 270 271
        <#--  }    -->
            <#else>
        <#--  if(context.${item.getCodeName()?lower_case}){  -->
tony001's avatar
tony001 committed
272
            let res:any = Http.getInstance().${singleServiceApi.getRequestMethod()?lower_case}(`/${srfpluralize(item.codeName)?lower_case}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,isloading);<#if afterActionStr?? && afterActionStr !="" >
273
            ${afterActionStr}</#if>
tony001's avatar
tony001 committed
274
            return res;
ibizdev's avatar
ibizdev committed
275 276
        <#--  }     -->
            </#if>
277
            <#-- 指定属性情况end -->
ibizdev's avatar
ibizdev committed
278 279 280 281 282 283 284 285
            <#elseif singleServiceApi.getRequestParamType() == "ENTITY">
            <#-- 提交对象数据情况start -->
        <#if singleAppMethod.getCodeName() == 'Update'>
        let masterData:any = {};
        <@getStore appEntity=item />
        Object.assign(data,masterData);
        <#--  if(context.${item.getCodeName()?lower_case}){  -->
            let res:any = await  Http.getInstance().${singleServiceApi.getRequestMethod()?lower_case}(`/${srfpluralize(item.codeName)?lower_case}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,data,isloading);
tony001's avatar
tony001 committed
286
            <@setStore appEntity=item /><#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
287
            return res;
ibizdev's avatar
ibizdev committed
288 289 290 291 292 293 294
        <#--  }  -->
        <#elseif singleAppMethod.getCodeName() == 'Save'>
        let masterData:any = {};
        <@getStore appEntity=item />
        Object.assign(data,masterData);
        <#--  if(context.${item.getCodeName()?lower_case}){  -->
            let res:any = await  Http.getInstance().${singleServiceApi.getRequestMethod()?lower_case}(`/${srfpluralize(item.codeName)?lower_case}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,data,isloading);
tony001's avatar
tony001 committed
295
            <@setStore appEntity=item /><#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
296
            return res;
ibizdev's avatar
ibizdev committed
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
        <#--  }  -->
        <#elseif singleAppMethod.getCodeName() == 'Create'>
        let masterData:any = {};
        <@getStore appEntity=item />
        Object.assign(data,masterData);
        if(!data.srffrontuf || data.srffrontuf !== "1"){
            data[this.APPDEKEY] = null;
        }
        if(data.srffrontuf){
            delete data.srffrontuf;
        }
        let tempContext:any = JSON.parse(JSON.stringify(context));
        let res:any = await Http.getInstance().${singleServiceApi.getRequestMethod()?lower_case}(`/${srfpluralize(item.codeName)?lower_case}`,data,isloading);
        <#if item.getMajorPSAppDERSs()??>
        <#list item.getMajorPSAppDERSs() as deReRs>
        <#-- 主实体 -->
        <#assign majorPSAppDataEntity = deReRs.getMajorPSAppDataEntity() />
        <#-- 从实体 -->
        <#assign minorPSAppDataEntity = deReRs.getMinorPSAppDataEntity() />
316
        this.tempStorage.setItem(tempContext.srfsessionkey+'_${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}',JSON.stringify(res.data.${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}?res.data.${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}:[]));
ibizdev's avatar
ibizdev committed
317
        </#list>
tony001's avatar
tony001 committed
318
        </#if><#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
319
        return res;
ibizdev's avatar
ibizdev committed
320 321
        <#else>
        <#--  if(context.${item.getCodeName()?lower_case}){  -->
tony001's avatar
tony001 committed
322
            let res:any = Http.getInstance().${singleServiceApi.getRequestMethod()?lower_case}(`/${srfpluralize(item.codeName)?lower_case}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,data,isloading);<#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
tony001's avatar
tony001 committed
323
            return res;
ibizdev's avatar
ibizdev committed
324 325
        <#--  }  -->
        </#if>
326
            <#-- 提交对象数据情况end -->
ibizdev's avatar
ibizdev committed
327 328 329 330 331 332 333 334 335
            <#else>
            <#-- URI参数传递情况start -->
        // URI参数传递情况未实现
            <#-- URI参数传递情况start -->
            </#if>
         <#-- 方法类型为DEACTION end -->
        </#if>
    </#if>
    <#-- 嵌套成员 -->
tony001's avatar
tony001 committed
336
    <#if item.isMajor() == false && !(singleAppMethod.getPSDEServiceAPIMethod?? &&  singleAppMethod.getPSDEServiceAPIMethod()??)>
ibizdev's avatar
ibizdev committed
337 338 339 340 341 342 343 344 345 346 347
     <#if singleAppMethod.getMethodType() == "SELECT">
        // ${singleAppMethod.getCodeName()} ---SELECT
        <#-- 方法类型为FETCH -->
     <#elseif singleAppMethod.getMethodType() == "FETCH">
        // ${singleAppMethod.getCodeName()} ---FETCH
        <#if item.getMinorPSAppDERSs()??>
        <#list item.getMinorPSAppDERSs() as singleDeRs>
        <#assign majorEntity = singleDeRs.getMajorPSAppDataEntity()/>
        if(context.srfsessionkey && !Object.is(this.tempStorage.getItem(context.srfsessionkey+'_${srfpluralize(item.codeName)?lower_case}'),'undefined')){
            let result:any = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_${srfpluralize(item.codeName)?lower_case}') as any);
            if(result){
348
                return {"status":200,"data":result};
ibizdev's avatar
ibizdev committed
349
            }else{
350
                return {"status":200,"data":[]};
ibizdev's avatar
ibizdev committed
351 352
            } 
        }else{
353
            return {"status":200,"data":[]};
ibizdev's avatar
ibizdev committed
354 355 356 357 358 359 360 361 362 363 364 365
        }
        </#list>
        </#if>
        <#-- 方法类型为FETCH -->
     <#elseif singleAppMethod.getMethodType() == "FETCHTEMP">
        // ${singleAppMethod.getCodeName()} ---FETCHTEMP
        <#if item.getMinorPSAppDERSs()??>
        <#list item.getMinorPSAppDERSs() as singleDeRs>
        <#assign majorEntity = singleDeRs.getMajorPSAppDataEntity()/>
        if(context.srfsessionkey && !Object.is(this.tempStorage.getItem(context.srfsessionkey+'_${srfpluralize(item.codeName)?lower_case}'),'undefined')){
            let result:any = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_${srfpluralize(item.codeName)?lower_case}') as any);
            if(result){
366
                return {"status":200,"data":result};
ibizdev's avatar
ibizdev committed
367
            }else{
368
                return {"status":200,"data":[]};
ibizdev's avatar
ibizdev committed
369 370
            } 
        }else{
371
            return {"status":200,"data":[]};
ibizdev's avatar
ibizdev committed
372 373 374 375 376 377 378 379 380 381 382 383 384 385
        }
        </#list>
        </#if>
     <#else>
        <#if singleAppMethod.getCodeName() == "Save">
        // 从实体Save 行为暂未实现
        <#elseif singleAppMethod.getCodeName() == "Remove">
        <#if item.getMinorPSAppDERSs()??>
        <#list item.getMinorPSAppDERSs() as singleDeRs>
        <#assign majorEntity = singleDeRs.getMajorPSAppDataEntity()/>
        if(context.srfsessionkey && !Object.is(this.tempStorage.getItem(context.srfsessionkey+'_${srfpluralize(item.codeName)?lower_case}'),'undefined')){
            let result:any = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_${srfpluralize(item.codeName)?lower_case}') as any);
            if(result){
                let tempResult:any = result.filter((item:any) =>{
386
                    return !Object.is(item.${item.getCodeName()?lower_case},data.${item.getCodeName()?lower_case});
ibizdev's avatar
ibizdev committed
387 388
                })
                this.tempStorage.setItem(context.srfsessionkey+'_${srfpluralize(item.codeName)?lower_case}',JSON.stringify(tempResult));
389
                 return {"status":200,"data":data};
ibizdev's avatar
ibizdev committed
390
            }else{
391
                return {"status":500,"data":null};
ibizdev's avatar
ibizdev committed
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
            } 
        }
        </#list>
        </#if>
        <#elseif singleAppMethod.getCodeName() == "Update">
        <#if item.getMinorPSAppDERSs()??>
        <#list item.getMinorPSAppDERSs() as singleDeRs>
        <#assign majorEntity = singleDeRs.getMajorPSAppDataEntity()/>
        if(context.srfsessionkey && !Object.is(this.tempStorage.getItem(context.srfsessionkey+'_${srfpluralize(item.codeName)?lower_case}'),'undefined')){
            let result:any = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_${srfpluralize(item.codeName)?lower_case}') as any);
            let tempData:Array<any> = [];
            if(result && result.length >0){
                result.forEach((item:any) => {
                    let singleData:any = {};
                    if(Object.is(item.${item.getCodeName()?lower_case},data.${item.getCodeName()?lower_case})){
                        Object.keys(item).forEach((field:any) =>{
                            singleData[field] = data[field]?data[field]:item[field];
                        })
                    }
                    if(Object.keys(singleData).length >0){
                        tempData.push(singleData);
                    }else{
                        tempData.push(item);
                    }  
                });
                this.tempStorage.setItem(context.srfsessionkey+'_${srfpluralize(item.codeName)?lower_case}',JSON.stringify(tempData));
418
                return {"status":200,"data":data};
ibizdev's avatar
ibizdev committed
419
            }else{
420
                return {"status":500,"data":null};
ibizdev's avatar
ibizdev committed
421 422 423 424 425 426 427 428 429 430 431 432
            }
        }
        </#list>
        </#if>
        <#elseif singleAppMethod.getCodeName() == "GetDraft">
        let tempData = {${item.getCodeName()?lower_case}:data.${item.getCodeName()?lower_case},srfsessionkey:context.srfsessionkey};
        <#if item.getMinorPSAppDERSs()??>
        <#list item.getMinorPSAppDERSs() as singleDeRs>
        <#assign majorEntity = singleDeRs.getMajorPSAppDataEntity()/>
        Object.assign(tempData,{${majorEntity.getCodeName()?lower_case}:data.${majorEntity.getCodeName()?lower_case}});
        </#list>
        </#if>
433
        return {"status":200,"data":tempData}; 
ibizdev's avatar
ibizdev committed
434 435 436 437
        <#elseif singleAppMethod.getCodeName() == "Create">
        <#if item.getMinorPSAppDERSs()??>
        <#list item.getMinorPSAppDERSs() as singleDeRs>
        <#assign majorEntity = singleDeRs.getMajorPSAppDataEntity()/>
438
         if(context.srfsessionkey && !Object.is(this.tempStorage.getItem(context.srfsessionkey+'_${srfpluralize(item.codeName)?lower_case}'),'undefined')){
ibizdev's avatar
ibizdev committed
439 440 441 442 443 444 445 446 447
            let ${srfpluralize(item.codeName)?lower_case}:any = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_${srfpluralize(item.codeName)?lower_case}') as any);
            if(!data.srffrontuf || data.srffrontuf !== "1"){
                data[this.APPDEKEY] = null;
            }
            if(data.srffrontuf){
                delete data.srffrontuf;
            }
            ${srfpluralize(item.codeName)?lower_case}.push(data);
            this.tempStorage.setItem(context.srfsessionkey+'_${srfpluralize(item.codeName)?lower_case}',JSON.stringify(${srfpluralize(item.codeName)?lower_case}));
448
            return {"status":200,"data":data};
ibizdev's avatar
ibizdev committed
449
        }else{
450
            return {"status":200,"data":{}};
ibizdev's avatar
ibizdev committed
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466
        }
        </#list>
        </#if>
        <#elseif singleAppMethod.getCodeName() == "CheckKey">
        <#if item.getMinorPSAppDERSs()??>
        <#list item.getMinorPSAppDERSs() as singleDeRs>
        <#assign majorEntity = singleDeRs.getMajorPSAppDataEntity()/>
        if(context.srfsessionkey && !Object.is(this.tempStorage.getItem(context.srfsessionkey+'_${srfpluralize(item.codeName)?lower_case}'),'undefined')){
            let result:any = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_${srfpluralize(item.codeName)?lower_case}') as any);
            if(result){
               let flag:boolean = false;
                result.forEach((item:any) => {
                    if(Object.is(item.${item.getCodeName()?lower_case},data.${item.getCodeName()?lower_case})){
                        flag = true;
                    }
                });
467
                return {"status":200,"data":flag};
ibizdev's avatar
ibizdev committed
468
            }else{
469
                return {"status":500,"data":null};
ibizdev's avatar
ibizdev committed
470 471 472 473 474 475 476 477 478 479 480 481
            } 
        }
        </#list>
        </#if>
        <#elseif singleAppMethod.getCodeName() == "Get">
        <#if item.getMinorPSAppDERSs()??>
        <#list item.getMinorPSAppDERSs() as singleDeRs>
        <#assign majorEntity = singleDeRs.getMajorPSAppDataEntity()/>
        if(context.srfsessionkey && !Object.is(this.tempStorage.getItem(context.srfsessionkey+'_${srfpluralize(item.codeName)?lower_case}'),'undefined')){
            let result:any = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_${srfpluralize(item.codeName)?lower_case}') as any);
            if(result){
                let tempResult:any = result.filter((item:any) =>{
482
                    return Object.is(item.${item.getCodeName()?lower_case},data.${item.getCodeName()?lower_case});
ibizdev's avatar
ibizdev committed
483 484
                })
                let tempResultData:any = tempResult.length>0?tempResult[0]:Object.assign({},data);
485
                return {"status":200,"data":tempResultData};
ibizdev's avatar
ibizdev committed
486
            }else{
487
                return {"status":500,"data":null};
ibizdev's avatar
ibizdev committed
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502
            } 
        }
        </#list>
        </#if>
        <#else>
            <#list 1..item.getPSAppDERSPathCount() as count>
                <#assign path = ''/>
                <#assign condition = ''/>
                <#list item.getPSAppDERSPath(count_index)  as deRSPath>
                    <#if deRSPath.getMajorPSAppDataEntity?? && deRSPath.getMajorPSAppDataEntity()??>
                        <#assign _dataEntity = deRSPath.getMajorPSAppDataEntity()/>
                        <#assign condition>${condition}context.${_dataEntity.getCodeName()?lower_case} && </#assign>
                        <#assign path>${path}${srfpluralize(_dataEntity.codeName)?lower_case}/<#noparse>$</#noparse>{context.${_dataEntity.getCodeName()?lower_case}}/</#assign>
                    </#if>
                </#list>
503 504
        if(${condition} true){
            return Http.getInstance().post(`${path}${srfpluralize(item.codeName)?lower_case}/${singleAppMethod.getCodeName()?lower_case}`,data,isloading);
ibizdev's avatar
ibizdev committed
505 506 507 508 509 510 511 512
        }
            </#list>
        </#if>
     </#if>
    </#if>
</#macro>
<#-- 定义service_block end -->

tony001's avatar
tony001 committed
513 514 515 516 517
<#-- 行为执行之前 start -->
<#-- @author zpc -->
<#-- @update 2020.7.14 11:00 -->
<#macro excuteBeforeAction appdeAction>
    <#if appdeAction.getBeforePSDEActionLogics?? && appdeAction.getBeforePSDEActionLogics()??>
518
        <#list appdeAction.getBeforePSDEActionLogics() as beforelogic>
519
        <#if beforelogic.getPSDELogic()?? && beforelogic.getPSDELogic().getLogicHolder?? && beforelogic.getPSDELogic().getLogicHolder()?? && (beforelogic.getPSDELogic().getLogicHolder() == 2 || beforelogic.getPSDELogic().getLogicHolder() == 3)>
520
        <#assign singleLogic = beforelogic.getPSDELogic() />
521 522
        <#if beforelogic.isInternalLogic()>
        <#-- 内部逻辑start -->
523 524
        let ${singleLogic.getCodeName()?lower_case}:${srfclassname('${singleLogic.getCodeName()}')}Logic = new ${srfclassname('${singleLogic.getCodeName()}')}Logic({context:JSON.parse(JSON.stringify(context)),data:JSON.parse(JSON.stringify(data))});
        data = await ${singleLogic.getCodeName()?lower_case}.onExecute(context,data,isloading?true:false);
525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545
        <#-- 内部逻辑end -->
        <#else>
        <#-- 外部逻辑start -->
        let tempService:any = await this.getService("${beforelogic.getDstPSDE().getCodeName()?lower_case}");
        let tempData:any = <#if beforelogic.isCloneParam()>Util.deepCopy(data)<#else>{}</#if>;
        if(tempService['${beforelogic.getDstPSDEAction().getCodeName()}'] && tempService['${beforelogic.getDstPSDEAction().getCodeName()}'] instanceof Function){
            <#if beforelogic.isIgnoreException()>try {</#if>
                let response:any = await tempService['${beforelogic.getDstPSDEAction().getCodeName()}'](context,tempData,isloading?true:false);
                if(response && response.status === 200){
                    data = response.data;
                }else{
                    <#if !beforelogic.isIgnoreException()>data = response.data;</#if>
                }
            <#if beforelogic.isIgnoreException()>
            } catch (error) {
                console.warn(error);
            }
            </#if>
        }
        <#-- 外部逻辑end -->
        </#if>
546 547
        </#if>
        </#list>
tony001's avatar
tony001 committed
548 549 550 551
    </#if>
</#macro>
<#-- 行为执行之前 end -->

552 553 554 555 556 557
<#-- 行为执行之后 start -->
<#-- @author zpc -->
<#-- @update 2020.7.14 14:00 -->
<#macro excuteAfterAction appdeAction>
    <#if appdeAction.getAfterPSDEActionLogics?? && appdeAction.getAfterPSDEActionLogics()??>
        <#list appdeAction.getAfterPSDEActionLogics() as afterlogic>
558
        <#if afterlogic.getPSDELogic()?? && afterlogic.getPSDELogic().getLogicHolder?? && afterlogic.getPSDELogic().getLogicHolder()?? && (afterlogic.getPSDELogic().getLogicHolder() == 2 || afterlogic.getPSDELogic().getLogicHolder() == 3)>
559
        <#assign singleLogic = afterlogic.getPSDELogic() />
560 561
        <#if afterlogic.isInternalLogic()>
        <#-- 内部逻辑start -->
562 563 564
    <@compress single_line=true>let ${singleLogic.getCodeName()?lower_case}:${srfclassname('${singleLogic.getCodeName()}')}Logic = new ${srfclassname('${singleLogic.getCodeName()}')}Logic({context:JSON.parse(JSON.stringify(context)),data:JSON.parse(JSON.stringify(res)).data});</@compress>
            <@compress single_line=true>let ${singleLogic.getCodeName()?lower_case}Data:any = await ${singleLogic.getCodeName()?lower_case}.onExecute(context,res.data,isloading?true:false);</@compress>
            res ={status:200,data:${singleLogic.getCodeName()?lower_case}Data};
565 566 567 568 569 570
        <#-- 内部逻辑end -->
        <#else>
        <#-- 外部逻辑start -->
        let tempService:any = await this.getService("${afterlogic.getDstPSDE().getCodeName()?lower_case}");
        let tempData:any = <#if afterlogic.isCloneParam()>Util.deepCopy(data)<#else>{}</#if>;
        if(tempService['${afterlogic.getDstPSDEAction().getCodeName()}'] && tempService['${afterlogic.getDstPSDEAction().getCodeName()}'] instanceof Function){
571 572
            <#if afterlogic.isIgnoreException()>try {</#if>
                let response:any = await tempService['${afterlogic.getDstPSDEAction().getCodeName()}'](context,tempData,isloading?true:false);
573 574 575
                if(response && response.status === 200){
                    res = response;
                }else{
576
                    <#if !afterlogic.isIgnoreException()>res = response;</#if>
577
                }
578 579
            <#if afterlogic.isIgnoreException()>
            } catch (error) {
580
                console.warn(error);
581 582
            }
            </#if>
583 584 585
        }
        <#-- 外部逻辑end -->
        </#if>
586 587 588 589 590 591
        </#if>
        </#list>
    </#if>
</#macro>
<#-- 行为执行之后 end -->

ibizdev's avatar
ibizdev committed
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621

/**
 * ${de.getLogicName()}服务对象基类
 *
 * @export
 * @class ${srfclassname('${item.getCodeName()}')}ServiceBase
 * @extends {EntityServie}
 */
export default class ${srfclassname('${item.getCodeName()}')}ServiceBase extends EntityService {

    /**
     * Creates an instance of  ${srfclassname('${item.getCodeName()}')}ServiceBase.
     * 
     * @param {*} [opts={}]
     * @memberof  ${srfclassname('${item.getCodeName()}')}ServiceBase
     */
    constructor(opts: any = {}) {
        super(opts);
    }

    /**
     * 初始化基础数据
     *
     * @memberof ${srfclassname('${item.getCodeName()}')}ServiceBase
     */
    public initBasicData(){
        this.APPLYDEKEY ='${item.codeName?lower_case}';
        this.APPDEKEY = '${item.getKeyPSAppDEField().getCodeName()?lower_case}';
        this.APPDENAME = '${srfpluralize(item.codeName)?lower_case}';
        this.APPDETEXT = '<#if item.getMajorPSAppDEField?? && item.getMajorPSAppDEField()??>${item.getMajorPSAppDEField().getCodeName()?lower_case}</#if>';
622 623
        this.APPNAME = '${app.getCodeName()?lower_case}';
        this.SYSTEMNAME = '${app.getPSSystem().getCodeName()?lower_case}';
ibizdev's avatar
ibizdev committed
624 625 626 627 628
    }

// 实体接口
<#-- 实体接口调用start -->
<#if item.getAllPSAppDEMethods?? && item.getAllPSAppDEMethods()??>
629
<#list item.getAllPSAppDEMethods() as singleAppMethod>
ibizdev's avatar
ibizdev committed
630 631 632
    <#if singleAppMethod.render??>
        ${singleAppMethod.render.code}
    <#else>
633
    <#if singleAppMethod.isBuiltinMethod() == false>
ibizdev's avatar
ibizdev committed
634 635 636 637 638 639 640 641 642 643 644

    /**
     * ${singleAppMethod.getCodeName()}接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof ${srfclassname('${item.getCodeName()}')}ServiceBase
     */
    public async ${singleAppMethod.getCodeName()}(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
645 646
    <#if singleAppMethod.getPSDEAction()??>
    <#assign appdeAction = singleAppMethod.getPSDEAction() /> 
647 648 649
    <#-- 检查行为是否可以执行 start -->
    <#-- @author zpc -->
    <#-- @update 2020.7.13 16:00 -->
650 651 652 653
    <#if appdeAction.getTestActionMode?? && appdeAction.getTestActionMode()?? && (appdeAction.getTestActionMode() == 1 || appdeAction.getTestActionMode() == 3)>
        let result:any = await this.test${srfclassname('${singleAppMethod.getCodeName()}')}(context,data);
		if(!result) return;
    </#if>
654
    <#-- 检查行为是否可以执行 end -->
tony001's avatar
tony001 committed
655 656 657 658 659 660

    <#-- 行为执行之前 start -->
    <#-- @author zpc -->
    <#-- @update 2020.7.14 11:00 -->
    <@excuteBeforeAction appdeAction = appdeAction />
    <#-- 行为执行之前 end -->
661
    <#--是否存在前端处理逻辑start -->
662 663
    <#if appdeAction.getPSDELogic?? && appdeAction.getPSDELogic()?? && (appdeAction.getActionHolder() == 2 || appdeAction.getActionHolder() == 3)   >
    <#assign appdelogic = appdeAction.getPSDELogic() />
tony001's avatar
tony001 committed
664
        let appLogic:${srfclassname('${appdelogic.getCodeName()}')}Logic = new ${srfclassname('${appdelogic.getCodeName()}')}Logic({context:JSON.parse(JSON.stringify(context)),data:JSON.parse(JSON.stringify(data))});
665 666
        data = await appLogic.onExecute(context,data,isloading?true:false);
        let res:any ={status:200,data:data};
667
        <@excuteAfterAction appdeAction = appdeAction />
668
        return res;
669
    <#else>
670 671 672
    <#-- 行为执行之后 start -->
    <#-- @author zpc -->
    <#-- @update 2020.7.14 14:00 -->
673
    <#assign afterActionStr><@excuteAfterAction appdeAction = appdeAction /></#assign>
674 675
    <@service_block item=item singleAppMethod=singleAppMethod afterActionStr = afterActionStr/>
    <#-- 行为执行之后 end -->
676 677 678
    </#if>
    <#--是否存在前端处理逻辑end -->
    <#else>
tony001's avatar
tony001 committed
679
    <#-- 无实体行为,有接口走接口,无接口走本地供数 start -->
680
    <#-- @author zpc -->
tony001's avatar
tony001 committed
681
    <#-- @update 2020.7.22 17:00 -->
682
    <@local_supply item=item singleAppMethod=singleAppMethod />
tony001's avatar
tony001 committed
683
    <#-- 无实体行为,有接口走接口,无接口走本地供数 end -->
684
    </#if>
ibizdev's avatar
ibizdev committed
685
    }
686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731
    <#-- 查询数据集(post方式)start -->
    <#if singleAppMethod.getMethodType?? && singleAppMethod.getMethodType()?? && singleAppMethod.getMethodType() == "FETCH">
    <#assign dataSet = singleAppMethod.getPSDEDataSet() />

    /**
     * search${dataSet.getCodeName()}接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof ${srfclassname('${item.getCodeName()}')}ServiceBase
     */
    public async search${dataSet.getCodeName()}(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
    <#if singleAppMethod.getPSDEAction()??>
    <#assign appdeAction = singleAppMethod.getPSDEAction() />
    <#if appdeAction.getTestActionMode?? && appdeAction.getTestActionMode()?? && (appdeAction.getTestActionMode() == 1 || appdeAction.getTestActionMode() == 3)>
        let result:any = await this.test${srfclassname('search${dataSet.getCodeName()}')}(context,data);
		if(!result) return;
    </#if>
    </#if>
    <#-- 检查行为是否可以执行 end -->
    <#if item.getPSAppDERSPathCount() gt 0 && singleServiceApi??>
        <#list 1..item.getPSAppDERSPathCount() as count>
        <#assign path = ''/>
        <#assign condition = ''/>
        <#list item.getPSAppDERSPath(count_index)  as deRSPath>
            <#if deRSPath.getMajorPSAppDataEntity?? && deRSPath.getMajorPSAppDataEntity()??>
                <#assign _dataEntity = deRSPath.getMajorPSAppDataEntity()/>
                <#assign condition>${condition}context.${_dataEntity.getCodeName()?lower_case} && </#assign>
                <#assign path>${path}${srfpluralize(_dataEntity.codeName)?lower_case}/<#noparse>$</#noparse>{context.${_dataEntity.getCodeName()?lower_case}}/</#assign>
            </#if>
        </#list>
        if(${condition}true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            return await Http.getInstance().post(`/${path}${srfpluralize(item.codeName)?lower_case}/search${dataSet.getCodeName()?lower_case}`,tempData,isloading);
        }
        </#list>
    </#if>
    <#if item.isMajor()>
        let tempData:any = JSON.parse(JSON.stringify(data));
        return await Http.getInstance().post(`/${srfpluralize(item.codeName)?lower_case}/search${dataSet.getCodeName()?lower_case}`,tempData,isloading);
    </#if>
    }
    </#if>
    <#-- 查询数据集(post方式)end -->
732 733 734 735
    <#-- 自定义行为Batch方法start -->
    <#if singleAppMethod.getMethodType?? && singleAppMethod.getMethodType()?? && singleAppMethod.getMethodType() == "DEACTION" && singleAppMethod.getPSDEAction?? && singleAppMethod.getPSDEAction()?? && singleAppMethod.getPSDEServiceAPIMethod?? && singleAppMethod.getPSDEServiceAPIMethod()??>
    <#assign deAction = singleAppMethod.getPSDEAction()>
    <#assign singleServiceApi = singleAppMethod.getPSDEServiceAPIMethod()/>
736 737
    <#if deAction.getActionType?? && deAction.getActionType()?? && deAction.getActionType() == "USERCUSTOM">

738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760
    /**
     * ${singleAppMethod.getCodeName()}Batch接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof ${srfclassname('${item.getCodeName()}')}ServiceBase
     */
    public async ${singleAppMethod.getCodeName()}Batch(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
    <#if item.getPSAppDERSPathCount() gt 0 && singleServiceApi??>
        <#list 1..item.getPSAppDERSPathCount() as count>
        <#assign path = ''/>
        <#assign condition = ''/>
        <#list item.getPSAppDERSPath(count_index)  as deRSPath>
            <#if deRSPath.getMajorPSAppDataEntity?? && deRSPath.getMajorPSAppDataEntity()??>
                <#assign _dataEntity = deRSPath.getMajorPSAppDataEntity()/>
                <#assign condition>${condition}context.${_dataEntity.getCodeName()?lower_case} && </#assign>
                <#assign path>${path}${srfpluralize(_dataEntity.codeName)?lower_case}/<#noparse>$</#noparse>{context.${_dataEntity.getCodeName()?lower_case}}/</#assign>
            </#if>
        </#list>
        if(${condition}true){
            let tempData:any = JSON.parse(JSON.stringify(data));
tony001's avatar
tony001 committed
761
            return await Http.getInstance().post(`/${path}${srfpluralize(item.codeName)?lower_case}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>batch`,tempData,isloading);
762 763 764 765 766
        }
        </#list>
    </#if>
    <#if item.isMajor()>
        let tempData:any = JSON.parse(JSON.stringify(data));
767
        return await Http.getInstance().post(`/${srfpluralize(item.codeName)?lower_case}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>batch`,tempData,isloading);
768 769 770
    </#if>
    }
    </#if>
771
    </#if>
772
    <#-- 自定义行为Batch方法end -->
773

774 775 776
    <#-- 检查行为是否可以执行 start -->
    <#-- @author zpc -->
    <#-- @update 2020.7.13 17:00 -->
777 778
    <#if singleAppMethod.getPSDEAction()??>
    <#assign appdeAction = singleAppMethod.getPSDEAction() />
779
    <#if appdeAction.getTestActionMode?? && appdeAction.getTestActionMode()?? && (appdeAction.getTestActionMode() == 1 || appdeAction.getTestActionMode() == 3)>
780 781 782 783 784 785 786 787 788
    
    /**
     * test${srfclassname('${singleAppMethod.getCodeName()}')}方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @returns {Promise<any>}
     * @memberof ${srfclassname('${item.getCodeName()}')}ServiceBase
     */
789
    <@getTestActionModifier appdeAction=appdeAction/> async test${srfclassname('${singleAppMethod.getCodeName()}')}(context: any = {},data: any = {}): Promise<any> {
790 791
        return true;
    }
792 793 794 795 796 797 798 799 800 801 802 803 804 805 806
    <#if singleAppMethod.getMethodType?? && singleAppMethod.getMethodType()?? && singleAppMethod.getMethodType() == "FETCH">
    <#assign dataSet = singleAppMethod.getPSDEDataSet() />

    /**
     * test${srfclassname('search${dataSet.getCodeName()}')}方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @returns {Promise<any>}
     * @memberof ${srfclassname('${item.getCodeName()}')}ServiceBase
     */
    <@getTestActionModifier appdeAction=appdeAction/> async test${srfclassname('search${dataSet.getCodeName()}')}(context: any = {},data: any = {}): Promise<any> {
        return true;
    }
    </#if>
807
    </#if>
808
    </#if>
809
    <#-- 检查行为是否可以执行 end -->
ibizdev's avatar
ibizdev committed
810
    </#if>
811 812
    </#if>
</#list>
ibizdev's avatar
ibizdev committed
813 814 815
</#if>
<#-- 实体接口调用end -->
}