diff --git a/backend/src/main/java/io/metersphere/base/domain/TestCase.java b/backend/src/main/java/io/metersphere/base/domain/TestCase.java index c138be0380..11f7e7ed3e 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestCase.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestCase.java @@ -67,5 +67,7 @@ public class TestCase implements Serializable { private Boolean latest; + private String lastExecuteResult; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/TestCaseExample.java b/backend/src/main/java/io/metersphere/base/domain/TestCaseExample.java index 91c8f63931..1df2aa5861 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestCaseExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestCaseExample.java @@ -2193,6 +2193,76 @@ public class TestCaseExample { addCriterion("latest not between", value1, value2, "latest"); return (Criteria) this; } + + public Criteria andLastExecuteResultIsNull() { + addCriterion("last_execute_result is null"); + return (Criteria) this; + } + + public Criteria andLastExecuteResultIsNotNull() { + addCriterion("last_execute_result is not null"); + return (Criteria) this; + } + + public Criteria andLastExecuteResultEqualTo(String value) { + addCriterion("last_execute_result =", value, "lastExecuteResult"); + return (Criteria) this; + } + + public Criteria andLastExecuteResultNotEqualTo(String value) { + addCriterion("last_execute_result <>", value, "lastExecuteResult"); + return (Criteria) this; + } + + public Criteria andLastExecuteResultGreaterThan(String value) { + addCriterion("last_execute_result >", value, "lastExecuteResult"); + return (Criteria) this; + } + + public Criteria andLastExecuteResultGreaterThanOrEqualTo(String value) { + addCriterion("last_execute_result >=", value, "lastExecuteResult"); + return (Criteria) this; + } + + public Criteria andLastExecuteResultLessThan(String value) { + addCriterion("last_execute_result <", value, "lastExecuteResult"); + return (Criteria) this; + } + + public Criteria andLastExecuteResultLessThanOrEqualTo(String value) { + addCriterion("last_execute_result <=", value, "lastExecuteResult"); + return (Criteria) this; + } + + public Criteria andLastExecuteResultLike(String value) { + addCriterion("last_execute_result like", value, "lastExecuteResult"); + return (Criteria) this; + } + + public Criteria andLastExecuteResultNotLike(String value) { + addCriterion("last_execute_result not like", value, "lastExecuteResult"); + return (Criteria) this; + } + + public Criteria andLastExecuteResultIn(List values) { + addCriterion("last_execute_result in", values, "lastExecuteResult"); + return (Criteria) this; + } + + public Criteria andLastExecuteResultNotIn(List values) { + addCriterion("last_execute_result not in", values, "lastExecuteResult"); + return (Criteria) this; + } + + public Criteria andLastExecuteResultBetween(String value1, String value2) { + addCriterion("last_execute_result between", value1, value2, "lastExecuteResult"); + return (Criteria) this; + } + + public Criteria andLastExecuteResultNotBetween(String value1, String value2) { + addCriterion("last_execute_result not between", value1, value2, "lastExecuteResult"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/mapper/TestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/TestCaseMapper.xml index 13db861f47..8e47636977 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/TestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/TestCaseMapper.xml @@ -33,6 +33,7 @@ + @@ -104,7 +105,7 @@ id, node_id, test_id, node_path, project_id, `name`, `type`, maintainer, priority, `method`, create_time, update_time, sort, num, other_test_name, review_status, tags, demand_id, demand_name, `status`, step_model, custom_num, create_user, original_status, - delete_time, delete_user_id, `order`, case_public, version_id, ref_id, latest + delete_time, delete_user_id, `order`, case_public, version_id, ref_id, latest, last_execute_result prerequisite, remark, steps, step_description, expected_result, custom_fields @@ -168,9 +169,9 @@ custom_num, create_user, original_status, delete_time, delete_user_id, `order`, case_public, version_id, ref_id, - latest, prerequisite, remark, - steps, step_description, expected_result, - custom_fields) + latest, last_execute_result, prerequisite, + remark, steps, step_description, + expected_result, custom_fields) values (#{id,jdbcType=VARCHAR}, #{nodeId,jdbcType=VARCHAR}, #{testId,jdbcType=VARCHAR}, #{nodePath,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{maintainer,jdbcType=VARCHAR}, #{priority,jdbcType=VARCHAR}, @@ -181,9 +182,9 @@ #{customNum,jdbcType=VARCHAR}, #{createUser,jdbcType=VARCHAR}, #{originalStatus,jdbcType=VARCHAR}, #{deleteTime,jdbcType=BIGINT}, #{deleteUserId,jdbcType=VARCHAR}, #{order,jdbcType=BIGINT}, #{casePublic,jdbcType=BIT}, #{versionId,jdbcType=VARCHAR}, #{refId,jdbcType=VARCHAR}, - #{latest,jdbcType=BIT}, #{prerequisite,jdbcType=LONGVARCHAR}, #{remark,jdbcType=LONGVARCHAR}, - #{steps,jdbcType=LONGVARCHAR}, #{stepDescription,jdbcType=LONGVARCHAR}, #{expectedResult,jdbcType=LONGVARCHAR}, - #{customFields,jdbcType=LONGVARCHAR}) + #{latest,jdbcType=BIT}, #{lastExecuteResult,jdbcType=VARCHAR}, #{prerequisite,jdbcType=LONGVARCHAR}, + #{remark,jdbcType=LONGVARCHAR}, #{steps,jdbcType=LONGVARCHAR}, #{stepDescription,jdbcType=LONGVARCHAR}, + #{expectedResult,jdbcType=LONGVARCHAR}, #{customFields,jdbcType=LONGVARCHAR}) insert into test_case @@ -281,6 +282,9 @@ latest, + + last_execute_result, + prerequisite, @@ -394,6 +398,9 @@ #{latest,jdbcType=BIT}, + + #{lastExecuteResult,jdbcType=VARCHAR}, + #{prerequisite,jdbcType=LONGVARCHAR}, @@ -516,6 +523,9 @@ latest = #{record.latest,jdbcType=BIT}, + + last_execute_result = #{record.lastExecuteResult,jdbcType=VARCHAR}, + prerequisite = #{record.prerequisite,jdbcType=LONGVARCHAR}, @@ -572,6 +582,7 @@ version_id = #{record.versionId,jdbcType=VARCHAR}, ref_id = #{record.refId,jdbcType=VARCHAR}, latest = #{record.latest,jdbcType=BIT}, + last_execute_result = #{record.lastExecuteResult,jdbcType=VARCHAR}, prerequisite = #{record.prerequisite,jdbcType=LONGVARCHAR}, remark = #{record.remark,jdbcType=LONGVARCHAR}, steps = #{record.steps,jdbcType=LONGVARCHAR}, @@ -614,7 +625,8 @@ case_public = #{record.casePublic,jdbcType=BIT}, version_id = #{record.versionId,jdbcType=VARCHAR}, ref_id = #{record.refId,jdbcType=VARCHAR}, - latest = #{record.latest,jdbcType=BIT} + latest = #{record.latest,jdbcType=BIT}, + last_execute_result = #{record.lastExecuteResult,jdbcType=VARCHAR} @@ -712,6 +724,9 @@ latest = #{latest,jdbcType=BIT}, + + last_execute_result = #{lastExecuteResult,jdbcType=VARCHAR}, + prerequisite = #{prerequisite,jdbcType=LONGVARCHAR}, @@ -765,6 +780,7 @@ version_id = #{versionId,jdbcType=VARCHAR}, ref_id = #{refId,jdbcType=VARCHAR}, latest = #{latest,jdbcType=BIT}, + last_execute_result = #{lastExecuteResult,jdbcType=VARCHAR}, prerequisite = #{prerequisite,jdbcType=LONGVARCHAR}, remark = #{remark,jdbcType=LONGVARCHAR}, steps = #{steps,jdbcType=LONGVARCHAR}, @@ -804,7 +820,8 @@ case_public = #{casePublic,jdbcType=BIT}, version_id = #{versionId,jdbcType=VARCHAR}, ref_id = #{refId,jdbcType=VARCHAR}, - latest = #{latest,jdbcType=BIT} + latest = #{latest,jdbcType=BIT}, + last_execute_result = #{lastExecuteResult,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtBaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtBaseMapper.xml index fbb83213fb..4476e65484 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtBaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtBaseMapper.xml @@ -22,7 +22,7 @@ - + like CONCAT('%', #{${object}.value},'%') @@ -66,4 +66,15 @@ + + + #{value} + + + + + + #{id} + + diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java index 34d0ef358e..cfa7bf6a99 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java @@ -145,8 +145,6 @@ public interface ExtTestCaseMapper { String getLastExecStatusById(String id); - List getLastExecStatusByIdList(@Param("ids") List idList); - int countByWorkSpaceId(String workSpaceId); long trashCount(@Param("projectId") String projectId); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml index daa30f9dd3..c0aea4165d 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml @@ -188,6 +188,7 @@ - - - + + and ${versionTable}.version_id = #{request.versionId} diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java index 001c0d6fd2..b4d9d2e766 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -784,19 +784,7 @@ public class TestCaseService { testCaseIdList.add(item.getId()); }); - List testCaseDTOList = extTestCaseMapper.getLastExecStatusByIdList(testCaseIdList); - Map testCaseStatusMap = new HashMap<>(); - testCaseDTOList.forEach(item -> { - testCaseStatusMap.put(item.getId(), item.getStatus()); - }); - for (TestCaseDTO data : returnList) { - String lastStatus = testCaseStatusMap.get(data.getId()); - if (StringUtils.isNotEmpty(lastStatus)) { - data.setLastExecuteResult(lastStatus); - } else { - data.setLastExecuteResult(null); - } String dataStatus = excelData.parseStatus(data.getStatus()); if (StringUtils.equalsAnyIgnoreCase(data.getStatus(), "Trash")) { try { @@ -2649,6 +2637,38 @@ public class TestCaseService { testCaseMapper::updateByPrimaryKeySelective); } + public void updateLastExecuteStatus(List ids, String status) { + if (CollectionUtils.isNotEmpty(ids) && StringUtils.isNotBlank(status)) { + TestCaseExample example = new TestCaseExample(); + example.createCriteria().andIdIn(ids); + TestCaseWithBLOBs testCase = new TestCaseWithBLOBs(); + testCase.setLastExecuteResult(status); + testCaseMapper.updateByExampleSelective(testCase, example); + } + } + + public void updateLastExecuteStatus(String id, String status) { + if (StringUtils.isNotBlank(id) && StringUtils.isNotBlank(status)) { + this.updateLastExecuteStatus(Arrays.asList(id), status); + } + } + + public void updateReviewStatus(List ids, String status) { + if (CollectionUtils.isNotEmpty(ids) && StringUtils.isNotBlank(status)) { + TestCaseExample example = new TestCaseExample(); + example.createCriteria().andIdIn(ids); + TestCaseWithBLOBs testCase = new TestCaseWithBLOBs(); + testCase.setReviewStatus(status); + testCaseMapper.updateByExampleSelective(testCase, example); + } + } + + public void updateReviewStatus(String id, String status) { + if (StringUtils.isNotBlank(id) && StringUtils.isNotBlank(status)) { + this.updateReviewStatus(Arrays.asList(id), status); + } + } + public Pager> getRelationshipRelateList(QueryTestCaseRequest request, int goPage, int pageSize) { setDefaultOrder(request); List relationshipIds = relationshipEdgeService.getRelationshipIds(request.getId()); diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java index 6941f3ad1c..a4a7f545ef 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java @@ -155,6 +155,7 @@ public class TestPlanTestCaseService { testPlanTestCase.setUpdateTime(System.currentTimeMillis()); testPlanTestCase.setRemark(null); testPlanTestCaseMapper.updateByPrimaryKeySelective(testPlanTestCase); + testCaseService.updateLastExecuteStatus(testPlanTestCase.getCaseId(), testPlanTestCase.getStatus()); } public int deleteTestCase(String id) { @@ -187,6 +188,11 @@ public class TestPlanTestCaseService { testPlanTestCaseMapper.updateByExampleSelective( testPlanTestCase, testPlanTestCaseExample); + + if (StringUtils.isNotBlank(request.getStatus())) { + List caseIds = extTestPlanTestCaseMapper.getCaseIdsByIds(request.getIds()); + testCaseService.updateLastExecuteStatus(caseIds, request.getStatus()); + } } public TestPlanTestCaseExample getBatchExample(TestPlanCaseBatchRequest request) { @@ -341,6 +347,8 @@ public class TestPlanTestCaseService { item.setStatus(status); testPlanTestCaseMapper.updateByPrimaryKeySelective(item); + testCaseService.updateLastExecuteStatus(testPlanTestCase.getCaseId(), testPlanTestCase.getStatus()); + SaveCommentRequest saveCommentRequest = new SaveCommentRequest(); saveCommentRequest.setCaseId(testPlanTestCase.getCaseId()); saveCommentRequest.setId(UUID.randomUUID().toString()); @@ -377,6 +385,7 @@ public class TestPlanTestCaseService { testPlanTestCases.forEach(item -> { item.setUpdateTime(System.currentTimeMillis()); testPlanTestCaseMapper.updateByPrimaryKeySelective(item); + testCaseService.updateLastExecuteStatus(item.getCaseId(), item.getStatus()); }); } diff --git a/backend/src/main/java/io/metersphere/track/service/TestReviewTestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestReviewTestCaseService.java index d84afddd42..33d936e883 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestReviewTestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestReviewTestCaseService.java @@ -35,8 +35,6 @@ import java.util.stream.Collectors; @Service @Transactional(rollbackFor = Exception.class) public class TestReviewTestCaseService { - @Resource - private TestCaseTestMapper testCaseTestMapper; @Resource private LoadTestMapper loadTestMapper; @Resource @@ -58,6 +56,8 @@ public class TestReviewTestCaseService { @Resource TestCaseMapper testCaseMapper; @Resource + TestCaseService testCaseService; + @Resource ExtTestPlanTestCaseMapper extTestPlanTestCaseMapper; public List list(QueryCaseReviewRequest request) { @@ -159,11 +159,7 @@ public class TestReviewTestCaseService { testCaseReviewTestCaseMapper.updateByPrimaryKeySelective(testCaseReviewTestCase); // 修改用例评审状态 - String caseId = testCaseReviewTestCase.getCaseId(); - TestCaseWithBLOBs testCase = new TestCaseWithBLOBs(); - testCase.setId(caseId); - testCase.setReviewStatus(testCaseReviewTestCase.getStatus()); - testCaseMapper.updateByPrimaryKeySelective(testCase); + testCaseService.updateReviewStatus(testCaseReviewTestCase.getCaseId(), testCaseReviewTestCase.getStatus()); } public TestReviewCaseDTO get(String reviewId) { @@ -223,11 +219,8 @@ public class TestReviewTestCaseService { // 更新状态{TestCase, TestCaseReviewTestCase} if (StringUtils.isNotBlank(request.getStatus())) { - TestCaseExample example = new TestCaseExample(); - example.createCriteria().andIdIn(ids); - TestCaseWithBLOBs testCase = new TestCaseWithBLOBs(); - testCase.setReviewStatus(request.getStatus()); - testCaseMapper.updateByExampleSelective(testCase, example); + testCaseService.updateReviewStatus(ids, request.getStatus()); + TestCaseReviewTestCaseExample caseReviewTestCaseExample = new TestCaseReviewTestCaseExample(); caseReviewTestCaseExample.createCriteria().andReviewIdEqualTo(request.getReviewId()).andCaseIdIn(ids); TestCaseReviewTestCase testCaseReviewTestCase = new TestCaseReviewTestCase(); @@ -250,17 +243,11 @@ public class TestReviewTestCaseService { public void editTestCaseForMinder(String reviewId, List testCaseReviewTestCases) { checkReviewCase(reviewId); if (!CollectionUtils.isEmpty(testCaseReviewTestCases)) { - List testCaseList = new ArrayList<>(); testCaseReviewTestCases.forEach((item) -> { - TestCaseWithBLOBs testCase = new TestCaseWithBLOBs(); - testCase.setId(item.getCaseId()); - testCase.setReviewStatus(item.getStatus()); - testCaseList.add(testCase); - testCase.setUpdateTime(System.currentTimeMillis()); item.setUpdateTime(System.currentTimeMillis()); testCaseReviewTestCaseMapper.updateByPrimaryKeySelective(item); + testCaseService.updateReviewStatus(item.getCaseId(), item.getStatus()); }); - testCaseList.forEach(testCaseMapper::updateByPrimaryKeySelective); } } diff --git a/frontend/src/business/components/track/case/components/TestCaseList.vue b/frontend/src/business/components/track/case/components/TestCaseList.vue index 48c50d25bb..4c9bee9ae3 100644 --- a/frontend/src/business/components/track/case/components/TestCaseList.vue +++ b/frontend/src/business/components/track/case/components/TestCaseList.vue @@ -49,19 +49,6 @@ min-width="120"/> - - - - - - + :fields-width="fieldsWidth"/> + + 0 ? requireComponent("./graph/RelationshipGraphDrawer.vue") : {}; @@ -294,6 +279,8 @@ const relationshipGraphDrawer = requireComponent.keys().length > 0 ? requireComp export default { name: "TestCaseList", components: { + TestPlanCaseStatusTableItem, + TestCaseReviewStatusTableItem, RelateDemand, MsSearch, ListItemDeleteConfirm, diff --git a/frontend/src/business/components/track/common/tableItems/TestCaseReviewStatusTableItem.vue b/frontend/src/business/components/track/common/tableItems/TestCaseReviewStatusTableItem.vue new file mode 100644 index 0000000000..fd891d5625 --- /dev/null +++ b/frontend/src/business/components/track/common/tableItems/TestCaseReviewStatusTableItem.vue @@ -0,0 +1,52 @@ + + + + + diff --git a/frontend/src/business/components/track/common/tableItems/TestPlanCaseStatusTableItem.vue b/frontend/src/business/components/track/common/tableItems/TestPlanCaseStatusTableItem.vue new file mode 100644 index 0000000000..dd211e2cf4 --- /dev/null +++ b/frontend/src/business/components/track/common/tableItems/TestPlanCaseStatusTableItem.vue @@ -0,0 +1,54 @@ + + + + + diff --git a/frontend/src/business/components/track/plan/view/comonents/api/TestPlanApiCaseList.vue b/frontend/src/business/components/track/plan/view/comonents/api/TestPlanApiCaseList.vue index 22ac3e8763..5138cf43c0 100644 --- a/frontend/src/business/components/track/plan/view/comonents/api/TestPlanApiCaseList.vue +++ b/frontend/src/business/components/track/plan/view/comonents/api/TestPlanApiCaseList.vue @@ -125,6 +125,7 @@ + + + +