diff --git a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml
index b58467bd6d..4110b20caf 100644
--- a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml
+++ b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml
@@ -467,19 +467,19 @@
- and (t1.status IS NULL or t1.status NOT IN ('SUCCESS','ERROR','FAKE_ERROR') )
+ and (t3.status IS NULL or t3.status NOT IN ('SUCCESS','ERROR','FAKE_ERROR') )
- and t1.status = 'SUCCESS'
+ and t3.status = 'SUCCESS'
- and t1.status = 'ERROR'
+ and t3.status = 'ERROR'
- and t1.status = 'FAKE_ERROR'
+ and t3.status = 'FAKE_ERROR'
- and t1.status IN ('SUCCESS','ERROR','FAKE_ERROR')
+ and t3.status IN ('SUCCESS','ERROR','FAKE_ERROR')
@@ -1022,23 +1022,29 @@
from api_test_case
where id = #{0}
-
+ SELECT
+ execResult.`status` AS execResult,
+ count(testCase.id) AS `count`
+ FROM
+ api_test_case testCase
+ LEFT JOIN api_definition_exec_result execResult ON execResult.id = testCase.last_result_id
+ WHERE
+ ( testCase.`status` IS NULL OR testCase.`status` != 'Trash' )
+ AND testCase.api_definition_id IN (
+ SELECT id FROM api_definition
+ WHERE project_id = #{projectId}
+
+ AND version_id = #{versionId}
+
+
+ AND latest IS TRUE
+
+ )
+ GROUP BY
+ execResult.`status`;
- SELECT `status` AS execResult,count(id) AS count
- FROM api_test_case
- WHERE `status` != 'Trash' AND api_definition_id IN
- (SELECT id FROM api_definition
- WHERE project_id = #{projectId}
-
- AND version_id = #{versionId}
-
-
- AND latest IS TRUE
-
- )
- GROUP BY `status`
SELECT
diff --git a/api-test/backend/src/main/java/io/metersphere/controller/home/ApiHomeController.java b/api-test/backend/src/main/java/io/metersphere/controller/home/ApiHomeController.java
index a41ccbc835..ea7748b033 100644
--- a/api-test/backend/src/main/java/io/metersphere/controller/home/ApiHomeController.java
+++ b/api-test/backend/src/main/java/io/metersphere/controller/home/ApiHomeController.java
@@ -58,9 +58,7 @@ public class ApiHomeController {
@GetMapping("/api/count/{projectId}/{versionId}")
public ApiDataCountDTO apiCount(@PathVariable String projectId, @PathVariable String versionId) {
- if (StringUtils.equalsIgnoreCase(versionId, "default")) {
- versionId = null;
- }
+ versionId = this.initializationVersionId(versionId);
ApiDataCountDTO apiCountResult = new ApiDataCountDTO();
List countResultByProtocolList = apiDefinitionService.countProtocolByProjectID(projectId, versionId);
apiCountResult.countProtocol(countResultByProtocolList);
@@ -103,9 +101,7 @@ public class ApiHomeController {
@GetMapping("/api/case/count/{projectId}/{versionId}")
public ApiDataCountDTO apiCaseCount(@PathVariable String projectId, @PathVariable String versionId) {
- if (StringUtils.equalsIgnoreCase(versionId, "default")) {
- versionId = null;
- }
+ versionId = this.initializationVersionId(versionId);
ApiDataCountDTO apiCountResult = new ApiDataCountDTO();
List countResultList = apiTestCaseService.countProtocolByProjectID(projectId, versionId);
apiCountResult.countProtocol(countResultList);
@@ -146,9 +142,7 @@ public class ApiHomeController {
@GetMapping("/scenario/count/{projectId}/{versionId}")
public ApiDataCountDTO scenarioCount(@PathVariable String projectId, @PathVariable String versionId) {
- if (StringUtils.equalsIgnoreCase(versionId, "default")) {
- versionId = null;
- }
+ versionId = this.initializationVersionId(versionId);
ApiDataCountDTO apiCountResult = new ApiDataCountDTO();
long scenarioCountNumber = apiAutomationService.countScenarioByProjectID(projectId, versionId);
apiCountResult.setTotal(scenarioCountNumber);
@@ -190,11 +184,8 @@ public class ApiHomeController {
@GetMapping("/schedule/task/count/{projectId}/{versionId}")
public ApiDataCountDTO scheduleTaskCount(@PathVariable String projectId, @PathVariable String versionId) {
- if (StringUtils.equalsIgnoreCase(versionId, "default")) {
- versionId = null;
- }
+ versionId = this.initializationVersionId(versionId);
List allScenarioScheduleList = baseScheduleService.selectScenarioTaskByProjectId(projectId, versionId);
-
ApiDataCountDTO apiCountResult = new ApiDataCountDTO();
long allTaskCount = allScenarioScheduleList.size();
apiCountResult.setTotal(allTaskCount);
@@ -246,9 +237,7 @@ public class ApiHomeController {
@PostMapping("/runningTask/{projectId}/{versionId}/{goPage}/{pageSize}")
public Pager> runningTask(@PathVariable String projectId, @PathVariable String versionId, @PathVariable int goPage, @PathVariable int pageSize) {
Page page = PageHelper.startPage(goPage, pageSize, true);
- if (StringUtils.equalsIgnoreCase(versionId, "default")) {
- versionId = null;
- }
+ versionId = this.initializationVersionId(versionId);
List resultList = taskService.findScenarioAndSwaggerRunningTaskInfoByProjectID(projectId, versionId);
int dataIndex = 1;
for (TaskInfoResult taskInfo :
@@ -266,9 +255,7 @@ public class ApiHomeController {
@GetMapping("/failure/case/about/plan/{projectId}/{versionId}/{selectFunctionCase}/{limitNumber}/{goPage}/{pageSize}")
public Pager> failureCaseAboutTestPlan(@PathVariable String projectId, @PathVariable String versionId, @PathVariable boolean selectFunctionCase,
@PathVariable int limitNumber, @PathVariable int goPage, @PathVariable int pageSize) {
- if (StringUtils.equalsIgnoreCase(versionId, "default")) {
- versionId = null;
- }
+ versionId = this.initializationVersionId(versionId);
Page page = PageHelper.startPage(goPage, pageSize, true);
List selectDataList = apiDefinitionExecResultService.findFailureCaseInfoByProjectIDAndLimitNumberInSevenDays(projectId, versionId, selectFunctionCase, limitNumber);
List returnList = new ArrayList<>(selectDataList.size());
@@ -288,4 +275,13 @@ public class ApiHomeController {
}
return PageUtils.setPageInfo(page, returnList);
}
+
+ //初始化版本ID
+ private String initializationVersionId(String versionId) {
+ if (StringUtils.equalsIgnoreCase(versionId, "default")) {
+ return null;
+ } else {
+ return versionId;
+ }
+ }
}
\ No newline at end of file
diff --git a/api-test/frontend/src/business/definition/components/ApiVariable.vue b/api-test/frontend/src/business/definition/components/ApiVariable.vue
index 2ada628752..34b2f531a7 100644
--- a/api-test/frontend/src/business/definition/components/ApiVariable.vue
+++ b/api-test/frontend/src/business/definition/components/ApiVariable.vue
@@ -32,7 +32,7 @@
:disabled="isReadOnly"
v-model="scope.row.type"
size="mini"
- @change="typeChange(item)">
+ @change="typeChange(scope.row)">
@@ -437,7 +437,7 @@ export default {
urlEncode: this.urlEncode,
uuid: this.uuid(),
valid: false,
- value: null
+ value: null,
})
);
}
@@ -488,11 +488,11 @@ export default {
},
typeChange(item) {
if (item.type === 'file') {
- item.contentType = 'application/octet-stream';
+ this.$set(item, 'contentType', 'application/octet-stream');
} else if (item.type === 'text') {
- item.contentType = 'text/plain';
+ this.$set(item, 'contentType', 'text/plain');
} else {
- item.contentType = 'application/json';
+ this.$set(item, 'contentType', 'application/json');
}
this.reload();
},
@@ -540,7 +540,7 @@ export default {
urlEncode: this.urlEncode,
uuid: this.uuid(),
valid: false,
- value: null
+ value: null,
})
);
}