<#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() />
            this.tempStorage.setItem(context.srfsessionkey+'_${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}',JSON.stringify(res.data.${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}));
        </#list>
        </#if>
</#macro>

<#-- 获取本地缓存 -->
<#macro getStore appEntity>
        <#if appEntity.getMajorPSAppDERSs()??>
        <#list appEntity.getMajorPSAppDERSs() as deReRs>
        <#-- 主实体 -->
        <#assign majorPSAppDataEntity = deReRs.getMajorPSAppDataEntity() />
        <#-- 从实体 -->
        <#assign minorPSAppDataEntity = deReRs.getMinorPSAppDataEntity() />
        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;
                        }
                        delete item.srffrontuf;
                    }
                });
            }
        }
        masterData.${srfpluralize(minorPSAppDataEntity.codeName)?lower_case} = ${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}Data;
        </#list>
        </#if>
</#macro>

<#-- 定义service_block start -->
<#macro service_block item singleAppMethod>
 <#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>
        <#-- 方法类型为SELECT -->
        <#if singleAppMethod.getMethodType() == "SELECT">
        if(${condition}context.${item.getCodeName()?lower_case}){
            <#if singleServiceApi.getRequestMethod() == 'PUT' ||  singleServiceApi.getRequestMethod() == 'POST'>
            return 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);
            <#else>
            return 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>
        }
        <#-- 方法类型为FETCH -->
        <#elseif singleAppMethod.getMethodType() == "FETCH">
        if(${condition}true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            return Http.getInstance().get(`/${path}${srfpluralize(item.codeName)?lower_case}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,tempData,isloading);
        }
        <#-- 方法类型为FETCHTEMP -->
        <#elseif singleAppMethod.getMethodType() == "FETCHTEMP">
        if(${condition}true){
            return Http.getInstance().get(`/${path}${srfpluralize(item.codeName)?lower_case}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,data,isloading);
        }
        <#else>
        <#-- 方法类型为DEACTION start -->
            <#if singleServiceApi.getRequestParamType() == "NONE">
            <#-- 无参数情况start -->
        if(${condition}true){
            return Http.getInstance().${singleServiceApi.getRequestMethod()?lower_case}(`/${path}${srfpluralize(item.codeName)?lower_case}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,isloading);
        }
            <#-- 无参数情况end -->
            <#elseif singleServiceApi.getRequestParamType() == "FIELD">
            <#-- 指定属性情况start -->
        if(${condition}context.${item.getCodeName()?lower_case}){
            return 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);
        }
            <#-- 指定属性情况start -->
            <#elseif singleServiceApi.getRequestParamType() == "ENTITY">
            <#-- 提交对象数据情况start -->
            <#if singleAppMethod.getCodeName() == 'Create'>
        if(${condition}true){
            if(!data.srffrontuf || data.srffrontuf !== "1"){
                data[this.APPDEKEY] = null;
            }
            if(data.srffrontuf){
                delete data.srffrontuf;
            }
            return Http.getInstance().${singleServiceApi.getRequestMethod()?lower_case}(`/${path}${srfpluralize(item.codeName)?lower_case}`,data,isloading);
        }
            <#else>
        if(${condition}context.${item.getCodeName()?lower_case}){
            return 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>
            <#-- 提交对象数据情况start -->
            <#else>
            <#-- URI参数传递情况start -->
        // URI参数传递情况未实现
            <#-- URI参数传递情况start -->
            </#if>
         <#-- 方法类型为DEACTION end -->
        </#if>
    </#list>
    </#if>
    <#if item.isMajor()>
        <#-- 方法类型为SELECT -->
        <#if singleAppMethod.getMethodType() == "SELECT">
        <#--  if(context.${item.getCodeName()?lower_case}){  -->
            <#if singleServiceApi.getRequestMethod() == 'PUT' ||  singleServiceApi.getRequestMethod() == 'POST'>
            return 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);
            <#else>
            return 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>
        <#--  }  -->
        <#-- 方法类型为FETCH -->
        <#elseif singleAppMethod.getMethodType() == "FETCH">
        let tempData:any = JSON.parse(JSON.stringify(data));
        return Http.getInstance().get(`/${srfpluralize(item.codeName)?lower_case}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,tempData,isloading);
        <#-- 方法类型为FETCHTEMP -->
        <#elseif singleAppMethod.getMethodType() == "FETCHTEMP">
        return Http.getInstance().get(`/${srfpluralize(item.codeName)?lower_case}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,data,isloading);
        <#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};
        <@setStore appEntity=item />
        return res;
            <#-- 无参数情况end -->
            <#elseif singleServiceApi.getRequestParamType() == "FIELD">
            <#-- 指定属性情况start -->
            <#-- GET -->
            <#if singleServiceApi.getRequestMethod() == "GET">
        <#--  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>`,isloading);
            <@setStore appEntity=item />
            return res;
        <#--  }  -->
            <#elseif singleServiceApi.getRequestMethod() == "POST">
            <#-- REMOVE -->
        <#--  if(context.${item.getCodeName()?lower_case}){  -->
            return 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);
        <#--  }    -->
            <#else>
        <#--  if(context.${item.getCodeName()?lower_case}){  -->
            return 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>

            <#-- 指定属性情况start -->
            <#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);
            <@setStore appEntity=item />
            return res;
        <#--  }  -->
        <#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);
            <@setStore appEntity=item />
            return res;
        <#--  }  -->
        <#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() />
        this.tempStorage.setItem(tempContext.srfsessionkey+'_${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}',JSON.stringify(res.data.${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}));
        </#list>
        </#if>
        return res;
        <#else>
        <#--  if(context.${item.getCodeName()?lower_case}){  -->
            return 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>
            <#-- 提交对象数据情况start -->
            <#else>
            <#-- URI参数传递情况start -->
        // URI参数传递情况未实现
            <#-- URI参数传递情况start -->
            </#if>
         <#-- 方法类型为DEACTION end -->
        </#if>
    </#if>
    <#-- 嵌套成员 -->
    <#if item.isMajor() == false && !singleServiceApi??>
     <#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){
                return {"status":200,"data":result};
            }else{
                return {"status":200,"data":[]};
            } 
        }else{
            return {"status":200,"data":[]};
        }
        </#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){
                return {"status":200,"data":result};
            }else{
                return {"status":200,"data":[]};
            } 
        }else{
            return {"status":200,"data":[]};
        }
        </#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) =>{
                    return !Object.is(item.${item.getCodeName()?lower_case},data.${item.getCodeName()?lower_case});
                })
                this.tempStorage.setItem(context.srfsessionkey+'_${srfpluralize(item.codeName)?lower_case}',JSON.stringify(tempResult));
                 return {"status":200,"data":data};
            }else{
                return {"status":500,"data":null};
            } 
        }
        </#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));
                return {"status":200,"data":data};
            }else{
                return {"status":500,"data":null};
            }
        }
        </#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>
        return {"status":200,"data":tempData}; 
        <#elseif singleAppMethod.getCodeName() == "Create">
        <#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 ${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}));
            return {"status":200,"data":data};
        }else{
            return {"status":200,"data":{}};
        }
        </#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;
                    }
                });
                return {"status":200,"data":flag};
            }else{
                return {"status":500,"data":null};
            } 
        }
        </#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) =>{
                    return Object.is(item.${item.getCodeName()?lower_case},data.${item.getCodeName()?lower_case});
                })
                let tempResultData:any = tempResult.length>0?tempResult[0]:Object.assign({},data);
                return {"status":200,"data":tempResultData};
            }else{
                return {"status":500,"data":null};
            } 
        }
        </#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>
        if(${condition} true){
            return Http.getInstance().post(`${path}${srfpluralize(item.codeName)?lower_case}/${singleAppMethod.getCodeName()?lower_case}`,data,isloading);
        }
            </#list>
        </#if>
     </#if>
    </#if>
