Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz-Vue-Mob-R7
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7前端标准模板
iBiz-Vue-Mob-R7
提交
437acfde
提交
437acfde
编写于
7月 29, 2020
作者:
KK
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
调整mock
上级
a86ffd7f
变更
1
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
401 行增加
和
810 行删除
+401
-810
%DE_PKGPATH%s.ts.ftl
APP/src/mock/entity/%DE_PKGPATH%s/%DE_PKGPATH%s.ts.ftl
+401
-810
未找到文件。
APP/src/mock/entity/%DE_PKGPATH%s/%DE_PKGPATH%s.ts.ftl
浏览文件 @
437acfde
<#ibiztemplate>
TARGET=PSAPPDATAENTITY
</#ibiztemplate>
import qs from 'qs';
import { MockAdapter } from '@/mock/mock-adapter';
import { Util } from '@/ibiz-core/utils';
const mock = MockAdapter.getInstance();
<#-- 日志方法: BEGIN -->
<#macro startLog appMethod>
console.groupCollapsed("实体:${item.codeName?lower_case} 方法: ${appMethod.getCodeName()}");
console.table({url:config.url, method: config.method, data:config.data});
</#macro>
<#macro endLog appMethod dataName>
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(${dataName});
console.groupEnd();
console.groupEnd();
</#macro>
<#-- 日志方法: END -->
<#-- 输出排序方法: BEGIN -->
<#-- 排序宏 -->
<#macro outputSort priority position>
<#assign outputSort_nested><#nested></#assign>
<#if !outputSort_maxPriority?has_content>
<#assign outputSort_maxPriority = priority>
<#else>
<#if priority gt outputSort_maxPriority >
<#assign outputSort_maxPriority = priority>
</#if>
</#if>
<#assign outputSort_template>${
"<#if position == 'before'>
<#assign outputSort_param"+priority+">
"+r"${outputSort_nested}<#t>"+"
<#if outputSort_param"+priority+"?has_content>"+r"${outputSort_param"+priority+"}</#if><#t>
</#assign>
</#if>
<#if position== 'after'>
<#assign outputSort_param"+priority+">
<#if outputSort_param"+priority+"?has_content>"+r"${outputSort_param"+priority+"}</#if><#t>
"+r"${outputSort_nested}<#t>"+"
</#assign>
</#if>"
}</#assign>
<@outputSort_template?interpret />
</#macro>
<#-- 输出宏 -->
<#macro outputSort_print>
<#if outputSort_maxPriority?has_content && outputSort_maxPriority?is_number>
<#list 0..outputSort_maxPriority as i >
<#assign outputSort_template>${
"<#if outputSort_param"+i+"?has_content>"
+r"${outputSort_param"+i+"}<#t>"
+"</#if>"
}</#assign>
<@outputSort_template?interpret />
</#list>
</#if>
</#macro>
<#-- 重置变量 -->
<#macro outputSort_clear>
<#if outputSort_maxPriority?has_content && outputSort_maxPriority?is_number>
<#list 0..outputSort_maxPriority as i >
<#assign outputSort_template>${
"<#if outputSort_param"+i+"?has_content>"
+r"<#assign outputSort_param"+i+r"=''/>"
+"</#if>"
}</#assign>
<@outputSort_template?interpret />
</#list>
<#assign outputSort_maxPriority='' />
</#if>
</#macro>
<#-- 输出排序方法: END -->
<@outputSort_clear />
// 模拟数据
const mockDatas: Array<any> = [
...
...
@@ -14,906 +83,428 @@ const mockDatas: Array<any> = [
</#if>
];
/**
* 解析参数
*
* @param paramArray 参数数组
* @param regStr 路径正则
* @param url 访问路径
*/
const parsingParameters = (paramArray: Array<string>, regStr: RegExp, url: string): any => {
let params: any = {};
const matchArray: any = new RegExp(regStr).exec(url);
if (matchArray && matchArray.length > 1 && paramArray && paramArray.length > 0) {
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(params, item, {
enumerable: true,
value: matchArray[index + 1],
});
});
}
return params;
};
/**
* 排队路径参数是否存在 null、undefined 或者空字符串等异常情况
*
* @param paramArray
* @param params
*/
const judgmentParametersException = (paramArray: Array<string>, params: any): boolean => {
let isParametersException = false;
if (paramArray.length > 0) {
let state = paramArray.some((key: string) => {
let _value = params[key];
if (!_value || Object.is(_value, '')) {
return true;
}
return false;
});
if (state) {
isParametersException = true;;
}
}
return isParametersException;
};
<#assign isCurWFDE = false>
<#if app.getAppMode()?? && app.getAppMode() == "WFAPP" && app.getAllPSAppWFs()??>
<#list app.getAllPSAppWFs() as appwf>
<#if appwf.getPSWorkflow().getWFProxyMode() == 3 && appwf.getPSWorkflow().getPSWFDEs()??>
<#list appwf.getPSWorkflow().getPSWFDEs() as wfde>
<#if wfde.getWFProxyMode() == 2 && wfde.getCodeName() == de.getCodeName()>
<#assign isCurWFDE = true>
<#break>
</#if>
</#list>
<#if isCurWFDE>
<#break>
</#if>
</#if>
</#list>
</#if>
<#assign isClientWFDE = false>
<#if de.hasPSDEWF() && de.getAllPSDEWFs()??>
<#list de.getAllPSDEWFs() as wfde>
<#if wfde.getWFProxyMode() == 1 >
<#assign isClientWFDE = true>
<#break>
</#if>
</#list>
</#if>
<#assign keyCNLC = "id">
<#assign itemCodeName = item.getCodeName()>
<#assign itemCodeNameLC = itemCodeName?lower_case>
<#-- 主实体 start -->
<#if item.isMajor()>
<#assign parentPath = "" >
<#assign selfPath="\\/" + srfpluralize(itemCodeNameLC) >
<#assign parentParams = "">
<#assign parentSearchParams = "" >
<#assign parentParams2 = "">
<#assign parentParams3 = "">
<#assign idParams = "">
<#assign authParams = "">
<#assign idParams2 = "">
<#assign idParams3 = "">
<#assign etParams = "">
<#assign etParams2 = "">
<#assign etParams3 = "">
<#assign id_etParams = "">
<#assign id_etParams2 = "">
<#assign id_etParams3 = "">
<#assign etParams = etParams + "@RequestBody " + itemCodeName + " " + itemCodeNameLC + "">
<#assign etParams2 = etParams2 + itemCodeName + " " + itemCodeNameLC + "">
<#assign etParams3 = etParams3 + "">
<#assign idParams = idParams + "@PathVariable(\"" + itemCodeNameLC + keyCNLC + "\") " + srfjavatype(de.getKeyPSDEField().stdDataType) + " " + itemCodeNameLC + keyCNLC >
<#assign authParams = "#" + itemCodeNameLC + keyCNLC + ",">
<#assign idParams2 = idParams2 + " " + srfjavatype(de.getKeyPSDEField().stdDataType) + " " + itemCodeNameLC + keyCNLC >
<#assign idParams3 = idParams3 + "'" + itemCodeNameLC + keyCNLC + "'" >
<#assign id_etParams = id_etParams + "@PathVariable(\"" + itemCodeNameLC + keyCNLC + "\") " + srfjavatype(de.getKeyPSDEField().stdDataType) + " " + itemCodeNameLC + keyCNLC + ", @RequestBody " + itemCodeName + " " + itemCodeNameLC + "" >
<#assign id_etParams2 = id_etParams2 + "" + srfjavatype(de.getKeyPSDEField().stdDataType) + " " + itemCodeNameLC + keyCNLC + ", " + itemCodeName + " " + itemCodeNameLC + "," >
<#assign id_etParams3 = id_etParams3 + "'" + itemCodeNameLC + keyCNLC + "'" >
<#assign fullPath = parentPath + selfPath>
<#if item.getAllPSAppDEMethods()??>
<#list item.getAllPSAppDEMethods() as appMethod>
<#if appMethod.getPSDEServiceAPIMethod()??>
<#assign reqMtd = appMethod.getPSDEServiceAPIMethod().getRequestMethod()>
<#if appMethod.getMethodType()=='DEACTION'>
<#assign deaction = appMethod.getPSDEAction()>
<#assign deactionName = deaction.getName()>
<#assign deactionCodeName = deaction.getCodeName()>
<#assign oppriv = "">
<#if deaction.getPSDEOPPriv()??>
<#assign oppriv = deaction.getPSDEOPPriv().getName() >
</#if>
<#if deaction.codeName == 'Create'>
<#-- @RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}")
@PreAuthorize("@${item.getCodeName()?lower_case}_pms.check('${oppriv}')")
public ResponseEntity<${item.getCodeName()}> ${appMethod.getCodeName()?uncap_first}(${etParams}) {
${item.getCodeName()} ${item.getCodeName()?lower_case}2 = ${item.getCodeName()?lower_case}service.${deactionCodeName?uncap_first}(${etParams3});
return ResponseEntity.status(HttpStatus.OK).body(${itemCodeName?lower_case}2);
} -->
//${deactionCodeName}
mock.on${reqMtd?lower_case?cap_first}(new RegExp(/^${fullPath}$/)).reply((config: any) => {
//getwflink
mock.onGet(new RegExp(/^\/wfcore\/${app.getPSSystem().getCodeName()?lower_case}-app-${app.getCodeName()?lower_case}\/${srfpluralize(item.codeName)?lower_case}\/[a-zA-Z0-9\-\;]+\/usertasks\/[a-zA-Z0-9\-\;]+\/ways$/)).reply((config: any) => {
console.groupCollapsed("实体:${item.codeName?lower_case} 方法: getwflink");
console.table({url:config.url, method: config.method, data:config.data});
console.groupEnd();
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
// ${etParams3}
let paramArray: Array<string> = [${etParams3}];
let regStr: RegExp = /^${fullPath}$/;
let url = config.url;
let params = parsingParameters(paramArray, regStr, url);
console.log(params);
let state = judgmentParametersException(paramArray, params);
if (state) {
return [403, null, config.headers, config];
}
let data: any = JSON.parse(config.data);
mockDatas.push(Object.assign({}, data, { ${itemCodeNameLC}${keyCNLC}: Util.createUUID() }))
return [status, mockDatas[mockDatas.length - 1], config.headers, config];
return [status, {}];
}
return [status,[
{"sequenceFlowId":"dfdsfdsfdsfdsfds","sequenceFlowName":"同意",
"taskId":"aaaaddddccccddddd","processDefinitionKey":"support-workorders-approve-v1",
"processInstanceId":"ddlfldldfldsfds","refViewKey":""},
{"sequenceFlowId":"ddssdfdfdfdfsfdf","sequenceFlowName":"不同意",
"taskId":"aaaaddddccccddddd","processDefinitionKey":"support-workorders-approve-v1",
"processInstanceId":"ddfdsldlfdlldsf","refViewKey":"workorder_ltform_editview"}
]];
});
<#elseif deaction.codeName == 'Update'>
<#-- @RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}")
@PreAuthorize("@${item.getCodeName()?lower_case}_pms.check(${authParams}'${oppriv}')")
public ResponseEntity<${itemCodeName}> ${appMethod.getCodeName()?uncap_first}(${id_etParams}) {
${itemCodeName} ${itemCodeName?lower_case}2 = ${itemCodeName?lower_case}service.${deactionCodeName?uncap_first}(${id_etParams3});
return ResponseEntity.status(HttpStatus.OK).body(${itemCodeName?lower_case}2);
} -->
//${deactionCodeName}
mock.on${reqMtd?lower_case?cap_first}(new RegExp(/^${fullPath}\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => {
<#-- mock.on${reqMtd?lower_case?cap_first}('${fullPath}/{${itemCodeNameLC + keyCNLC}}').reply((config: any) => { -->
// getwfstep
mock.onGet(new RegExp(/^\/wfcore\/${app.getPSSystem().getCodeName()?lower_case}-app-${app.getCodeName()?lower_case}\/${srfpluralize(item.codeName)?lower_case}\/process-definitions-nodes$/)).reply((config: any) => {
console.groupCollapsed("实体:${item.codeName?lower_case} 方法: getwfstep");
console.table({url:config.url, method: config.method, data:config.data});
console.groupEnd();
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
// ${id_etParams3}
let paramArray: Array<string> = [${id_etParams3}];
let regStr: RegExp = /^${fullPath}\/([a-zA-Z0-9\-\;]{1,35})$/;
let url = config.url;
let params = parsingParameters(paramArray, regStr, url);
console.log(params);
let state = judgmentParametersException(paramArray, params);
if (state) {
return [403, null, config.headers, config];
}
return [status, {}];
}
return [status, [
{"userTaskId":"sddfddfd-dfdf-fdfd-fdf-dfdfd",
"userTaskName":"待审",
"cnt":0,
"processDefinitionKey":"support-workorders-approve-v1",
"processDefinitionName":"工单审批流程v1"
},
{"userTaskId":"sddfddfd-dfdf-fdfd-fdf-87927",
"userTaskName":"待分配",
"cnt":3,
"processDefinitionKey":"support-workorders-approve-v1",
"processDefinitionName":"工单审批流程v1"}
]];
});
// 遍历键值,获取数据
let items: Array<any> = [];
items = Util.deepCopy(mockDatas);
let state2 = Object.keys(params).some((key: string) => {
let _value = params[key];
let _items = items.filter((data: any) => Object.is(data[key], _value));
if (_items.length === 0) {
return true;
}
items = [];
items = Util.deepCopy(_items);
return false;
});
if (state2) {
return [403, null, config.headers, config];
// createBatch
mock.onPost(new RegExp(/^\/${srfpluralize(item.codeName)?lower_case}\/batch$/)).reply((config: any) => {
console.groupCollapsed("实体:${item.codeName?lower_case} 方法: createBatch");
console.table({url:config.url, method: config.method, data:config.data});
console.groupEnd();
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, {}];
}
return [status, {}];
});
let et_id = Object.keys(params)[Object.keys(params).length - 1]
let et_id_value = params[et_id];
let index = mockDatas.findIndex((data: any) => Object.is(data[et_id], et_id_value)
);
let data: any = JSON.parse(config.data
);
Object.keys(mockDatas[index]).forEach((key: string) => {
if (data.hasOwnProperty(key)
) {
Object.assign(mockDatas[index], { [key]: data[key] })
// updateBatch
mock.onPut(new RegExp(/^\/${srfpluralize(item.codeName)?lower_case}\/batch$/)).reply((config: any) => {
console.groupCollapsed("实体:${item.codeName?lower_case} 方法: updateBatch"
);
console.table({url:config.url, method: config.method, data:config.data});
console.groupEnd(
);
let status = MockAdapter.mockStatus(config);
if (status !== 200
) {
return [status, {}];
}
});
return [status, mockDatas[index], config.headers, config];
return [status, {}];
});
<#elseif deaction.codeName == 'Get'>
<#-- @RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}")
@PreAuthorize("@${item.getCodeName()?lower_case}_pms.check(${authParams}'${oppriv}')")
public ResponseEntity<${itemCodeName}> ${appMethod.getCodeName()?uncap_first}(${idParams}) {
${itemCodeName} ${itemCodeName?lower_case} = ${item.getCodeName()?lower_case}service.${deactionCodeName?uncap_first}(${idParams3});
return ResponseEntity.status(HttpStatus.OK).body(${itemCodeName?lower_case});
} -->
//${deactionCodeName}
mock.on${reqMtd?lower_case?cap_first}(new RegExp(/^${fullPath}\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => {
// removeBatch
mock.onDelete(new RegExp(/^\/${srfpluralize(item.codeName)?lower_case}\/batch$/)).reply((config: any) => {
console.groupCollapsed("实体:${item.codeName?lower_case} 方法: removeBatch");
console.table({url:config.url, method: config.method, data:config.data});
console.groupEnd();
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status,
null
];
return [status,
{}
];
}
// ${idParams3}
let paramArray: Array<string> = [${idParams3}];
let regStr: RegExp = /^${fullPath}\/([a-zA-Z0-9\-\;]{1,35})$/;
let url = config.url;
let params = parsingParameters(paramArray, regStr, url);
console.log(params);
return [status, {}];
});
let state = judgmentParametersException(paramArray, params);
if (state) {
return [403, null, config.headers, config];
}
<#-- 实体接口mock数据:BEGIN -->
<#if item.getAllPSAppDEMethods?? && item.getAllPSAppDEMethods()??>
<#list item.getAllPSAppDEMethods() as singleAppMethod>
<#if singleAppMethod.getPSDEServiceAPIMethod?? && singleAppMethod.getPSDEServiceAPIMethod()??>
<#assign singleServiceApi = singleAppMethod.getPSDEServiceAPIMethod()/>
</#if>
<#-- 应用实体关系路径数大于0 && 拥有实体服务接口方法: BEGIN -->
<#if item.getPSAppDERSPathCount() gt 0 && singleServiceApi??>
<#list 1..item.getPSAppDERSPathCount() as count>
<#assign path = ''/>
<#assign param = ''/>
<#list item.getPSAppDERSPath(count_index) as deRSPath>
<#if deRSPath.getMajorPSAppDataEntity?? && deRSPath.getMajorPSAppDataEntity()??>
<#assign _dataEntity = deRSPath.getMajorPSAppDataEntity()/>
<#assign param>${param}'${_dataEntity.getKeyPSAppDEField().getCodeName()?lower_case}'<#if deRSPath_has_next>,</#if></#assign>
<#assign path>${path}${srfpluralize(_dataEntity.codeName)?lower_case}\/([a-zA-Z0-9\-\;]{1,35})\/</#assign>
</#if>
</#list>
// 遍历键值,获取数据
let items: Array<any> = [];
items = Util.deepCopy(mockDatas);
let state2 = Object.keys(params).some((key: string) => {
let _value = params[key];
let _items = items.filter((data: any) => Object.is(data[key], _value));
if (_items.length === 0) {
return true;
}
items = [];
items = Util.deepCopy(_items);
return false;
});
if (state2) {
return [403, null, config.headers, config];
}
return [status, items[0], config.headers, config];
});
<#-- 方法类型为SELECT: BEGIN -->
<#if singleAppMethod.getMethodType() == "SELECT">
<#elseif deaction.codeName == 'GetDraft'>
<#-- @RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/${deactionCodeName?lower_case}")
@PreAuthorize("@${item.getCodeName()?lower_case}_pms.check('${oppriv}')")
public ResponseEntity<${itemCodeName}> ${appMethod.getCodeName()?uncap_first}() {
//${itemCodeName} ${itemCodeName?lower_case} = ${item.getCodeName()?lower_case}service.${deactionCodeName?uncap_first}(${idParams3});
return ResponseEntity.status(HttpStatus.OK).body(new ${itemCodeName}());
} -->
//${deactionCodeName}
mock.on${reqMtd?lower_case?cap_first}(new RegExp(/^${fullPath}\/${deactionCodeName?lower_case}$/)).reply((config: any) => {
// ${singleAppMethod.getCodeName()}
mock.on${srfclassname('${singleServiceApi.getRequestMethod()?lower_case}')}(new RegExp(/^\/${path}${srfpluralize(item.codeName)?lower_case}\/([a-zA-Z0-9\-\;]{1,35})<#if singleServiceApi.getRequestPath()??>\${singleServiceApi.getRequestPath()}</#if>$/)).reply((config: any) => {
<@startLog singleAppMethod />
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
// ${idParams3}
<#-- let paramArray: Array<string> = [${idParams3}]; -->
let paramArray: Array<string> = [];
let regStr: RegExp = /^${fullPath}\/${deactionCodeName?lower_case}$/;
let url = config.url;
let params = parsingParameters(paramArray, regStr, url);
console.log(params);
let state = judgmentParametersException(paramArray, params);
if (state) {
return [403, null, config.headers, config];
const paramArray:Array<any> = [${param},'${item.getKeyPSAppDEField().getCodeName()?lower_case}'];
const matchArray:any = new RegExp(/^\/${path}${srfpluralize(item.codeName)?lower_case}\/([a-zA-Z0-9\-\;]{1,35})<#if singleServiceApi.getRequestPath()??>\${singleServiceApi.getRequestPath()}</#if>$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
return [status, {}, config.headers, config];
let items = mockDatas ? mockDatas : [];
let _items = items.find((item: any) => Object.is(item.${item.getKeyPSAppDEField().getCodeName()?lower_case}, tempValue.${item.getKeyPSAppDEField().getCodeName()?lower_case}));
<@endLog appMethod=singleAppMethod dataName="_items"/>
return [status, _items];
});
<#-- 方法类型为SELECT: END -->
<#-- 方法类型为FETCH: BEGIN -->
<#elseif singleAppMethod.getMethodType() == "FETCH">
<#elseif deaction.codeName == 'Remove'>
<#-- @RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}")
@PreAuthorize("@${item.getCodeName()?lower_case}_pms.check(${authParams}'${oppriv}')")
public ResponseEntity<Boolean> ${deactionCodeName?uncap_first}(${idParams}) {
boolean b = ${item.getCodeName()?lower_case}service.${deactionCodeName?uncap_first}(${idParams3});
return ResponseEntity.status(HttpStatus.OK).body(b);
} -->
//${deactionCodeName}
mock.on${reqMtd?lower_case?cap_first}(new RegExp(/^${fullPath}\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => {
// ${singleAppMethod.getCodeName()}
mock.onGet(new RegExp(/^\/${path}${srfpluralize(item.codeName)?lower_case}<#if singleServiceApi.getRequestPath()??>\${singleServiceApi.getRequestPath()}</#if>$/)).reply((config: any) => {
<@startLog singleAppMethod />
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
// ${idParams3}
let
paramArray: Array<string> = [${idParams3}]
;
let regStr: RegExp = /^${fullPath}\/([a-zA-Z0-9\-\;]{1,35})$/
;
let url = config.url;
let params = parsingParameters(paramArray, regStr, url);
console.log(params);
let state = judgmentParametersException(paramArray, params);
if (state) {
return [403, null, config.headers, config]
;
const paramArray:Array<any> = [${param}];
let
tempValue: any = {}
;
const matchArray:any = new RegExp(/^\/${path}${srfpluralize(item.codeName)?lower_case}<#if singleServiceApi.getRequestPath()??>\${singleServiceApi.getRequestPath()}</#if>$/).exec(config.url)
;
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
})
;
}
let et_id = Object.keys(params)[Object.keys(params).length - 1]
let et_id_value = params[et_id];
let index = mockDatas.findIndex((data: any) => Object.is(data[et_id], et_id_value));
mockDatas.splice(index, 1);
return [status, null, config.headers, config];
let items = mockDatas ? mockDatas : [];
if (items.length > 0 && paramArray.length > 0) {
paramArray.forEach((paramkey: any) => {
if (tempValue[paramkey] && tempValue[paramkey].indexOf(";") > 0) {
let keysGrounp: Array<any> = tempValue[paramkey].split(new RegExp(/[\;]/));
let tempArray: Array<any> = [];
keysGrounp.forEach((singlekey: any) => {
let _items = items.filter((item: any) => { return item[paramkey] == singlekey });
if(_items.length >0){
tempArray.push(..._items);
}
})
items = tempArray;
} else {
items = items.filter((item: any) => { return item[paramkey] == tempValue[paramkey] });
}
})
}
<@endLog appMethod=singleAppMethod dataName="items"/>
return [status, items];
});
<#-- 方法类型为FETCH: END -->
<#-- 方法类型为DEACTION: BEGIN -->
<#else>
<#-- 方法请求不需要参数情况: BEGIN -->
<#if singleServiceApi.getRequestParamType() == "NONE">
<#elseif deaction.codeName == 'CheckKey'>
<#-- @RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/${deactionCodeName?lower_case}")
@PreAuthorize("@${item.getCodeName()?lower_case}_pms.check('${oppriv}')")
public ResponseEntity<Boolean> ${deactionCodeName?uncap_first}(${etParams}) {
boolean b = ${item.getCodeName()?lower_case}service.${deactionCodeName?uncap_first}(${etParams3});
return ResponseEntity.status(HttpStatus.OK).body(b);
} -->
//${deactionCodeName}
mock.on${reqMtd?lower_case?cap_first}(new RegExp(/^${fullPath}\/${deactionCodeName?lower_case}$/)).reply((config: any) => {
// ${singleAppMethod.getCodeName()}
mock.on${srfclassname('${singleServiceApi.getRequestMethod()?lower_case}')}(new RegExp(/^\/${path}${srfpluralize(item.codeName)?lower_case}<#if singleServiceApi.getRequestPath()??>\${singleServiceApi.getRequestPath()}</#if>$/)).reply((config: any) => {
<@startLog singleAppMethod />
// ${singleAppMethod.getCodeName()}
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
// ${etParams3}
let paramArray: Array<string> = [${etParams3}];
let regStr: RegExp = /^${fullPath}\/${deactionCodeName?lower_case}$/;
let url = config.url;
let params = parsingParameters(paramArray, regStr, url);
console.log(params);
let state = judgmentParametersException(paramArray, params);
if (state) {
return [403, null, config.headers, config];
}
return [status, {
}];
<@endLog appMethod=singleAppMethod dataName="{}"/>
return [status, {}];
});
<#else>
<#-- @RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}/${deactionCodeName?lower_case}")
@PreAuthorize("@${item.getCodeName()?lower_case}_pms.check(${authParams}'${oppriv}')")
public ResponseEntity<${itemCodeName}> ${appMethod.getCodeName()?uncap_first}(${id_etParams}) {
${itemCodeName} ${itemCodeName?lower_case}2 = ${item.getCodeName()?lower_case}service.${deactionCodeName?uncap_first}(${id_etParams3});
return ResponseEntity.status(HttpStatus.OK).body(${itemCodeName?lower_case}2);
} -->
//${deactionCodeName}
mock.on${reqMtd?lower_case?cap_first}(new RegExp(/^${fullPath}\/([a-zA-Z0-9\-\;]{1,35})\/${deactionCodeName?lower_case}$/)).reply((config: any) => {
<#-- 方法请求不需要参数情况: END -->
<#-- 方法请求参数为指定字段属性值: BEGIN -->
<#elseif singleServiceApi.getRequestParamType() == "FIELD">
<@outputSort 1 'after'>
// ${singleAppMethod.getCodeName()}
mock.on${srfclassname('${singleServiceApi.getRequestMethod()?lower_case}')}(new RegExp(/^\/${path}${srfpluralize(item.codeName)?lower_case}\/([a-zA-Z0-9\-\;]{1,35})<#if singleServiceApi.getRequestPath()??>\${singleServiceApi.getRequestPath()}</#if>$/)).reply((config: any) => {
<@startLog singleAppMethod />
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
// ${id_etParams3}
let paramArray: Array<string> = [${id_etParams3}]
;
let
regStr: RegExp = /^${fullPath}\/([a-zA-Z0-9\-\;]{1,35})\/${deactionCodeName?lower_case}$/
;
let url = config.url;
let params = parsingParameters(paramArray, regStr, url);
console.log(params);
let state = judgmentParametersException(paramArray, params);
if (state) {
return [403, null, config.headers, config]
;
const paramArray:Array<any> = [${param},'${item.getKeyPSAppDEField().getCodeName()?lower_case}'];
const matchArray:any = new RegExp(/^\/${path}${srfpluralize(item.codeName)?lower_case}\/([a-zA-Z0-9\-\;]{1,35})<#if singleServiceApi.getRequestPath()??>\${singleServiceApi.getRequestPath()}</#if>$/).exec(config.url)
;
let
tempValue: any = {}
;
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
})
;
}
return [status, {
}];
let items = mockDatas ? mockDatas : [];
let _items = items.find((item: any) => Object.is(item.${item.getKeyPSAppDEField().getCodeName()?lower_case}, tempValue.${item.getKeyPSAppDEField().getCodeName()?lower_case}));
<@endLog appMethod=singleAppMethod dataName="_items?_items:{}"/>
return [status, _items?_items:{}];
});
</#if>
<#elseif appMethod.getMethodType()=='FETCH'>
<#assign deds = appMethod.getPSDEDataSet()>
<#assign oppriv = "">
<#if deds.getPSDEOPPriv()??>
<#assign oppriv = deds.getPSDEOPPriv().getName() >
</#if>
<#-- @RequestMapping(method= RequestMethod.${reqMtd} , value="${fullPath}/fetch<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()?lower_case}<#else>${deds.getCodeName()?lower_case}</#if>")
@PreAuthorize("@${item.getCodeName()?lower_case}_pms.check('${oppriv}')")
public ResponseEntity<List<${itemCodeName}>> ${appMethod.getCodeName()?uncap_first}(<#if parentParams!="">${parentParams},</#if>${itemCodeName}SearchContext searchContext,Pageable pageable) {
${parentSearchParams}
Page<${itemCodeName}> page = ${item.getCodeName()?lower_case}service.fetch<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()}<#else>${deds.getCodeName()}</#if>(<#if parentParams != "">${parentParams3} , </#if>searchContext);
return ResponseEntity.status(HttpStatus.OK)
.header("x-page", String.valueOf(pageable.getPageNumber()))
.header("x-per-page", String.valueOf(pageable.getPageSize()))
.header("x-total", String.valueOf(page.getTotalElements()))
.body(page.getContent());
} -->
//fetch<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()}<#else>${deds.getCodeName()}</#if>
mock.on${reqMtd?lower_case?cap_first}(new RegExp(/^${fullPath}\/fetch<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()?lower_case}<#else>${deds.getCodeName()?lower_case}</#if>(\?[\w-./?%&=]*)*$/)).reply((config: any) => {
</@outputSort>
<#-- 方法请求参数为指定字段属性值: END -->
<#-- 方法请求参数为实体对象数据: BEGIN -->
<#elseif singleServiceApi.getRequestParamType() == "ENTITY">
// ${singleAppMethod.getCodeName()}
mock.on${srfclassname('${singleServiceApi.getRequestMethod()?lower_case}')}(new RegExp(/^\/${path}${srfpluralize(item.codeName)?lower_case}\/([a-zA-Z0-9\-\;]{1,35})<#if singleServiceApi.getRequestPath()??>\${singleServiceApi.getRequestPath()}</#if>$/)).reply((config: any) => {
<@startLog singleAppMethod />
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
// ${parentParams3}
let paramArray: Array<string> = [${parentParams3}];
let regStr: RegExp = /^${fullPath}\/fetch<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()?lower_case}<#else>${deds.getCodeName()?lower_case}</#if>(\?[\w-./?%&=]*)*$/;
let url = config.url;
let params = parsingParameters(paramArray, regStr, url);
console.log(params);
let state = judgmentParametersException(paramArray, params);
if (state) {
return [403, null, config.headers, config];
}
let { headers } = config;
let xTotal = mockDatas.length;
let records: Array<any> = [];
if (config.url.includes('page')) {
let url = config.url;
let xPage = url.split('page=')[1];
let xPerPage = url.split('size=')[1].split('&')[0];
Object.assign(headers, { 'x-page': xPage + '', 'x-per-page': xPerPage + '', 'x-total': xTotal + '' });
let start = xTotal - (xPage * xPerPage);
records = mockDatas.slice(xPage * xPerPage, xPerPage);
} else {
records = [...mockDatas];
const paramArray:Array<any> = [${param},'${item.getKeyPSAppDEField().getCodeName()?lower_case}'];
const matchArray:any = new RegExp(/^\/${path}${srfpluralize(item.codeName)?lower_case}\/([a-zA-Z0-9\-\;]{1,35})<#if singleServiceApi.getRequestPath()??>\${singleServiceApi.getRequestPath()}</#if>$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
return [status, records, config.headers, config];
<@endLog appMethod=singleAppMethod dataName="{}"/>
return [status, {}];
});
</#if>
<#else>
<#if appMethod.getMethodType()=='DEACTION'>
<#assign deaction = appMethod.getPSDEAction()>
<#assign deactionName = deaction.getName()>
<#assign deactionCodeName = deaction.getCodeName()>
<#if deaction.codeName == 'Create'>
<#-- public ResponseEntity<${itemCodeName}> ${appMethod.getCodeName()?uncap_first}(${etParams}) {
return null;
} -->
<#elseif deaction.codeName == 'Update'>
<#-- public ResponseEntity<${itemCodeName}> ${appMethod.getCodeName()?uncap_first}(${id_etParams}) {
return null;
} -->
<#elseif deaction.codeName == 'Get'>
<#-- public ResponseEntity<${itemCodeName}> ${appMethod.getCodeName()?uncap_first}(${idParams}) {
return null;
} -->
<#elseif deaction.codeName == 'GetDraft'>
<#-- public ResponseEntity<${itemCodeName}> ${appMethod.getCodeName()?uncap_first}() {
return null;
} -->
<#elseif deaction.codeName == 'Remove'>
<#-- public ResponseEntity<Boolean> ${deactionCodeName?uncap_first}(${idParams}) {
return null;
} -->
<#elseif deaction.codeName == 'CheckKey'>
<#-- public ResponseEntity<Boolean> ${deactionCodeName?uncap_first}(${etParams}) {
return null;
} -->
<#else>
<#-- public ResponseEntity<${itemCodeName}> ${appMethod.getCodeName()?uncap_first}(${id_etParams}) {
return null;
} -->
</#if>
<#elseif appMethod.getMethodType()=='FETCH'>
<#assign deds = appMethod.getPSDEDataSet()>
<#-- public ResponseEntity<List<${itemCodeName}>> ${appMethod.getCodeName()?uncap_first}() {
return null;
} -->
</#if>
</#if>
</#list>
</#if>
</#if>
<#-- 主实体 end -->
<#-- 关系接口 start -->
<#if item.getPSAppDERSPathCount() gt 0>
<#list 0..1000 as x>
<#if x gte item.getPSAppDERSPathCount()>
<#break>
<#-- 方法请求参数为实体对象数据: END -->
<#-- 方法请求参数为URI参数数据: BEGIN -->
<#else>
<#assign parentPath = "" >
<#assign selfPath="/" + srfpluralize(itemCodeNameLC) >
<#assign parentParams = "">
<#assign byParams = "By">
<#assign parentSearchParams = "" >
<#assign parentParams2 = "">
<#assign parentParams3 = "">
<#assign parentAuthParams = "">
<#assign parentAuthParams2 = "">
<#assign idParams = "">
<#assign authParams = "">
<#assign idParams2 = "">
<#assign idParams3 = "">
<#assign etParams = "">
<#assign etParams2 = "">
<#assign etParams3 = "">
<#assign id_etParams = "">
<#assign id_etParams2 = "">
<#assign id_etParams3 = "">
<#list item.getPSAppDERSPath(x) as rs>
<#assign rsMainAppDe = rs.getMajorPSAppDataEntity()>
<#assign rsMainDe = rsMainAppDe.getPSDataEntity()>
<#assign rsMainAppDeCN = rsMainAppDe.codeName >
<#assign rsMainAppDeCNLC = rsMainAppDeCN?lower_case >
<#assign rsMainDePKCN = rsMainDe.getKeyPSDEField().codeName >
<#assign rsMainDePKCNLC = rsMainDePKCN?lower_case >
<#assign rsMainDePKDataType = rsMainDe.getKeyPSDEField().stdDataType >
<#assign parentPath += "/" + srfpluralize(rsMainAppDeCNLC)?lower_case + "/{" + rsMainAppDeCNLC + keyCNLC + "}" >
<#if x != 0>
<#assign parentParams += ", ">
</#if>
<#assign parentParams += "@PathVariable(\"" + rsMainAppDeCNLC + keyCNLC + "\") " + srfjavatype(rsMainDePKDataType) + " " + rsMainAppDeCNLC + keyCNLC >
<#assign byParams += rsMainAppDeCN >
<#assign parentAuthParams = parentAuthParams + "#" + rsMainAppDeCNLC + keyCNLC + ",">
<#assign parentAuthParams2 = parentAuthParams2 + "#" + rsMainAppDeCNLC + keyCNLC + ",">
<#if rs.getPSDER1N()??>
<#assign parentSearchParams += "searchContext.setN_" + rs.getPSDER1N().getPSPickupDEField().getCodeName()?lower_case + "_eq("+ rsMainAppDeCNLC + keyCNLC +");" >
// URI参数传递情况未实现
</#if>
<#assign parentParams2 += "" + srfjavatype(rsMainDePKDataType) + " " + rsMainAppDeCNLC + keyCNLC >
<#assign parentParams3 += "" + rsMainAppDeCNLC + keyCNLC >
<#if parentParams != "" >
<#assign idParams = parentParams + ", ">
<#assign idParams2 = parentParams2 + ", ">
<#assign idParams3 = parentParams3 + ", ">
<#assign etParams = parentParams + ", ">
<#assign etParams2 = parentParams2 + ", ">
<#assign etParams3 = parentParams3 + ", ">
<#assign id_etParams = parentParams + ", ">
<#assign id_etParams2 = parentParams2 + ", ">
<#assign id_etParams3 = parentParams3 + ", ">
<#-- 方法请求参数为URI参数数据: END -->
</#if>
<#-- 方法类型为DEACTION: END -->
</#list>
<#assign etParams = etParams + "@RequestBody " + itemCodeName + " " + itemCodeNameLC + "">
<#assign etParams2 = etParams2 + itemCodeName + " " + itemCodeNameLC + "">
<#assign etParams3 = etParams3 + itemCodeNameLC + "">
<#assign idParams = idParams + "@PathVariable(\"" + itemCodeNameLC + keyCNLC + "\") " + srfjavatype(de.getKeyPSDEField().stdDataType) + " " + itemCodeNameLC + keyCNLC >
<#assign authParams = "#" + itemCodeNameLC + keyCNLC + ",">
<#assign idParams2 = idParams2 + " " + srfjavatype(de.getKeyPSDEField().stdDataType) + " " + itemCodeNameLC + keyCNLC >
<#assign idParams3 = idParams3 + " " + itemCodeNameLC + keyCNLC >
<#assign id_etParams = id_etParams + "@PathVariable(\"" + itemCodeNameLC + keyCNLC + "\") " + srfjavatype(de.getKeyPSDEField().stdDataType) + " " + itemCodeNameLC + keyCNLC + ", @RequestBody " + itemCodeName + " " + itemCodeNameLC + "" >
<#assign id_etParams2 = id_etParams2 + "" + srfjavatype(de.getKeyPSDEField().stdDataType) + " " + itemCodeNameLC + keyCNLC + ", " + itemCodeName + " " + itemCodeNameLC + "" >
<#assign id_etParams3 = id_etParams3 + "" + itemCodeNameLC + keyCNLC + ", " + itemCodeNameLC + "" >
<#assign fullPath = parentPath + selfPath>
<#if item.getAllPSAppDEMethods()??>
<#list item.getAllPSAppDEMethods() as appMethod>
<#if appMethod.getPSDEServiceAPIMethod()??>
<#assign reqMtd = appMethod.getPSDEServiceAPIMethod().getRequestMethod()>
<#if appMethod.getMethodType()=='DEACTION'>
<#assign deaction = appMethod.getPSDEAction()>
<#assign deactionName = deaction.getName()>
<#assign deactionCodeName = deaction.getCodeName()>
<#assign oppriv = "">
<#if deaction.getPSDEOPPriv()??>
<#assign oppriv = deaction.getPSDEOPPriv().getName() >
</#if>
<#if deaction.codeName == 'Create'
>
<#-- @RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}")
@PreAuthorize("@${item.getCodeName()?lower_case}_pms.check${byParams}(${parentAuthParams2}'${oppriv}')")
public ResponseEntity<${item.getCodeName()}> ${appMethod.getCodeName()?uncap_first}${byParams}(${etParams}) {
${item.getCodeName()} ${item.getCodeName()?lower_case}2 = ${item.getCodeName()?lower_case}service.${deactionCodeName?uncap_first}${byParams}(${etParams3});
return ResponseEntity.status(HttpStatus.OK).body(${itemCodeName?lower_case}2);
} -->
//${deaction.codeName}
mock.on${reqMtd?lower_case?cap_first}('${fullPath}').reply((config: any) => {
<#-- 应用实体关系路径数大于0 && 拥有实体服务接口方法: END --
>
<#-- 主实体方法: BEGIN -->
<#if item.isMajor()>
<#-- 方法类型为SELECT: BEGIN -->
<#if singleAppMethod.getMethodType() == "SELECT">
// ${singleAppMethod.getCodeName()}
mock.on${srfclassname('${singleServiceApi.getRequestMethod()?lower_case}')}(new RegExp(/^\/${srfpluralize(item.codeName)?lower_case}\/([a-zA-Z0-9\-\;]{1,35})<#if singleServiceApi.getRequestPath()??>\${singleServiceApi.getRequestPath()}</#if>$/)).reply((config: any) => {
<@startLog singleAppMethod />
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
return [status, {
}];
const paramArray:Array<any> = ['${item.getKeyPSAppDEField().getCodeName()?lower_case}'];
const matchArray:any = new RegExp(/^\/${srfpluralize(item.codeName)?lower_case}\/([a-zA-Z0-9\-\;]{1,35})<#if singleServiceApi.getRequestPath()??>\${singleServiceApi.getRequestPath()}</#if>$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
let items = mockDatas ? mockDatas : [];
let _items = items.find((item: any) => Object.is(item.${item.getKeyPSAppDEField().getCodeName()?lower_case}, tempValue.${item.getKeyPSAppDEField().getCodeName()?lower_case}));
<@endLog appMethod=singleAppMethod dataName="_items"/>
return [status, _items];
});
<#-- 方法类型为SELECT: EWND -->
<#-- 方法类型为FETCH: BEGIN -->
<#elseif singleAppMethod.getMethodType() == "FETCH">
<#elseif deaction.codeName == 'Update'>
<#-- @RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}")
@PreAuthorize("@${item.getCodeName()?lower_case}_pms.check${byParams}(${parentAuthParams}${authParams}'${oppriv}')")
public ResponseEntity<${itemCodeName}> ${appMethod.getCodeName()?uncap_first}${byParams}(${id_etParams}) {
${itemCodeName} ${itemCodeName?lower_case}2 = ${itemCodeName?lower_case}service.${deactionCodeName?uncap_first}${byParams}(${id_etParams3});
return ResponseEntity.status(HttpStatus.OK).body(${itemCodeName?lower_case}2);
} -->
//${deaction.codeName}
mock.on${reqMtd?lower_case?cap_first}('${fullPath}/{${itemCodeNameLC + keyCNLC}').reply((config: any) => {
// ${singleAppMethod.getCodeName()}
mock.onGet(new RegExp(/^\/${srfpluralize(item.codeName)?lower_case}<#if singleServiceApi.getRequestPath()??>\${singleServiceApi.getRequestPath()}</#if>$/)).reply((config: any) => {
<@startLog singleAppMethod />
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
return [status, {
}
];
<@endLog appMethod=singleAppMethod dataName="mockDatas"/>
return [status, mockDatas ? mockDatas : []
];
});
<#elseif deaction.codeName == 'Get'>
<#-- @RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}")
@PreAuthorize("@${item.getCodeName()?lower_case}_pms.check${byParams}(${parentAuthParams}${authParams}'${oppriv}')")
public ResponseEntity<${itemCodeName}> ${appMethod.getCodeName()?uncap_first}${byParams}(${idParams}) {
${itemCodeName} ${itemCodeName?lower_case} = ${item.getCodeName()?lower_case}service.${deactionCodeName?uncap_first}${byParams}(${idParams3});
return ResponseEntity.status(HttpStatus.OK).body(${itemCodeName?lower_case});
} -->
//${deaction.codeName}
mock.on${reqMtd?lower_case?cap_first}('${fullPath}/{${itemCodeNameLC + keyCNLC}').reply((config: any) => {
// ${singleAppMethod.getCodeName()}
mock.onGet(new RegExp(/^\/${srfpluralize(item.codeName)?lower_case}<#if singleServiceApi.getRequestPath()??>\${singleServiceApi.getRequestPath()}</#if>(\?[\w-./?%&=,]*)*$/)).reply((config: any) => {
<@startLog singleAppMethod />
if(config.url.includes('page')){
let url = config.url.split('?')[1];
let params = qs.parse(url);
Object.assign(config, params);
}
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
return [status, {
}];
let total = mockDatas.length;
let records: Array<any> = [];
if(!config.page || !config.size){
records = mockDatas;
}else{
if((config.page-1)*config.size < total){
records = mockDatas.slice(config.page,config.size);
}
}
<#-- if(config.query){
records = records.filter(item => {
return item.accountname.includes(config.query);
})
} -->
<@endLog appMethod=singleAppMethod dataName="records ? records : []"/>
return [status, records ? records : []];
});
<#-- 方法类型为FETCH: END -->
<#-- 方法类型为DEACTION: BEGIN -->
<#else>
<#-- 方法请求不需要参数情况: BEGIN -->
<#if singleServiceApi.getRequestParamType() == "NONE">
<#elseif deaction.codeName == 'GetDraft'>
<#-- @RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/${deactionCodeName?lower_case}")
@PreAuthorize("@${item.getCodeName()?lower_case}_pms.check${byParams}(${parentAuthParams2}'${oppriv}')")
public ResponseEntity<${itemCodeName}> ${appMethod.getCodeName()?uncap_first}${byParams}() {
//${itemCodeName} ${itemCodeName?lower_case} = ${item.getCodeName()?lower_case}service.${deactionCodeName?uncap_first}${byParams}(${idParams3});
return ResponseEntity.status(HttpStatus.OK).body(new ${itemCodeName}());
} -->
//${deaction.codeName}
mock.on${reqMtd?lower_case?cap_first}('${fullPath}/${deactionCodeName?lower_case}').reply((config: any) => {
// ${singleAppMethod.getCodeName()}
mock.on${srfclassname('${singleServiceApi.getRequestMethod()?lower_case}')}(new RegExp(/^\/${srfpluralize(item.codeName)?lower_case}<#if singleServiceApi.getRequestPath()??>\${singleServiceApi.getRequestPath()}</#if>$/)).reply((config: any) => {
<@startLog singleAppMethod />
// ${singleAppMethod.getCodeName()}
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
return [status, {
}];
<@endLog appMethod=singleAppMethod dataName="{}"/>
return [status, {
}];
});
<#elseif deaction.codeName == 'Remove'>
<#-- @RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}")
@PreAuthorize("@${item.getCodeName()?lower_case}_pms.check${byParams}(${parentAuthParams}${authParams}'${oppriv}')")
public ResponseEntity<Boolean> ${deactionCodeName?uncap_first}${byParams}(${idParams}) {
boolean b = ${item.getCodeName()?lower_case}service.${deactionCodeName?uncap_first}${byParams}(${idParams3});
return ResponseEntity.status(HttpStatus.OK).body(b);
} -->
//${deaction.codeName}
mock.on${reqMtd?lower_case?cap_first}('${fullPath}/{${itemCodeNameLC + keyCNLC}}').reply((config: any) => {
<#-- 方法请求不需要参数情况: END -->
<#-- 方法请求参数为指定字段属性值: BEGIN -->
<#elseif singleServiceApi.getRequestParamType() == "FIELD">
<@outputSort 1 'after'>
// ${singleAppMethod.getCodeName()}
mock.on${srfclassname('${singleServiceApi.getRequestMethod()?lower_case}')}(new RegExp(/^\/${srfpluralize(item.codeName)?lower_case}\/([a-zA-Z0-9\-\;]{1,35})<#if singleServiceApi.getRequestPath()??>\${singleServiceApi.getRequestPath()}</#if>$/)).reply((config: any) => {
<@startLog singleAppMethod />
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
return [status, {
}];
const paramArray:Array<any> = ['${item.getKeyPSAppDEField().getCodeName()?lower_case}'];
const matchArray:any = new RegExp(/^\/${srfpluralize(item.codeName)?lower_case}\/([a-zA-Z0-9\-\;]{1,35})<#if singleServiceApi.getRequestPath()??>\${singleServiceApi.getRequestPath()}</#if>$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
let items = mockDatas ? mockDatas : [];
let _items = items.find((item: any) => Object.is(item.${item.getKeyPSAppDEField().getCodeName()?lower_case}, tempValue.${item.getKeyPSAppDEField().getCodeName()?lower_case}));
<@endLog appMethod=singleAppMethod dataName="_items?_items:{}"/>
return [status, _items?_items:{}];
});
<#elseif deaction.codeName == 'CheckKey'>
<#-- @RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/${deactionCodeName?lower_case}")
@PreAuthorize("@${item.getCodeName()?lower_case}_pms.check${byParams}(${parentAuthParams2}'${oppriv}')")
public ResponseEntity<Boolean> ${deactionCodeName?uncap_first}${byParams}(${etParams}) {
boolean b = ${item.getCodeName()?lower_case}service.${deactionCodeName?uncap_first}${byParams}(${etParams3});
return ResponseEntity.status(HttpStatus.OK).body(b);
} -->
//${deaction.codeName}
mock.on${reqMtd?lower_case?cap_first}('${fullPath}/${deactionCodeName?lower_case}').reply((config: any) => {
</@outputSort>
<#-- 方法请求参数为指定字段属性值: END -->
<#-- 方法请求参数为实体对象数据: BEGIN -->
<#elseif singleServiceApi.getRequestParamType() == "ENTITY">
// ${singleAppMethod.getCodeName()}
mock.on${srfclassname('${singleServiceApi.getRequestMethod()?lower_case}')}(new RegExp(/^\/${srfpluralize(item.codeName)?lower_case}\/?([a-zA-Z0-9\-\;]{0,35})<#if singleServiceApi.getRequestPath()??>\${singleServiceApi.getRequestPath()}</#if>$/)).reply((config: any) => {
<@startLog singleAppMethod />
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
return [status, {
}];
});
const paramArray:Array<any> = ['${item.getKeyPSAppDEField().getCodeName()?lower_case}'];
const matchArray:any = new RegExp(/^\/${srfpluralize(item.codeName)?lower_case}\/([a-zA-Z0-9\-\;]{1,35})<#if singleServiceApi.getRequestPath()??>\${singleServiceApi.getRequestPath()}</#if>$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
<#if singleAppMethod.getCodeName() == "Create">
<@endLog appMethod=singleAppMethod dataName="mockDatas[0]"/>
return [status, mockDatas[0]];
<#else>
<#-- @RequestMapping(method = RequestMethod.${reqMtd}, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}/${deactionCodeName?lower_case}")
@PreAuthorize("@${item.getCodeName()?lower_case}_pms.check${byParams}(${parentAuthParams}${authParams}'${oppriv}')")
public ResponseEntity<${itemCodeName}> ${appMethod.getCodeName()?uncap_first}${byParams}(${id_etParams}) {
${itemCodeName} ${itemCodeName?lower_case}2 = ${item.getCodeName()?lower_case}service.${deactionCodeName?uncap_first}${byParams}(${id_etParams3});
return ResponseEntity.status(HttpStatus.OK).body(${itemCodeName?lower_case}2);
} -->
//${deaction.codeName}
mock.on${reqMtd?lower_case?cap_first}('${fullPath}/{${itemCodeNameLC + keyCNLC}}/${deactionCodeName?lower_case}').reply((config: any) => {
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
//let items = mockDatas ? mockDatas : [];
//let _items = items.find((item: any) => Object.is(item.${item.getKeyPSAppDEField().getCodeName()?lower_case}, tempValue.${item.getKeyPSAppDEField().getCodeName()?lower_case}));
let data = JSON.parse(config.data);
mockDatas.forEach((item)=>{
if(item['${item.getKeyPSAppDEField().getCodeName()?lower_case}'] == tempValue['${item.getKeyPSAppDEField().getCodeName()?lower_case}'] ){
for(let value in data){
if(item.hasOwnProperty(value)){
item[value] = data[value];
}
return [status, {
}];
});
</#if>
<#elseif appMethod.getMethodType()=='FETCH'>
<#assign deds = appMethod.getPSDEDataSet()>
<#if deds.getPSDEOPPriv()??>
<#assign oppriv = deds.getPSDEOPPriv().getName() >
</#if>
<#-- @RequestMapping(method= RequestMethod.${reqMtd} , value="${fullPath}/fetch<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()?lower_case}<#else>${deds.getCodeName()?lower_case}</#if>")
@PreAuthorize("@${item.getCodeName()?lower_case}_pms.check${byParams}(${parentAuthParams2}'${oppriv}')")
public ResponseEntity<List<${itemCodeName}>> ${appMethod.getCodeName()?uncap_first}${byParams}(<#if parentParams!="">${parentParams},</#if>${itemCodeName}SearchContext searchContext,Pageable pageable) {
${parentSearchParams}
Page<${itemCodeName}> page = ${item.getCodeName()?lower_case}service.fetch<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()}<#else>${deds.getCodeName()}</#if>${byParams}(<#if parentParams != "">${parentParams3} , </#if>searchContext);
return ResponseEntity.status(HttpStatus.OK)
.header("x-page", String.valueOf(pageable.getPageNumber()))
.header("x-per-page", String.valueOf(pageable.getPageSize()))
.header("x-total", String.valueOf(page.getTotalElements()))
.body(page.getContent());
} -->
//${deaction.codeName}
mock.on${reqMtd?lower_case?cap_first}('${fullPath}/fetch<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()?lower_case}<#else>${deds.getCodeName()?lower_case}</#if>').reply((config: any) => {
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
return [status, {
}
];
});
}
}
)
<@endLog appMethod=singleAppMethod dataName="data"/>
return [status, data];
</#if>
});
<#-- 方法请求参数为实体对象数据: END -->
<#-- 方法请求参数为URI参数数据: BEGIN -->
<#else>
<#if appMethod.getMethodType()=='DEACTION'>
<#assign deaction = appMethod.getPSDEAction()>
<#assign deactionName = deaction.getName()>
<#assign deactionCodeName = deaction.getCodeName()>
<#if deaction.codeName == 'Create'>
<#-- public ResponseEntity<${itemCodeName}> ${appMethod.getCodeName()?uncap_first}${byParams}(${etParams}) {
return null;
} -->
<#elseif deaction.codeName == 'Update'>
<#-- public ResponseEntity<${itemCodeName}> ${appMethod.getCodeName()?uncap_first}${byParams}(${id_etParams}) {
return null;
} -->
<#elseif deaction.codeName == 'Get'>
<#-- public ResponseEntity<${itemCodeName}> ${appMethod.getCodeName()?uncap_first}${byParams}(${idParams}) {
return null;
} -->
<#elseif deaction.codeName == 'GetDraft'>
<#-- public ResponseEntity<${itemCodeName}> ${appMethod.getCodeName()?uncap_first}${byParams}() {
return null;
} -->
<#elseif deaction.codeName == 'Remove'>
<#-- public ResponseEntity<Boolean> ${deactionCodeName?uncap_first}${byParams}(${idParams}) {
return null;
} -->
<#elseif deaction.codeName == 'CheckKey'>
<#-- public ResponseEntity<Boolean> ${deactionCodeName?uncap_first}${byParams}(${etParams}) {
return null;
} -->
<#else>
<#-- public ResponseEntity<${itemCodeName}> ${appMethod.getCodeName()?uncap_first}${byParams}(${id_etParams}) {
return null;
} -->
</#if>
<#elseif appMethod.getMethodType()=='FETCH'>
<#assign deds = appMethod.getPSDEDataSet()>
<#-- public ResponseEntity<List<${itemCodeName}>> ${appMethod.getCodeName()?uncap_first}${byParams}() {
return null;
} -->
</#if>
</#if>
</#list>
// URI参数传递情况未实现
</#if>
<#-- 方法请求参数为URI参数数据: END -->
</#if>
</#list>
</#if>
<#-- 关系接口 end -->
<#assign isCurWFDE = false>
<#if app.getAppMode()?? && app.getAppMode() == "WFAPP" && app.getAllPSAppWFs()??>
<#list app.getAllPSAppWFs() as appwf>
<#if appwf.getPSWorkflow().getWFProxyMode() == 3 && appwf.getPSWorkflow().getPSWFDEs()??>
<#list appwf.getPSWorkflow().getPSWFDEs() as wfde>
<#if wfde.getWFProxyMode() == 2 && wfde.getCodeName() == de.getCodeName()>
<#assign isCurWFDE = true>
<#break>
</#if>
</#list>
<#if isCurWFDE>
<#break>
</#if>
<#-- 方法类型为DEACTION: END -->
</#if>
<#-- 主实体方法: END -->
</#list>
</#if>
<#-- 实体接口mock数据end -->
<#if isCurWFDE>
<#assign itemPKParam = itemCodeNameLC + keyCNLC>
<#assign wfFuncParams = "@PathVariable(\"" + itemCodeNameLC + keyCNLC + "\") " + srfjavatype(de.getKeyPSDEField().stdDataType) + " " + itemPKParam + ", @RequestBody JSONObject data">
<#assign wfFuncParams2 = itemPKParam + ", data">
/** 工作流行为 **/
/**
* 开始流程【WFStart】
*/
<#-- @RequestMapping(method = RequestMethod.POST, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}/wfstart")
public ResponseEntity<JSONObject> wfStart(${wfFuncParams}) {
if (${item.getCodeName()?lower_case}service.wfStart(${wfFuncParams2})) {
return ResponseEntity.status(HttpStatus.OK).body(data);
} else {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(data);
}
} -->
/**
* 流程处理【WFSubmit】
*/
<#-- @RequestMapping(method = RequestMethod.POST, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}/wfsubmit")
public ResponseEntity<JSONObject> wfSubmit(${wfFuncParams}) {
if (${item.getCodeName()?lower_case}service.wfSubmit(${wfFuncParams2})) {
return ResponseEntity.status(HttpStatus.OK).body(data);
} else {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(data);
}
} -->
/**
* 流程结束【WFClose】
*/
<#-- @RequestMapping(method = RequestMethod.POST, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}/wfclose")
public ResponseEntity<JSONObject> wfClose(${wfFuncParams}) {
if (${item.getCodeName()?lower_case}service.wfClose(${wfFuncParams2})) {
return ResponseEntity.status(HttpStatus.OK).body(data);
} else {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(data);
}
} -->
/**
* 流程跳转【WFGoto】
*/
<#-- @RequestMapping(method = RequestMethod.POST, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}/wfgoto")
public ResponseEntity<JSONObject> wfGoto(${wfFuncParams}) {
if (${item.getCodeName()?lower_case}service.wfGoto(${wfFuncParams2})) {
return ResponseEntity.status(HttpStatus.OK).body(data);
} else {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(data);
}
} -->
/**
* 流程重启【WFRestart】
*/
<#-- @RequestMapping(method = RequestMethod.POST, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}/wfrestart")
public ResponseEntity<JSONObject> wfRestart(${wfFuncParams}) {
if (${item.getCodeName()?lower_case}service.wfRestart(${wfFuncParams2})) {
return ResponseEntity.status(HttpStatus.OK).body(data);
} else {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(data);
}
} -->
/**
* 流程撤回【WFRollback】
*/
<#-- @RequestMapping(method = RequestMethod.POST, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}/wfrollback")
public ResponseEntity<JSONObject> wfRollback(${wfFuncParams}) {
if (${item.getCodeName()?lower_case}service.wfRollback(${wfFuncParams2})) {
return ResponseEntity.status(HttpStatus.OK).body(data);
} else {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(data);
}
} -->
/**
* 流程退回【WFSendBack】
*/
<#-- @RequestMapping(method = RequestMethod.POST, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}/wfsendback")
public ResponseEntity<JSONObject> wfSendBack(${wfFuncParams}) {
if (${item.getCodeName()?lower_case}service.wfSendBack(${wfFuncParams2})) {
return ResponseEntity.status(HttpStatus.OK).body(data);
} else {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(data);
}
} -->
/**
* 流程重新分配【WFReassign】
*/
<#-- @RequestMapping(method = RequestMethod.POST, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}/wfreassign")
public ResponseEntity<JSONObject> wfReassign(${wfFuncParams}) {
if (${item.getCodeName()?lower_case}service.wfReassign(${wfFuncParams2})) {
return ResponseEntity.status(HttpStatus.OK).body(data);
} else {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(data);
}
} -->
/**
* 流程标记已读【WFMarkRead】
*/
<#-- @RequestMapping(method = RequestMethod.POST, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}/wfmarkread")
public ResponseEntity<JSONObject> wfMarkRead(${wfFuncParams}) {
if (${item.getCodeName()?lower_case}service.wfMarkRead(${wfFuncParams2})) {
return ResponseEntity.status(HttpStatus.OK).body(data);
} else {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(data);
}
} -->
</#if>
<#-- 客户端 流程 实体 启动 -->
<#if isClientWFDE>
<#-- @RequestMapping(method= RequestMethod.GET , value="${fullPath}/wfstart")
public ResponseEntity<JSONObject> wfStart() {
return ResponseEntity.status(HttpStatus.OK).body(${item.getCodeName()?lower_case}service.wfStart());
} -->
</#if>
<@outputSort_print />
\ No newline at end of file
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录