fix (接口定义): 修复sql类型结果只显示一个的问题

--bug=1007307 --user=赵勇 【接口定义】-编辑SQL接口-test-添加多条SQL语句执行不生效仅执行一条 https://www.tapd.cn/55049933/s/1057511
This commit is contained in:
fit2-zhao 2021-10-21 18:51:41 +08:00 committed by fit2-zhao
parent c73e5bccf0
commit 18f3b2b082
2 changed files with 62 additions and 85 deletions

View File

@ -55,7 +55,6 @@ public class TestResultService {
try { try {
ApiTestReport report = null; ApiTestReport report = null;
ApiTestReportVariable reportTask = null; ApiTestReportVariable reportTask = null;
String reportUrl = null;
String planScenarioId = null; String planScenarioId = null;
// 这部分后续优化只留 DEFINITION SCENARIO 两部分 // 这部分后续优化只留 DEFINITION SCENARIO 两部分
if (StringUtils.equals(runMode, ApiRunMode.DEBUG.name())) { if (StringUtils.equals(runMode, ApiRunMode.DEBUG.name())) {
@ -129,9 +128,6 @@ public class TestResultService {
reportTask.setExecutionEnvironment(name); reportTask.setExecutionEnvironment(name);
SystemParameterService systemParameterService = CommonBeanFactory.getBean(SystemParameterService.class); SystemParameterService systemParameterService = CommonBeanFactory.getBean(SystemParameterService.class);
assert systemParameterService != null; assert systemParameterService != null;
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
reportUrl = baseSystemConfigDTO.getUrl() + "/#/api/automation/report";
} }
testResult.setTestId(scenarioReport.getScenarioId()); testResult.setTestId(scenarioReport.getScenarioId());
planScenarioId = scenarioReport.getTestPlanScenarioId(); planScenarioId = scenarioReport.getTestPlanScenarioId();

View File

@ -39,49 +39,28 @@
if (!this.body) { if (!this.body) {
return; return;
} }
let rowArry = this.body.split("\n"); let rowArray = this.body.split("\n");
// //
if (rowArry.length > 100) { if (rowArray.length > 100) {
rowArry = rowArry.slice(0, 100); rowArray = rowArray.slice(0, 100);
}
this.getTableData(rowArry);
if (this.tables.length > 1) {
for (let i = 0; i < this.tables.length; i++) {
if (this.tables[i].titles.length === 1 && i < this.tables.length - 1) {
this.tables[i].tableData.splice(this.tables[i].tableData.length - 1, 1);
}
}
let lastTable = this.tables[this.tables.length - 1];
if (lastTable.titles.length === 1) {
if (lastTable.tableData.length > 4) {
lastTable.tableData.splice(lastTable.tableData.length - 4, 4);
} else {
this.tables.splice(this.tables.length - 1, 1);
}
} else {
this.tables.splice(this.tables.length - 1, 1);
}
} else {
let table = this.tables[0];
table.tableData.splice(table.tableData.length - 4, 4);
} }
this.getTableData(rowArray);
}, },
methods: { methods: {
getTableData(rowArry) { getTableData(rowArray) {
let titles; let titles;
let result = []; let result = [];
for (let i = 0; i < rowArry.length; i++) { for (let i = 0; i < rowArray.length; i++) {
let colArray = rowArry[i].split("\t"); let colArray = rowArray[i].split("\t");
if (i === 0) { if (i === 0) {
titles = colArray; titles = colArray;
} else { } else {
if (colArray.length != titles.length) { if (colArray.length != titles.length) {
// //
if (colArray.length === 1 && colArray[0] === '') { if (colArray.length === 1 && colArray[0] === '') {
this.getTableData(rowArry.slice(i + 1)); this.getTableData(rowArray.slice(i + 1));
} else { } else {
this.getTableData(rowArry.slice(i)); this.getTableData(rowArray.slice(i));
} }
break; break;
} else { } else {
@ -89,11 +68,13 @@
for (let j = 0; j < colArray.length; j++) { for (let j = 0; j < colArray.length; j++) {
item[titles[j]] = (colArray[j] ? colArray[j] : ""); item[titles[j]] = (colArray[j] ? colArray[j] : "");
} }
//
if (result.length < 100) {
result.push(item); result.push(item);
} }
} }
} }
}
this.tables.splice(0, 0, { this.tables.splice(0, 0, {
titles: titles, titles: titles,
tableData: result tableData: result