</#macro>
<#-- 定义service_block end -->


/**
 * ${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>';
        this.APPNAME = '${app.getCodeName()?lower_case}';
        this.SYSTEMNAME = '${app.getPSSystem().getCodeName()?lower_case}';
    }

// 实体接口
<#-- 实体接口调用start -->
<#if item.getAllPSAppDEMethods?? && item.getAllPSAppDEMethods()??>
<#list item.getAllPSAppDEMethods() as singleAppMethod>
<#if singleAppMethod.getPSDEServiceAPIMethod?? &&  singleAppMethod.getPSDEServiceAPIMethod()??>
 <#assign singleServiceApi = singleAppMethod.getPSDEServiceAPIMethod()/>
</#if>
    <#if singleAppMethod.render??>
        ${singleAppMethod.render.code}
    <#else>
    <#if singleAppMethod.isBuiltinMethod() == false>

    /**
     * ${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> {
    <#--是否存在前端处理逻辑start -->
    <#if singleAppMethod.getPSDEAction()??>
    <#assign appdeAction = singleAppMethod.getPSDEAction() />
    <#if appdeAction.getPSDELogic?? && appdeAction.getPSDELogic()?? && (appdeAction.getActionHolder() == 2 || appdeAction.getActionHolder() == 3)   >
    <#assign appdelogic = appdeAction.getPSDELogic() />
        let appLogic:${appdelogic.codeName}Logic = new ${appdelogic.codeName}Logic();
        const result = await appLogic.onExecute(context,data,isloading?true:false);
        return {status:200,data:result};
    <#else>
    <@service_block item=item singleAppMethod=singleAppMethod/>
    </#if>
    <#--是否存在前端处理逻辑end -->
    <#else>
    <@service_block item=item singleAppMethod=singleAppMethod/>
    </#if>
    }
    </#if>
    </#if>
</#list>
</#if>
<#-- 实体接口调用end -->
}