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

调整实体数据服务

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