提交 9fc6a6ec 编写于 作者: KK's avatar KK

mock 调整

上级 e4d32131
......@@ -138,6 +138,40 @@ const judgmentParametersException = (paramArray: Array<string>, params: any): bo
${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);
} -->
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) => {
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];
}
return [status, records, config.headers, config];
});
//${deactionCodeName}
mock.on${reqMtd?lower_case?cap_first}(new RegExp(/^${fullPath}$/)).reply((config: any) => {
let status = MockAdapter.mockStatus(config);
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册