提交 e47288d3 编写于 作者: tony001's avatar tony001

调整实体数据服务

上级 5e6860d9
<#ibiztemplate>
TARGET=PSAPPDELOGIC
</#ibiztemplate>
import { Util, Verify } from '@/ibiz-core/utils';
import { EntityLogicBase } from '@/ibiz-core';
<#if item.getPSDELogicNodes()??>
<#list item.getPSDELogicNodes() as delogicNode>
<#if delogicNode.getLogicNodeType()?? && delogicNode.getLogicNodeType() == "DEACTION">
<#if delogicNode.getDstPSAppDataEntity()?? && delogicNode.getDstPSAppDEAction()??>
<#assign targetEntity = delogicNode.getDstPSAppDataEntity() />
<#if !P.exists("importService", targetEntity.getId(), "")>
import ${srfclassname('${targetEntity.getCodeName()}')}Service from '@/service/${srffilepath2(targetEntity.getCodeName())}/${srffilepath2(targetEntity.getCodeName())}-service';
</#if>
</#if>
</#if>
</#list>
</#if>
import { Verify } from '@/utils/verify/verify';
<#-- 设置参数 -->
<#macro setParam logicNode>
<#if logicNode.getPSDELogicNodeParams()??>
<#list logicNode.getPSDELogicNodeParams() as logicparam>
<#if logicparam.getSrcFieldName()?? && logicparam.getDstFieldName()??>
<#if logicparam.getSrcFieldName() != "">
Object.assign(params, { ${logicparam.getDstFieldName()?lower_case}: params.${logicparam.getSrcFieldName()?lower_case} });
</#if>
<#if logicparam.getDstPSDELogicParam?? && logicparam.getDstPSDELogicParam()?? && logicparam.getDstPSDELogicParam().getParamPSAppDataEntity()??>
<#if logicparam.getSrcFieldName()?lower_case?contains("id") >
Object.assign(context, { ${logicparam.getDstPSDELogicParam().getParamPSAppDataEntity().getCodeName()?lower_case} : params.${logicparam.getSrcFieldName()?lower_case} });
</#if>
</#if>
<#if logicparam.getDstPSDELogicParam()?? && logicparam.getDstFieldName()?? && logicparam.getSrcValueType()??>
<#-- 源参数 -->
<#if logicparam.getSrcPSDELogicParam()??><#assign srcParam = logicparam.getSrcPSDELogicParam() /></#if>
<#-- 源参数属性名称 -->
<#if logicparam.getSrcFieldName()??>
<#assign srcFieldParamName = logicparam.getSrcFieldName() />
<#if srcParam?? && srcParam.getParamPSAppDataEntity?? && srcParam.getParamPSAppDataEntity()?? && srcParam.getParamPSAppDataEntity().getPSAppDEField(srcFieldParamName,true)??>
<#assign srcFieldParam=srfcaseformat(srcParam.getParamPSAppDataEntity().getPSAppDEField(srcFieldParamName,true).getCodeName()?lower_case,'l_u2lC') />
<#else>
<#assign srcFieldParam= logicparam.getSrcFieldName()?lower_case />
</#if>
</#if>
<#-- 目标参数 -->
<#assign dstParam = logicparam.getDstPSDELogicParam() />
<#-- 目标参数属性名称 -->
<#assign dstFieldParamName = logicparam.getDstFieldName() />
<#if dstParam?? && dstParam.getParamPSAppDataEntity?? && dstParam.getParamPSAppDataEntity()?? && dstParam.getParamPSAppDataEntity().getPSAppDEField(dstFieldParamName,true)??>
<#assign dstFieldParam=srfcaseformat(dstParam.getParamPSAppDataEntity().getPSAppDEField(dstFieldParamName,true).getCodeName()?lower_case,'l_u2lC') />
<#else>
<#assign dstFieldParam= logicparam.getDstFieldName()?lower_case />
</#if>
<#-- 源逻辑参数 -->
let tempDstParam${logicparam_index}Context:any = this.paramsMap.get('${dstParam.getCodeName()}').context?this.paramsMap.get('${dstParam.getCodeName()}').context:{};
let tempDstParam${logicparam_index}Data:any = this.paramsMap.get('${dstParam.getCodeName()}').data?this.paramsMap.get('${dstParam.getCodeName()}').data:{};
<#if logicparam.getSrcValueType() =="SRCDLPARAM">
let tempSrcParam${logicparam_index}Data:any = this.paramsMap.get('${srcParam.getCodeName()}').data?this.paramsMap.get('${srcParam.getCodeName()}').data:{};
<#if dstParam.getParamPSAppDataEntity?? && dstParam.getParamPSAppDataEntity()?? && dstFieldParam == dstParam.getParamPSAppDataEntity().getKeyPSAppDEField().getCodeName()?lower_case>
Object.assign(tempDstParam${logicparam_index}Context,{${dstParam.getParamPSAppDataEntity().getCodeName()?lower_case}:tempSrcParam${logicparam_index}Data['${srcFieldParam}']});
</#if>
Object.assign(tempDstParam${logicparam_index}Data,{${dstFieldParam}:tempSrcParam${logicparam_index}Data['${srcFieldParam}']});
<#-- 应用上下文 -->
<#elseif logicparam.getSrcValueType() =="APPDATA">
<#if dstParam.getParamPSAppDataEntity?? && dstParam.getParamPSAppDataEntity()?? && dstFieldParam == dstParam.getParamPSAppDataEntity().getKeyPSAppDEField().getCodeName()?lower_case>
Object.assign(tempDstParam${logicparam_index}Context,{${dstParam.getParamPSAppDataEntity().getCodeName()?lower_case}:context['${srcFieldParam}']});
</#if>
Object.assign(tempDstParam${logicparam_index}Data,{${dstFieldParam}:context['${srcFieldParam}']});
<#-- 数据上下文 -->
<#elseif logicparam.getSrcValueType() =="DATACONTEXT">
<#if dstParam.getParamPSAppDataEntity?? && dstParam.getParamPSAppDataEntity()?? && dstFieldParam == dstParam.getParamPSAppDataEntity().getKeyPSAppDEField().getCodeName()?lower_case>
Object.assign(tempDstParam${logicparam_index}Context,{${dstParam.getParamPSAppDataEntity().getCodeName()?lower_case}:params['${srcFieldParam}']});
</#if>
Object.assign(tempDstParam${logicparam_index}Data,{${dstFieldParam}:params['${srcFieldParam}']});
<#-- 直接值 -->
<#elseif logicparam.getSrcValueType() =="SRCVALUE">
<#if dstParam.getParamPSAppDataEntity?? && dstParam.getParamPSAppDataEntity()?? && dstFieldParam == dstParam.getParamPSAppDataEntity().getKeyPSAppDEField().getCodeName()?lower_case>
Object.assign(tempDstParam${logicparam_index}Context,{${dstParam.getParamPSAppDataEntity().getCodeName()?lower_case}:${logicparam.getSrcValue()}});
</#if>
Object.assign(tempDstParam${logicparam_index}Data,{${dstFieldParam}:"${logicparam.getSrcValue()}"});
</#if>
this.paramsMap.set('${dstParam.getCodeName()}',{data:tempDstParam${logicparam_index}Data,context:tempDstParam${logicparam_index}Context});
</#if>
</#list>
</#if>
......@@ -28,22 +80,18 @@ import { EntityLogicBase } from '@/ibiz-core';
<#list logicNode.getPSDELogicLinks() as logiclink>
<#if logiclink.getDstPSDELogicNode()??>
<#assign nextnode = logiclink.getDstPSDELogicNode() />
<#list item.getPSDELogicLinks() as curLink>
<#if curLink.getId() == logiclink.getId() && curLink.getPSDELogicLinkGroupCond()??>
<#list item.getPSDELogicLinks() as curLink >
<#if curLink.getId() == logiclink.getId()>
<#assign curIndex = curLink_index/>
</#if>
</#list>
<#if curIndex??>
if (this.compute${curIndex}Cond(params)) {
return this.execute${nextnode.codeName}(context, params);
if(this.compute${curIndex}Cond(params)){
return this.execute${nextnode.codeName}(context,params,isloading);
}
<#else>
return this.execute${nextnode.codeName}(context, params);
</#if>
</#if>
</#list>
<#else>
return params;
return this.paramsMap.get(this.defaultParamName).data;
</#if>
</#macro>
......@@ -51,56 +99,89 @@ import { EntityLogicBase } from '@/ibiz-core';
<#macro getCond item><#if item.getLogicType() == 'GROUP'><#if item.isNotMode()>!(</#if><#if item.getPSDELogicLinkConds()??><#list item.getPSDELogicLinkConds() as subLogic><#if subLogic_index gt 0><#if item.getGroupOP() == 'AND'> && </#if><#if item.getGroupOP() == 'OR'> || </#if></#if><@getCond subLogic /></#list></#if><#if item.isNotMode()>)</#if><#elseif item.getLogicType() == 'SINGLE'>Verify.testCond(params.${item.getDstFieldName()?lower_case}, '${item.getCondOP()}', '${item.getValue()}')</#if></#macro>
/**
* ${item.name}处理逻辑基类
* ${item.name}
*
* @export
* @class ${item.codeName}LogicBase
* @extends {EntityLogicBase}
* @class ${srfclassname('${item.getCodeName()}')}LogicBase
*/
export class ${item.codeName}LogicBase extends EntityLogicBase {
export default class ${srfclassname('${item.getCodeName()}')}LogicBase {
/**
* 名称
*
* @protected
* @memberof ${item.codeName}LogicBase
* @memberof ${srfclassname('${item.getCodeName()}')}LogicBase
*/
protected name:string ="${item.codeName}";
private name:string ="${item.codeName}";
/**
* 唯一标识
*
* @protected
* @memberof ${item.codeName}LogicBase
* @memberof ${srfclassname('${item.getCodeName()}')}LogicBase
*/
protected id:string = "${item.id}";
private id:string = "${item.id}";
/**
* 默认参数名称
*
* @protected
* @memberof ${item.codeName}LogicBase
* @memberof ${srfclassname('${item.getCodeName()}')}LogicBase
*/
private defaultParamName:string = "${item.getDefaultParamName()}";
/**
* 参数集合
*
* @memberof ${srfclassname('${item.getCodeName()}')}LogicBase
*/
private paramsMap:Map<string,any> = new Map();
/**
* Creates an instance of ${srfclassname('${item.getCodeName()}')}LogicBase.
*
* @param {*} [opts={}]
* @memberof ${srfclassname('${item.getCodeName()}')}LogicBase
*/
protected defaultParamName:string = "${item.getDefaultParamName()}";
constructor(opts: any = {}) {
this.initParams(opts);
}
/**
* 初始化参数集合
*
* @param {*} [opts={}]
* @memberof ${srfclassname('${item.getCodeName()}')}LogicBase
*/
public initParams(opts:any){
<#if item.getPSDELogicParams?? && item.getPSDELogicParams()??>
<#list item.getPSDELogicParams() as logicParam>
<#if logicParam.isDefault()>
this.paramsMap.set('${logicParam.getCodeName()}',opts);
<#else>
this.paramsMap.set('${logicParam.getCodeName()}',{});
</#if>
</#list>
</#if>
}
<#if item.getPSDELogicLinks()??>
<#list item.getPSDELogicLinks() as curLink>
<#if curLink.getPSDELogicLinkGroupCond()??>
/**
* 计算${curLink_index}节点结果
*
* @param params 传入上下文参数
* @returns {boolean}
* @memberof ${item.codeName}LogicBase
* @param params 传入参数
*/
public compute${curLink_index}Cond(params: any): boolean {
public compute${curLink_index}Cond(params:any):boolean{
<#if curLink.getPSDELogicLinkGroupCond()??>
<#assign linkCond = curLink.getPSDELogicLinkGroupCond() />
if (<@getCond linkCond />) {
if(<@getCond linkCond />){
return true;
}else{
return false;
}
return false;
<#else>
return true;
</#if>
}
</#if>
</#list>
</#if>
......@@ -109,11 +190,9 @@ export class ${item.codeName}LogicBase extends EntityLogicBase {
*
* @param context 应用上下文
* @param params 传入参数
* @returns {Promise<any>}
* @memberof ${item.codeName}LogicBase
*/
public onExecute(context: any, params: any): Promise<any> {
return this.execute${item.getStartPSDELogicNode().codeName}(context, params);
public onExecute(context:any,params:any,isloading:boolean){
return this.execute${item.getStartPSDELogicNode().codeName}(context,params,isloading);
}
<#if item.getPSDELogicNodes()??>
......@@ -122,14 +201,11 @@ export class ${item.codeName}LogicBase extends EntityLogicBase {
<#-- 开始节点 -->
<#if delogicNode.getLogicNodeType()?? && delogicNode.getLogicNodeType() == "BEGIN">
/**
* ${delogicNode.getName()}
*
* @protected
* @param params 传入参数
* @returns {Promise<any>}
* @memberof ${item.codeName}LogicBase
*/
protected async execute${delogicNode.codeName}(context: any, params: any): Promise<any> {
* ${delogicNode.getName()}
*
* @param params 传入参数
*/
private async execute${delogicNode.codeName}(context:any,params:any,isloading:boolean){
//开始节点
<@setParam delogicNode />
<@executeNext delogicNode />
......@@ -137,105 +213,97 @@ export class ${item.codeName}LogicBase extends EntityLogicBase {
<#-- 行为处理节点 -->
<#elseif delogicNode.getLogicNodeType()?? && delogicNode.getLogicNodeType() == "DEACTION">
/**
* ${delogicNode.getName()}
*
* @protected
* @param context 应用上下文
* @param params 传入参数
* @returns {Promise<any>}
* @memberof ${item.codeName}LogicBase
*/
protected async execute${delogicNode.codeName}(context: any, params: any): Promise<any> {
* ${delogicNode.getName()}
*
* @param context 应用上下文
* @param params 传入参数
*/
private async execute${delogicNode.codeName}(context:any,params:any,isloading:boolean){
// 行为处理节点
<@setParam delogicNode />
<#if delogicNode.getDstPSAppDataEntity()?? && delogicNode.getDstPSAppDEAction()??>
<#assign targetEntity = delogicNode.getDstPSAppDataEntity() />
<#assign deAction = delogicNode.getDstPSAppDEAction() />
let result: any;
// ${targetEntity.getCodeName()}服务
const targetService: any = await this.getService('${targetEntity.getCodeName()}');
if (Util.isFunction(targetService['${deAction.getCodeName()}'])) {
result = await targetService['${deAction.getCodeName()}'](context, params);
<#if delogicNode.getDstPSDELogicParam()??>
let actionParam:any = this.paramsMap.get('${delogicNode.getDstPSDELogicParam().getCodeName()}');
<#else>
let actionParam:any = this.paramsMap.get(this.defaultParamName);
</#if>
const targetService:${srfclassname('${targetEntity.getCodeName()}')}Service = new ${srfclassname('${targetEntity.getCodeName()}')}Service();
if (targetService['${deAction.getCodeName()}'] && targetService['${deAction.getCodeName()}'] instanceof Function) {
result = await targetService['${deAction.getCodeName()}'](actionParam.context,actionParam.data, false);
}
if(result && result.status == 200){
Object.assign(params, result.data);
<@executeNext delogicNode />
Object.assign(actionParam.data,result.data);
<@executeNext delogicNode />
}
</#if>
}
<#-- 准备参数节点 -->
<#elseif delogicNode.getLogicNodeType()?? && delogicNode.getLogicNodeType() == "PREPAREPARAM">
/**
* ${delogicNode.getName()}
*
* @protected
* @param context 应用上下文
* @param params 传入参数
* @returns {Promise<any>}
* @memberof ${item.codeName}LogicBase
*/
protected async execute${delogicNode.codeName}(context: any, params: any): Promise<any> {
* ${delogicNode.getName()}
*
* @param context 应用上下文
* @param params 传入参数
*/
private async execute${delogicNode.codeName}(context:any,params:any,isloading:boolean){
// 准备参数节点
<@setParam delogicNode />
<@executeNext delogicNode />
<@setParam delogicNode />
<@executeNext delogicNode />
}
<#-- 开始流程节点 -->
<#elseif delogicNode.getLogicNodeType()?? && delogicNode.getLogicNodeType() == "STARTWF">
/**
* ${delogicNode.getName()}
*
* @protected
* @param context 应用上下文
* @param params 传入参数
* @returns {Promise<any>}
* @memberof ${item.codeName}LogicBase
*/
protected async execute${delogicNode.codeName}(context: any, params: any): Promise<any> {
throw new Error('开始流程节点暂未支持');
* ${delogicNode.getName()}
*
* @param context 应用上下文
* @param params 传入参数
*/
private async execute${delogicNode.codeName}(context:any,params:any,isloading:boolean){
// 开始流程节点
return this.paramsMap.get(this.defaultParamName).data;
}
<#-- 异常捕获节点 -->
<#elseif delogicNode.getLogicNodeType()?? && delogicNode.getLogicNodeType() == "THROWEXCEPTION">
/**
* ${delogicNode.getName()}
*
* @protected
* @param context 应用上下文
* @param params 传入参数
* @returns {Promise<any>}
* @memberof ${item.codeName}LogicBase
*/
protected async execute${delogicNode.codeName}(context: any, params: any): Promise<any> {
throw new Error('异常捕获节点暂未支持');
* ${delogicNode.getName()}
*
* @param context 应用上下文
* @param params 传入参数
*/
private async execute${delogicNode.codeName}(context:any,params:any,isloading:boolean){
// 异常捕获节点
return this.paramsMap.get(this.defaultParamName).data;
}
<#-- 前端插件 -->
<#elseif delogicNode.getLogicNodeType()?? && delogicNode.getLogicNodeType() == "PFPLUGIN">
/**
* ${delogicNode.getName()}
*
* @protected
* @param context 应用上下文
* @param params 传入参数
* @returns {Promise<any>}
* @memberof ${item.codeName}LogicBase
*/
protected async execute${delogicNode.codeName}(context: any, params: any): Promise<any> {
throw new Error('前端插件暂未支持');
* ${delogicNode.getName()}
*
* @param context 应用上下文
* @param params 传入参数
*/
private async execute${delogicNode.codeName}(context:any,params:any,isloading:boolean){
// 前端插件
return this.paramsMap.get(this.defaultParamName).data;
}
<#else>
/**
* ${delogicNode.getName()}
*
* @protected
* @param context 应用上下文
* @param params 传入参数
* @returns {Promise<any>}
* @memberof ${item.codeName}LogicBase
*/
protected async execute${delogicNode.codeName}(context: any, params: any): Promise<any> {
throw new Error('${delogicNode.getLogicNodeType()}暂未支持');
* ${delogicNode.getName()}
*
* @param context 应用上下文
* @param params 传入参数
*/
private async execute${delogicNode.codeName}(context:any,params:any,isloading:boolean){
// ${delogicNode.getLogicNodeType()}暂未支持
console.log("${delogicNode.getLogicNodeType()}暂未支持");
return this.paramsMap.get(this.defaultParamName).data;
}
</#if>
</#list>
</#if>
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSAPPDELOGIC
</#ibiztemplate>
import { ${item.codeName}LogicBase } from './${srffilepath2(item.getCodeName())}-logic-base';
import { Http,Util } from '@/utils';
import ${srfclassname('${item.getCodeName()}')}LogicBase from './${srffilepath2(item.getCodeName())}-logic-base';
/**
* ${item.name}处理逻辑
* ${item.name}
*
* @export
* @class ${item.codeName}Logic
* @extends {${item.codeName}LogicBase}
* @class ${srfclassname('${item.getCodeName()}')}Logic
*/
export class ${item.codeName}Logic extends ${item.codeName}LogicBase { }
// 默认导出
export default ${item.codeName}Logic;
\ No newline at end of file
export default class ${srfclassname('${item.getCodeName()}')}Logic extends ${srfclassname('${item.getCodeName()}')}LogicBase{
/**
* Creates an instance of ${srfclassname('${item.getCodeName()}')}Logic
*
* @param {*} [opts={}]
* @memberof ${srfclassname('${item.getCodeName()}')}Logic
*/
constructor(opts: any = {}) {
super(opts);
}
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSAPPDATAENTITY
</#ibiztemplate>
<#assign item_code_name = srfpluralize(item.codeName)?lower_case/>
<#macro appDerPath singleAppMethod singleServiceApi='ERROR'>
<#-- getPSAppDERSPathCount:应用实体关系路径数量 -->
<#if item.getPSAppDERSPathCount() gt 0 && singleServiceApi != 'ERROR'>
<#assign requestMethodName>${singleServiceApi.getRequestMethod()?lower_case}</#assign>
<#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><#if condition != ''> && </#if>${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 this.http.${requestMethodName}(`/${path}${item_code_name}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`, data);
<#else>
return this.http.${requestMethodName}(`/${path}${item_code_name}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`);
</#if>
}
<#-- 方法类型为FETCH -->
<#elseif singleAppMethod.getMethodType() == "FETCH">
if (${condition}) {
return this.http.${requestMethodName}(`/${path}${item_code_name}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`, data);
}
<#-- 方法类型为FETCHTEMP -->
<#elseif singleAppMethod.getMethodType() == "FETCHTEMP">
if (${condition}) {
return this.http.${requestMethodName}(`/${path}${item_code_name}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`, data);
}
<#else>
<#-- 方法类型为DEACTION start -->
<#if singleServiceApi.getRequestParamType() == "NONE">
<#-- 无参数情况start -->
if (${condition}) {
return this.http.${requestMethodName}(`/${path}${item_code_name}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`);
}
<#-- 无参数情况end -->
<#elseif singleServiceApi.getRequestParamType() == "FIELD">
<#-- 指定属性情况start -->
if (${condition} && context.${item.getCodeName()?lower_case}) {
return this.http.${requestMethodName}(`/${path}${item_code_name}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`);
}
<#-- 指定属性情况start -->
<#elseif singleServiceApi.getRequestParamType() == "ENTITY">
<#-- 提交对象数据情况start -->
<#if singleAppMethod.getCodeName() == 'Create'>
if (${condition}) {
return this.http.${requestMethodName}(`/${path}${item_code_name}`, data);
}
<#else>
if (${condition} && context.${item.getCodeName()?lower_case}) {
return this.http.${requestMethodName}(`/${path}${item_code_name}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`, data);
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() />
<#-- 从实体支持临时数据模式为true,才设置本地缓存 start -->
<#-- @author zpc -->
<#-- @update 2020.7.13 15:00 -->
<#if minorPSAppDataEntity.isEnableTempData()>
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}:[]));
</#if>
<#-- 从实体支持临时数据模式为true,才设置本地缓存 end -->
</#list>
</#if>
</#macro>
<#-- 获取本地缓存 -->
<#macro getStore appEntity>
<#if appEntity.getMajorPSAppDERSs()??>
<#list appEntity.getMajorPSAppDERSs() as deReRs>
<#-- 主实体 -->
<#assign majorPSAppDataEntity = deReRs.getMajorPSAppDataEntity() />
<#-- 从实体 -->
<#assign minorPSAppDataEntity = deReRs.getMinorPSAppDataEntity() />
<#-- 从实体支持临时数据模式为true,才从前端缓存拿取数据,组装数据给后台 start -->
<#-- @author zpc -->
<#-- @update 2020.7.13 15:00 -->
<#if minorPSAppDataEntity.isEnableTempData()>
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;
}
});
}
</#if>
<#-- 提交对象数据情况start -->
<#else>
<#-- URI参数传递情况start -->
throw new Error('URI参数传递情况未实现');
<#-- URI参数传递情况start -->
</#if>
<#-- 方法类型为DEACTION end -->
}
masterData.${srfpluralize(minorPSAppDataEntity.codeName)?lower_case} = ${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}Data;
</#if>
<#-- 从实体支持临时数据模式为true,才从前端缓存拿取数据,组装数据给后台 end -->
</#list>
</#if>
</#macro>
<#-- 本地供数satrt -->
<#macro local_supply item singleAppMethod>
<#if singleAppMethod.getPredefinedType?? && singleAppMethod.getPredefinedType()??>
<#-- 预定义类型为索引实体start -->
<#if singleAppMethod.getPredefinedType() == "INDEXDE">
<#if singleAppMethod.getPSAppCodeList?? && singleAppMethod.getPSAppCodeList()??>
<#assign appCodeList = singleAppMethod.getPSAppCodeList() />
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};
</#if>
</#if>
<#-- 预定义类型为索引实体end -->
</#if>
</#macro>
<#-- 本地供数end -->
<#-- 检查行为是否可以执行 start -->
<#-- @author zpc -->
<#-- @update 2020.7.13 18:00 -->
<#-- 获取测试行为的修饰符和名称 start -->
<#macro getTestActionModifier appdeAction>
<#compress>
<#if appdeAction.getTestActionMode() == 1>private</#if><#if appdeAction.getTestActionMode() == 3>public</#if>
</#compress>
</#macro>
<#-- 获取测试行为的修饰符和名称 end -->
<#-- 定义service_block start -->
<#macro service_block item singleAppMethod afterActionStr = "">
<#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>
</#macro>
<#macro major singleAppMethod singleServiceApi='ERROR'>
<#-- existAppMethodDeAction:是否存在前端逻辑 -->
<#if item.isMajor() && singleServiceApi != 'ERROR'>
<#assign requestMethodName>${singleServiceApi.getRequestMethod()?lower_case}</#assign>
<#-- 方法类型为SELECT -->
<#if singleAppMethod.getMethodType() == "SELECT">
if(${condition}context.${item.getCodeName()?lower_case}){
<#if singleServiceApi.getRequestMethod() == 'PUT' || singleServiceApi.getRequestMethod() == 'POST'>
return this.http.${requestMethodName}(`/${item_code_name}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`, data);
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);
<#else>
return this.http.${requestMethodName}(`/${item_code_name}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`);
</#if>
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><#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
return res;
}
<#-- 方法类型为FETCH -->
<#elseif singleAppMethod.getMethodType() == "FETCH">
return this.http.${requestMethodName}(`/${item_code_name}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`, data);
if(${condition}true){
let tempData:any = JSON.parse(JSON.stringify(data));
let res:any = Http.getInstance().get(`/${path}${srfpluralize(item.codeName)?lower_case}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,tempData,isloading);<#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
return res;
}
<#-- 方法类型为FETCHTEMP -->
<#elseif singleAppMethod.getMethodType() == "FETCHTEMP">
return this.http.${requestMethodName}(`/${item_code_name}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`, data);
if(${condition}true){
let res:any = Http.getInstance().get(`/${path}${srfpluralize(item.codeName)?lower_case}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,data,isloading);<#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
return res;
}
<#else>
<#-- 方法类型为DEACTION start -->
<#if singleServiceApi.getRequestParamType() == "NONE">
<#-- 方法类型为DEACTION start -->
<#if singleServiceApi.getRequestParamType() == "NONE">
<#-- 无参数情况start -->
const res: any = await this.http.${requestMethodName}(`/${item_code_name}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`);
res.data.${item.getCodeName()?lower_case} = context.${item.getCodeName()?lower_case};
<@setStore appEntity = item />
if(${condition}true){
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};
<@setStore appEntity=item /><#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
return res;
<#-- 无参数情况end -->
<#elseif singleServiceApi.getRequestParamType() == "FIELD">
<#-- 指定属性情况start -->
<#-- GET -->
<#if singleServiceApi.getRequestMethod() == "GET">
const res: any = await this.http.${requestMethodName}(`/${item_code_name}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`);
<@setStore appEntity = item />
return res;
<#elseif singleServiceApi.getRequestMethod() == "POST">
<#-- REMOVE -->
return this.http.${requestMethodName}(`/${item_code_name}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`, data);
<#else>
return this.http.${requestMethodName}(`/${item_code_name}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`);
</#if>
<#-- 指定属性情况start -->
<#elseif singleServiceApi.getRequestParamType() == "ENTITY">
<#-- 提交对象数据情况start -->
<#if singleAppMethod.getCodeName() == 'Update'>
<@getStore appEntity = item />
const res: any = await this.http.${requestMethodName}(`/${item_code_name}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`, data);
<@setStore appEntity = item />
}
<#-- 无参数情况end -->
<#elseif singleServiceApi.getRequestParamType() == "FIELD">
<#-- 指定属性情况start -->
if(${condition}context.${item.getCodeName()?lower_case}){
<#-- 指定属性情况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);
<@setStore appEntity=item /><#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
return res;
<#elseif singleAppMethod.getCodeName() == 'Save'>
<@getStore appEntity = item />
const res: any = await this.http.${requestMethodName}(`/${item_code_name}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`, data);
<@setStore appEntity = item />
<#elseif singleServiceApi.getRequestMethod() == "POST">
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 !="" >
${afterActionStr}</#if>
return res;
<#elseif singleAppMethod.getCodeName() == 'Create'>
<@getStore appEntity = item />
data.${item.getCodeName()?lower_case} = null;
const res: any = await this.http.${requestMethodName}(`/${item_code_name}`, data);
await this.setMinorLocalCache(context, res.data);
<#else>
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 !="" >
${afterActionStr}</#if>
return res;
<#else>
return this.http.${requestMethodName}(`/${item_code_name}/<#noparse>$</#noparse>{context.${item.getCodeName()?lower_case}}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`, data);
</#if>
</#if>
<#-- 指定属性情况end -->
}
<#-- 指定属性情况start -->
<#elseif singleServiceApi.getRequestParamType() == "ENTITY">
<#-- 提交对象数据情况start -->
<#else>
<#if singleAppMethod.getCodeName() == 'Create'>
if(${condition}true){
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}(`/${path}${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}?res.data.${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}:[]));
</#list>
</#if><#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
return res;
}
<#else>
if(${condition}context.${item.getCodeName()?lower_case}){
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);
<@setStore appEntity=item /><#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
return res;
}
</#if>
<#-- 提交对象数据情况end -->
<#else>
<#-- URI参数传递情况start -->
throw new Error('URI参数传递情况未实现');
// URI参数传递情况未实现
<#-- URI参数传递情况start -->
</#if>
<#-- 方法类型为DEACTION end -->
</#if>
<#-- 方法类型为DEACTION end -->
</#if>
</#list>
</#if>
</#macro>
<#macro notMajor singleAppMethod singleServiceApi='ERROR'>
<#if item.isMajor() == false && singleServiceApi == 'ERROR'>
<#if item.isMajor()>
<#-- 方法类型为SELECT -->
<#if singleAppMethod.getMethodType() == "SELECT">
// ${singleAppMethod.getCodeName()} ---SELECT
<#-- 方法类型为FETCH -->
<#-- if(context.${item.getCodeName()?lower_case}){ -->
<#if singleServiceApi.getRequestMethod() == 'PUT' || singleServiceApi.getRequestMethod() == 'POST'>
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);
<#else>
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><#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
return res;
<#-- } -->
<#-- 方法类型为FETCH -->
<#elseif singleAppMethod.getMethodType() == "FETCH">
// ${singleAppMethod.getCodeName()} ---FETCH
<#if item.getMinorPSAppDERSs()??>
<#list item.getMinorPSAppDERSs() as singleDeRs>
<#assign majorEntity = singleDeRs.getMajorPSAppDataEntity()/>
const result: any = await this.getLocalCache(context);
if (result) {
return new HttpResponse(200, result, null, { 'x-page': 1, 'x-per-page': 1000, 'x-total': result.length });
}
return new HttpResponse(200, []);
</#list>
</#if>
let tempData:any = JSON.parse(JSON.stringify(data));
let res:any = Http.getInstance().get(`/${srfpluralize(item.codeName)?lower_case}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,tempData,isloading);<#if afterActionStr?? && afterActionStr !="" >
${afterActionStr}</#if>
return res;
<#-- 方法类型为FETCHTEMP -->
<#elseif singleAppMethod.getMethodType() == "FETCHTEMP">
// ${singleAppMethod.getCodeName()} ---FETCHTEMP
<#if item.getMinorPSAppDERSs()??>
<#list item.getMinorPSAppDERSs() as singleDeRs>
<#assign majorEntity = singleDeRs.getMajorPSAppDataEntity()/>
const result: any = await this.getLocalCache(context);
if (result) {
return new HttpResponse(200, result, null, { 'x-page': 1, 'x-per-page': 1000, 'x-total': result.length });
}
return new HttpResponse(200, []);
</#list>
let res:any = Http.getInstance().get(`/${srfpluralize(item.codeName)?lower_case}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>`,data,isloading);<#if afterActionStr?? && afterActionStr !="" >
${afterActionStr}</#if>
return res;
<#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 /><#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
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 /><#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
return res;
<#-- } -->
<#elseif singleServiceApi.getRequestMethod() == "POST">
<#-- REMOVE -->
<#-- if(context.${item.getCodeName()?lower_case}){ -->
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>
return res;
<#-- } -->
<#else>
<#-- if(context.${item.getCodeName()?lower_case}){ -->
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 !="" >
${afterActionStr}</#if>
return res;
<#-- } -->
</#if>
<#-- 指定属性情况end -->
<#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 /><#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
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 /><#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
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}?res.data.${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}:[]));
</#list>
</#if><#if afterActionStr?? && afterActionStr !="" >${afterActionStr}</#if>
return res;
<#else>
<#if singleAppMethod.getCodeName() == "Save">
throw new Error('从实体Save行为暂未实现');
<#elseif singleAppMethod.getCodeName() == "Remove">
<#if item.getMinorPSAppDERSs()??>
<#list item.getMinorPSAppDERSs() as singleDeRs>
<#assign majorEntity = singleDeRs.getMajorPSAppDataEntity()/>
const result: any = await this.getLocalCache(context);
if (result) {
const tempResult: any = result.filter((item: any) => {
return !Object.is(item.${item.getCodeName()?lower_case}, context.${item.getCodeName()?lower_case});
});
if (await this.setLocalCache(context, tempResult)) {
return new HttpResponse(200, data);
}
}
return new HttpResponse(200, null, { code: 100, message: '从数据${item_code_name}删除失败' });
</#list>
<#-- if(context.${item.getCodeName()?lower_case}){ -->
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>
return res;
<#-- } -->
</#if>
<#-- 提交对象数据情况end -->
<#else>
<#-- URI参数传递情况start -->
// URI参数传递情况未实现
<#-- URI参数传递情况start -->
</#if>
<#elseif singleAppMethod.getCodeName() == "Update">
<#if item.getMinorPSAppDERSs()??>
<#list item.getMinorPSAppDERSs() as singleDeRs>
<#assign majorEntity = singleDeRs.getMajorPSAppDataEntity()/>
cosnt result: any[] = await this.getLocalCache(context);
const tempData: Array<any> = [];
if (result && result.length > 0) {
<#-- 方法类型为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) => {
const singleData: any = {};
if (Object.is(item.${item.getCodeName()?lower_case}, context.${item.getCodeName()?lower_case})) {
Object.keys(item).forEach((field: any) =>{
singleData[field] = data[field] ? data[field] : item[field];
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) {
if(Object.keys(singleData).length >0){
tempData.push(singleData);
} else {
}else{
tempData.push(item);
}
}
});
if (await this.setLocalCache(context, tempData)) {
return new HttpResponse(200, tempData);
}
this.tempStorage.setItem(context.srfsessionkey+'_${srfpluralize(item.codeName)?lower_case}',JSON.stringify(tempData));
return {"status":200,"data":data};
}else{
return {"status":500,"data":null};
}
return new HttpResponse(200, null, { code: 100 });
</#list>
</#if>
<#elseif singleAppMethod.getCodeName() == "GetDraft">
const tempData = { ${item.getCodeName()?lower_case}: context.${item.getCodeName()?lower_case}, srfsessionkey: data.srfsessionkey };
<#if item.getMinorPSAppDERSs()??>
<#list item.getMinorPSAppDERSs() as singleDeRs>
<#assign majorEntity = singleDeRs.getMajorPSAppDataEntity()/>
Object.assign(tempData, { ${majorEntity.getCodeName()?lower_case}: context.${majorEntity.getCodeName()?lower_case} });
</#list>
</#if>
return new HttpResponse(200, tempData);
<#elseif singleAppMethod.getCodeName() == "Create">
<#if item.getMinorPSAppDERSs()??>
<#list item.getMinorPSAppDERSs() as singleDeRs>
<#assign majorEntity = singleDeRs.getMajorPSAppDataEntity()/>
cosnt ${item_code_name}: any[] = await this.getLocalCache(context);
if (${item_code_name}) {
data.${item.getCodeName()?lower_case} = null;
${item_code_name}.push(data);
if (await this.setLocalCache(context, ${item_code_name})) {
return new HttpResponse(200, data);
}
}
</#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;
}
return new HttpResponse(200, null, { code: 100, message: '数据创建失败' });
</#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+'_${item_code_name}'),'undefined')){
let result:any = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_${item_code_name}') as any);
if (result) {
let flag: boolean = false;
result.forEach((item:any) => {
if(Object.is(item.${item.getCodeName()?lower_case}, context.${item.getCodeName()?lower_case})){
flag = true;
}
});
}
return new HttpResponse(200, false);
if(data.srffrontuf){
delete data.srffrontuf;
}
</#list>
</#if>
<#elseif singleAppMethod.getCodeName() == "Get">
<#if item.getMinorPSAppDERSs()??>
<#list item.getMinorPSAppDERSs() as singleDeRs>
<#assign majorEntity = singleDeRs.getMajorPSAppDataEntity()/>
const result: any[] = await this.getLocalCache(context);
if (result) {
const tempResult: any = result.find((item:any) => {
return Object.is(item.${item.getCodeName()?lower_case}, context.${item.getCodeName()?lower_case});
${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});
})
return new HttpResponse(200, tempResult || data);
}
return new HttpResponse(200, null, { code: 5001 });
</#list>
</#if>
<#else>
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 = ''/>
......@@ -285,175 +494,236 @@ TARGET=PSAPPDATAENTITY
<#assign path>${path}${srfpluralize(_dataEntity.codeName)?lower_case}/<#noparse>$</#noparse>{context.${_dataEntity.getCodeName()?lower_case}}/</#assign>
</#if>
</#list>
if (${condition}) {
return this.http.post(`${path}${item_code_name}/${singleAppMethod.getCodeName()?lower_case}`, data);
}
if(${condition} true){
return Http.getInstance().post(`${path}${srfpluralize(item.codeName)?lower_case}/${singleAppMethod.getCodeName()?lower_case}`,data,isloading);
}
</#list>
</#if>
</#if>
</#if>
</#if>
</#macro>
import { EntityServiceBase } from '@/ibiz-core';
import { HttpResponse } from '@/ibiz-core/utils';
<#if item.getAllPSAppDELogics()??>
<#list item.getAllPSAppDELogics() as singleLogic>
<#if !P.exists("importService", singleLogic.getId(), "")>
<#if singleLogic.getLogicHolder() == 2 || singleLogic.getLogicHolder() == 3>
import { ${singleLogic.codeName}Logic } from '@/app-core/service/${srffilepath2(singleLogic.getPSAppDataEntity().getCodeName())}/${srffilepath2(singleLogic.getCodeName())}-logic';
</#if>
</#if>
</#list>
</#if>
</#macro>
<#-- 定义service_block end -->
<#-- 设置本地缓存 -->
<#macro setStore appEntity>
await this.setMinorLocalCache(context, res.data);
<#-- 行为执行之前 start -->
<#-- @author zpc -->
<#-- @update 2020.7.14 11:00 -->
<#macro excuteBeforeAction appdeAction>
<#if appdeAction.getBeforePSDEActionLogics?? && appdeAction.getBeforePSDEActionLogics()??>
<#list appdeAction.getBeforePSDEActionLogics() as beforelogic>
<#if beforelogic.getPSDELogic()?? && beforelogic.getPSDELogic().getLogicHolder?? && beforelogic.getPSDELogic().getLogicHolder()?? && (beforelogic.getPSDELogic().getLogicHolder() == 2 || beforelogic.getPSDELogic().getLogicHolder() == 3)>
<#assign singleLogic = beforelogic.getPSDELogic() />
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);
</#if>
</#list>
</#if>
</#macro>
<#-- 获取本地缓存 -->
<#macro getStore appEntity>
Object.assign(data, await this.getMinorLocalCache(context));
<#-- 行为执行之前 end -->
<#-- 行为执行之后 start -->
<#-- @author zpc -->
<#-- @update 2020.7.14 14:00 -->
<#macro excuteAfterAction appdeAction>
<#if appdeAction.getAfterPSDEActionLogics?? && appdeAction.getAfterPSDEActionLogics()??>
<#list appdeAction.getAfterPSDEActionLogics() as afterlogic>
<#if afterlogic.getPSDELogic()?? && afterlogic.getPSDELogic().getLogicHolder?? && afterlogic.getPSDELogic().getLogicHolder()?? && (afterlogic.getPSDELogic().getLogicHolder() == 2 || afterlogic.getPSDELogic().getLogicHolder() == 3)>
<#assign singleLogic = afterlogic.getPSDELogic() />
<@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))});</@compress>
<@compress single_line=true>res = await ${singleLogic.getCodeName()?lower_case}.onExecute(context,res.data,isloading?true:false);</@compress>
</#if>
</#list>
</#if>
</#macro>
<#-- 行为执行之后 end -->
/**
* ${de.getLogicName()}服务对象基类
*
* @export
* @class ${srfclassname(item.getCodeName())}ServiceBase
* @extends {EntityServiceBase}
* @class ${srfclassname('${item.getCodeName()}')}ServiceBase
* @extends {EntityServie}
*/
export class ${srfclassname(item.getCodeName())}ServiceBase extends EntityServiceBase {
export default class ${srfclassname('${item.getCodeName()}')}ServiceBase extends EntityService {
/**
* 当前实体主键标识
* Creates an instance of ${srfclassname('${item.getCodeName()}')}ServiceBase.
*
* @protected
* @type {(string)}
* @memberof ${srfclassname(item.getCodeName())}ServiceBase
* @param {*} [opts={}]
* @memberof ${srfclassname('${item.getCodeName()}')}ServiceBase
*/
protected readonly key: string = '${item.getKeyPSAppDEField().getCodeName()?lower_case}';
constructor(opts: any = {}) {
super(opts);
}
/**
* 当前实体名称
*
* @protected
* @type {(string)}
* @memberof ${srfclassname(item.getCodeName())}ServiceBase
* 初始化基础数据
*
* @memberof ${srfclassname('${item.getCodeName()}')}ServiceBase
*/
protected readonly dePath: string = '${item_code_name}';
<#if item.getMajorPSAppDEField?? && item.getMajorPSAppDEField()??>
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}';
}
/**
* 当前实体主信息标识
*
* @protected
* @type {(string)}
* @memberof ${srfclassname(item.getCodeName())}ServiceBase
*/
protected readonly text: string = '${item.getMajorPSAppDEField().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>
/**
* 请求根路径
*
* @protected
* @type {string}
* @memberof ${srfclassname(item.getCodeName())}ServiceBase
*/
protected readonly rootUrl: string = '';
/**
* 当前应用名
* ${singleAppMethod.getCodeName()}接口方法
*
* @protected
* @type {string}
* @memberof ${srfclassname(item.getCodeName())}ServiceBase
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof ${srfclassname('${item.getCodeName()}')}ServiceBase
*/
protected readonly appName: string = '${app.getCodeName()?lower_case}';
public async ${singleAppMethod.getCodeName()}(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
<#if singleAppMethod.getPSDEAction()??>
<#assign appdeAction = singleAppMethod.getPSDEAction() />
<#-- 检查行为是否可以执行 start -->
<#-- @author zpc -->
<#-- @update 2020.7.13 16:00 -->
<#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>
<#-- 检查行为是否可以执行 end -->
/**
* 当前系统名
*
* @protected
* @type {string}
* @memberof ${srfclassname(item.getCodeName())}ServiceBase
*/
protected readonly systemName: string = '${app.getPSSystem().getCodeName()?lower_case}';
<#-- 行为执行之前 start -->
<#-- @author zpc -->
<#-- @update 2020.7.14 11:00 -->
<@excuteBeforeAction appdeAction = appdeAction />
<#-- 行为执行之前 end -->
<#--是否存在前端处理逻辑start -->
<#if appdeAction.getPSDELogic?? && appdeAction.getPSDELogic()?? && (appdeAction.getActionHolder() == 2 || appdeAction.getActionHolder() == 3) >
<#assign appdelogic = appdeAction.getPSDELogic() />
let appLogic:${srfclassname('${appdelogic.getCodeName()}')}Logic = new ${srfclassname('${appdelogic.getCodeName()}')}Logic({context:JSON.parse(JSON.stringify(context)),data:JSON.parse(JSON.stringify(data))});
const res = await appLogic.onExecute(context,data,isloading?true:false);
<@excuteAfterAction appdeAction = appdeAction />
return {status:200,data:res};
<#else>
<#-- 行为执行之后 start -->
<#-- @author zpc -->
<#-- @update 2020.7.14 14:00 -->
<#assign afterActionStr><@excuteAfterAction appdeAction = appdeAction /></#assign>
<@service_block item=item singleAppMethod=singleAppMethod afterActionStr = afterActionStr/>
<#-- 行为执行之后 end -->
</#if>
<#--是否存在前端处理逻辑end -->
<#else>
<#-- 无实体行为,有接口走接口,无接口走本地供数 start -->
<#-- @author zpc -->
<#-- @update 2020.7.22 17:00 -->
<#if singleAppMethod.getPSDEServiceAPIMethod?? && singleAppMethod.getPSDEServiceAPIMethod()??>
<@service_block item=item singleAppMethod=singleAppMethod />
<#else>
<@local_supply item=item singleAppMethod=singleAppMethod />
</#if>
<#-- 无实体行为,有接口走接口,无接口走本地供数 end -->
</#if>
}
<#-- 查询数据集(post方式)start -->
<#-- @author zpc -->
<#-- @update 2020.7.13 15:00 -->
<#-- <#if singleAppMethod.getMethodType?? && singleAppMethod.getMethodType()?? && singleAppMethod.getMethodType() == "FETCH">
<#assign dataSet = singleAppMethod.getPSDEDataSet() /> -->
/**
* 所有从实体
<#-- /**
* search${dataSet.getCodeName()}接口方法
*
* @protected
* @type {*}
* @memberof ${srfclassname(item.getCodeName())}ServiceBase
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof ${srfclassname('${item.getCodeName()}')}ServiceBase
*/
protected allMinorAppEntity: any = {<#if item.getMajorPSAppDERSs()??>
<#list item.getMajorPSAppDERSs() as deReRs>
<#-- 主实体 -->
<#assign majorPSAppDataEntity = deReRs.getMajorPSAppDataEntity() />
<#-- 从实体 -->
<#assign minorPSAppDataEntity = deReRs.getMinorPSAppDataEntity() />
'${srfpluralize(minorPSAppDataEntity.codeName)?lower_case}': {
name: '${minorPSAppDataEntity.codeName?lower_case}'
},
public async search${dataSet.getCodeName()}(context: any = {},data: any = {}, isloading?: boolean): Promise<any> { -->
<#-- 检查行为是否可以执行 start -->
<#-- @author zpc -->
<#-- @update 2020.7.13 16:00 -->
<#-- <#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>
};
if(${condition}true){
let tempData:any = JSON.parse(JSON.stringify(data));
return 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 Http.getInstance().post(`/${srfpluralize(item.codeName)?lower_case}/search${dataSet.getCodeName()?lower_case}`,tempData,isloading);
</#if>
}
</#if> -->
<#-- 查询数据集(post方式)end -->
<#-- 检查行为是否可以执行 start -->
<#-- @author zpc -->
<#-- @update 2020.7.13 17:00 -->
<#if singleAppMethod.getPSDEAction()??>
<#assign appdeAction = singleAppMethod.getPSDEAction() />
<#if appdeAction.getTestActionMode?? && appdeAction.getTestActionMode()?? && (appdeAction.getTestActionMode() == 1 || appdeAction.getTestActionMode() == 3)>
/**
* Creates an instance of ${srfclassname(item.getCodeName())}ServiceBase.
* @memberof ${srfclassname(item.getCodeName())}ServiceBase
* test${srfclassname('${singleAppMethod.getCodeName()}')}方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @returns {Promise<any>}
* @memberof ${srfclassname('${item.getCodeName()}')}ServiceBase
*/
constructor() {
super('${item.codeName?lower_case}');
<@getTestActionModifier appdeAction=appdeAction/> async test${srfclassname('${singleAppMethod.getCodeName()}')}(context: any = {},data: any = {}): Promise<any> {
return true;
}
<#-- 实体接口调用start -->
<#if item.getAllPSAppDEMethods?? && item.getAllPSAppDEMethods()??>
<#list item.getAllPSAppDEMethods() as singleAppMethod>
<#-- 是否存在实体服务接口方法Start -->
<#if singleAppMethod.getPSDEServiceAPIMethod?? && singleAppMethod.getPSDEServiceAPIMethod()??>
<#assign singleServiceApi = singleAppMethod.getPSDEServiceAPIMethod()/>
</#if>
<#-- 是否存在实体服务接口方法End -->
<#if singleAppMethod.render??>
${singleAppMethod.render.code}
<#else>
<#if singleAppMethod.isBuiltinMethod() == false>
<#-- <#if singleAppMethod.getMethodType?? && singleAppMethod.getMethodType()?? && singleAppMethod.getMethodType() == "FETCH">
<#assign dataSet = singleAppMethod.getPSDEDataSet() />
/**
* ${singleAppMethod.getCodeName()}接口方法
* test${srfclassname('search${dataSet.getCodeName()}')}方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @returns {Promise<HttpResponse>}
* @memberof ${srfclassname(item.getCodeName())}ServiceBase
* @returns {Promise<any>}
* @memberof ${srfclassname('${item.getCodeName()}')}ServiceBase
*/
public async ${singleAppMethod.getCodeName()}(context: any = {}, data: any = {}): Promise<HttpResponse> {
try {
<#-- 定义变量:是否存在前端处理逻辑 -->
<#assign existAppMethodDeAction = (singleAppMethod.getPSDEAction?? && singleAppMethod.getPSDEAction()??)/>
<#if existAppMethodDeAction>
<#assign appdeAction = singleAppMethod.getPSDEAction() />
<@getTestActionModifier appdeAction=appdeAction/> async test${srfclassname('search${dataSet.getCodeName()}')}(context: any = {},data: any = {}): Promise<any> {
return true;
}
</#if> -->
</#if>
<#if existAppMethodDeAction && appdeAction.getPSDELogic?? && appdeAction.getPSDELogic()?? && (appdeAction.getActionHolder() == 2 || appdeAction.getActionHolder() == 3) >
<#assign appdelogic = appdeAction.getPSDELogic() />
const appLogic: ${appdelogic.codeName}Logic = new ${appdelogic.codeName}Logic();
const result = await appLogic.onExecute(context, data);
return new HttpResponse(200, result);
<#else>
<#if singleServiceApi??>
<@appDerPath singleAppMethod = singleAppMethod singleServiceApi = singleServiceApi/>
<@major singleAppMethod = singleAppMethod singleServiceApi = singleServiceApi/>
<@notMajor singleAppMethod = singleAppMethod singleServiceApi = singleServiceApi/>
<#elseif singleAppMethod??>
<@appDerPath singleAppMethod = singleAppMethod/>
<@major singleAppMethod = singleAppMethod/>
<@notMajor singleAppMethod = singleAppMethod/>
</#if>
</#if>
} catch (res) {
return new HttpResponse(res.status, null);
}
}
</#if>
<#-- 检查行为是否可以执行 end -->
</#if>
</#if>
</#list>
</#if>
......
<#ibiztemplate>
TARGET=PSAPPDATAENTITY
</#ibiztemplate>
import { ${srfclassname(item.getCodeName())}ServiceBase } from './${srffilepath2(item.getCodeName())}-service-base';
import { Http,Util } from '@/utils';
import ${srfclassname('${item.getCodeName()}')}ServiceBase from './${srffilepath2(item.getCodeName())}-service-base';
/**
* ${de.getLogicName()}服务对象
*
* @export
* @class ${srfclassname(item.getCodeName())}Service
* @extends {${srfclassname(item.getCodeName())}ServiceBase}
* @class ${srfclassname('${item.getCodeName()}')}Service
* @extends {${srfclassname('${item.getCodeName()}')}ServiceBase}
*/
export class ${srfclassname(item.getCodeName())}Service extends ${srfclassname(item.getCodeName())}ServiceBase { }
// 默认导出
export default ${srfclassname(item.getCodeName())}Service;
\ No newline at end of file
export default class ${srfclassname('${item.getCodeName()}')}Service extends ${srfclassname('${item.getCodeName()}')}ServiceBase {
/**
* Creates an instance of ${srfclassname('${item.getCodeName()}')}Service.
*
* @param {*} [opts={}]
* @memberof ${srfclassname('${item.getCodeName()}')}Service
*/
constructor(opts: any = {}) {
super(opts);
}
}
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册