From e43777b4fa7fa367f9cbe18d6a7400df1e891ca3 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 21 Oct 2021 13:30:51 +0800 Subject: [PATCH] =?UTF-8?q?feat=20(=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89):?= =?UTF-8?q?=20=E5=A2=9E=E5=8A=A0=E7=94=A8=E4=BE=8B=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/ApiTestCaseService.java | 45 +++++++----- .../metersphere/base/domain/ApiTestCase.java | 7 +- .../base/domain/ApiTestCaseExample.java | 72 ++++++++++++++++++- .../base/mapper/ApiTestCaseMapper.xml | 63 ++++++++++------ .../base/mapper/ext/ExtApiTestCaseMapper.xml | 8 ++- .../db/migration/V97__v1.14_release.sql | 5 +- .../components/case/ApiCaseItem.vue | 53 +++++++------- .../components/list/ApiCaseSimpleList.vue | 19 +++++ .../api/definition/model/JsonData.js | 2 +- .../src/common/js/default-table-header.js | 3 +- 10 files changed, 204 insertions(+), 73 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java index 2404211d5e..5c2472c1fa 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java @@ -328,25 +328,30 @@ public class ApiTestCaseService { request = esbApiParamService.handleEsbRequest(request); } - final ApiTestCaseWithBLOBs test = new ApiTestCaseWithBLOBs(); - test.setId(request.getId()); - test.setName(request.getName()); - test.setApiDefinitionId(request.getApiDefinitionId()); - test.setUpdateUserId(Objects.requireNonNull(SessionUtils.getUser()).getId()); - test.setProjectId(request.getProjectId()); - test.setRequest(JSONObject.toJSONString(request.getRequest())); - test.setPriority(request.getPriority()); - test.setUpdateTime(System.currentTimeMillis()); - test.setDescription(request.getDescription()); - test.setVersion(request.getVersion() == null ? 0 : request.getVersion() + 1); - test.setFollowPeople(request.getFollowPeople()); - if (StringUtils.equals("[]", request.getTags())) { - test.setTags(""); - } else { - test.setTags(request.getTags()); + final ApiTestCaseWithBLOBs test = apiTestCaseMapper.selectByPrimaryKey(request.getId()); + if (test != null) { + test.setName(request.getName()); + test.setCaseStatus(request.getCaseStatus()); + if (StringUtils.isEmpty(request.getCaseStatus())) { + test.setCaseStatus(APITestStatus.Underway.name()); + } + test.setApiDefinitionId(request.getApiDefinitionId()); + test.setUpdateUserId(Objects.requireNonNull(SessionUtils.getUser()).getId()); + test.setProjectId(request.getProjectId()); + test.setRequest(JSONObject.toJSONString(request.getRequest())); + test.setPriority(request.getPriority()); + test.setUpdateTime(System.currentTimeMillis()); + test.setDescription(request.getDescription()); + test.setVersion(request.getVersion() == null ? 0 : request.getVersion() + 1); + test.setFollowPeople(request.getFollowPeople()); + if (StringUtils.equals("[]", request.getTags())) { + test.setTags(""); + } else { + test.setTags(request.getTags()); + } + apiTestCaseMapper.updateByPrimaryKeySelective(test); } - apiTestCaseMapper.updateByPrimaryKeySelective(test); - return apiTestCaseMapper.selectByPrimaryKey(request.getId()); + return test; } private ApiTestCase createTest(SaveApiTestCaseRequest request, List bodyFiles) { @@ -362,6 +367,10 @@ public class ApiTestCaseService { test.setId(request.getId()); test.setName(request.getName()); test.setStatus(""); + test.setCaseStatus(request.getCaseStatus()); + if (StringUtils.isEmpty(request.getCaseStatus())) { + test.setCaseStatus(APITestStatus.Underway.name()); + } test.setApiDefinitionId(request.getApiDefinitionId()); test.setCreateUserId(Objects.requireNonNull(SessionUtils.getUser()).getId()); test.setUpdateUserId(Objects.requireNonNull(SessionUtils.getUser()).getId()); diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiTestCase.java b/backend/src/main/java/io/metersphere/base/domain/ApiTestCase.java index 716c47c712..f7082b03dd 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiTestCase.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiTestCase.java @@ -1,8 +1,9 @@ package io.metersphere.base.domain; -import java.io.Serializable; import lombok.Data; +import java.io.Serializable; + @Data public class ApiTestCase implements Serializable { private String id; @@ -43,5 +44,7 @@ public class ApiTestCase implements Serializable { private Long order; + private String caseStatus; + private static final long serialVersionUID = 1L; -} +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiTestCaseExample.java b/backend/src/main/java/io/metersphere/base/domain/ApiTestCaseExample.java index c42e6e9912..e778d2afb2 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiTestCaseExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiTestCaseExample.java @@ -1373,6 +1373,76 @@ public class ApiTestCaseExample { addCriterion("`order` not between", value1, value2, "order"); return (Criteria) this; } + + public Criteria andCaseStatusIsNull() { + addCriterion("case_status is null"); + return (Criteria) this; + } + + public Criteria andCaseStatusIsNotNull() { + addCriterion("case_status is not null"); + return (Criteria) this; + } + + public Criteria andCaseStatusEqualTo(String value) { + addCriterion("case_status =", value, "caseStatus"); + return (Criteria) this; + } + + public Criteria andCaseStatusNotEqualTo(String value) { + addCriterion("case_status <>", value, "caseStatus"); + return (Criteria) this; + } + + public Criteria andCaseStatusGreaterThan(String value) { + addCriterion("case_status >", value, "caseStatus"); + return (Criteria) this; + } + + public Criteria andCaseStatusGreaterThanOrEqualTo(String value) { + addCriterion("case_status >=", value, "caseStatus"); + return (Criteria) this; + } + + public Criteria andCaseStatusLessThan(String value) { + addCriterion("case_status <", value, "caseStatus"); + return (Criteria) this; + } + + public Criteria andCaseStatusLessThanOrEqualTo(String value) { + addCriterion("case_status <=", value, "caseStatus"); + return (Criteria) this; + } + + public Criteria andCaseStatusLike(String value) { + addCriterion("case_status like", value, "caseStatus"); + return (Criteria) this; + } + + public Criteria andCaseStatusNotLike(String value) { + addCriterion("case_status not like", value, "caseStatus"); + return (Criteria) this; + } + + public Criteria andCaseStatusIn(List values) { + addCriterion("case_status in", values, "caseStatus"); + return (Criteria) this; + } + + public Criteria andCaseStatusNotIn(List values) { + addCriterion("case_status not in", values, "caseStatus"); + return (Criteria) this; + } + + public Criteria andCaseStatusBetween(String value1, String value2) { + addCriterion("case_status between", value1, value2, "caseStatus"); + return (Criteria) this; + } + + public Criteria andCaseStatusNotBetween(String value1, String value2) { + addCriterion("case_status not between", value1, value2, "caseStatus"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { @@ -1467,4 +1537,4 @@ public class ApiTestCaseExample { this(condition, value, secondValue, null); } } -} +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ApiTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ApiTestCaseMapper.xml index 1ca34f16dc..6743ee7295 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ApiTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ApiTestCaseMapper.xml @@ -21,6 +21,7 @@ + @@ -85,9 +86,9 @@ - id, project_id, `name`, priority, api_definition_id, create_user_id, update_user_id, - create_time, update_time, num, tags, last_result_id, `status`, original_status, delete_time, - delete_user_id, version, follow_people, `order` + id, project_id, `name`, priority, api_definition_id, create_user_id, update_user_id, + create_time, update_time, num, tags, last_result_id, `status`, original_status, delete_time, + delete_user_id, version, follow_people, `order`, case_status description, request @@ -123,7 +124,7 @@ select - t1.id, t1.project_id, t1.name, t1.api_definition_id, t1.priority, t1.description, t1.create_user_id, t1.update_user_id, t1.create_time, t1.update_time, t1.num, + t1.id, t1.project_id, t1.name,t1.case_status, t1.api_definition_id, t1.priority, t1.description, t1.create_user_id, t1.update_user_id, t1.create_time, t1.update_time, t1.num, a.module_id, a.path, a.protocol, t1.tags,t1.status,t1.last_result_id as lastResultId, t1.delete_time, deleteUser.name AS deleteUser,CONCAT(FORMAT(SUM(IF (t2.`status`='success',1,0))/COUNT(t2.id)*100,2),'%') passRate from @@ -311,6 +311,12 @@ #{value} + + and t1.case_status in + + #{value} + + diff --git a/backend/src/main/resources/db/migration/V97__v1.14_release.sql b/backend/src/main/resources/db/migration/V97__v1.14_release.sql index a14878c56b..7fb2a81653 100644 --- a/backend/src/main/resources/db/migration/V97__v1.14_release.sql +++ b/backend/src/main/resources/db/migration/V97__v1.14_release.sql @@ -334,4 +334,7 @@ ALTER TABLE service_integration DROP COLUMN organization_id; ALTER TABLE workspace - DROP COLUMN organization_id; \ No newline at end of file + DROP COLUMN organization_id; + +ALTER TABLE api_test_case ADD COLUMN case_status VARCHAR(100) comment '用例状态等同场景的status'; +UPDATE api_test_case set case_status ="Underway" where case_status is null; \ No newline at end of file diff --git a/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue b/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue index de4714ff10..d0ffc48b87 100644 --- a/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue +++ b/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue @@ -37,10 +37,6 @@ {{ $t('operating_log.change_history') }}
- - - - {{ apiCase.updateTime | timestampFormatDate }} {{ apiCase.updateUser }} {{ $t('api_test.definition.request.update_info') }} @@ -58,26 +54,32 @@ - -
- -
-
- - -
- - - - -
+ + + + + + + + +
+ + + + +
+
+
+ +
+ +
+
@@ -156,7 +158,7 @@