diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.java index f2daf5f3f1..d27c54aa67 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.java @@ -11,4 +11,6 @@ public interface ExtIssuesMapper { List getIssuesByCaseId(@Param("request") IssuesRequest issuesRequest); List getIssuesByProjectId(@Param("request") IssuesRequest issuesRequest); + + List getRelateIssues(@Param("request") IssuesRequest request); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.xml index f90fc91d1c..052aa1eabe 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.xml @@ -20,6 +20,17 @@ + diff --git a/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelData.java b/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelData.java index 8526dcfc4f..8ae4dc7caa 100644 --- a/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelData.java +++ b/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelData.java @@ -17,15 +17,11 @@ public class TestCaseExcelData { @ExcelIgnore private String nodePath; @ExcelIgnore - private String type; - @ExcelIgnore private String maintainer; @ExcelIgnore private String priority; @ExcelIgnore private String tags; -// @ExcelIgnore -// private String method; @ExcelIgnore private String prerequisite; @ExcelIgnore diff --git a/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataCn.java b/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataCn.java index 461179b93f..fec94b4f9b 100644 --- a/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataCn.java +++ b/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataCn.java @@ -1,5 +1,6 @@ package io.metersphere.excel.domain; +import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.write.style.ColumnWidth; import io.metersphere.excel.annotation.NotRequired; @@ -34,11 +35,6 @@ public class TestCaseExcelDataCn extends TestCaseExcelData { @Pattern(regexp = "^(?!.*//).*$", message = "{incorrect_format}") private String nodePath; - @NotBlank(message = "{cannot_be_null}") - @ExcelProperty("用例类型") - @Pattern(regexp = "(^functional$)|(^performance$)|(^api$)", message = "{test_case_type_validate}") - private String type; - @NotBlank(message = "{cannot_be_null}") @ExcelProperty("维护人") private String maintainer; diff --git a/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataTw.java b/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataTw.java index c945f1b085..0c82bfd904 100644 --- a/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataTw.java +++ b/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataTw.java @@ -34,11 +34,6 @@ public class TestCaseExcelDataTw extends TestCaseExcelData { @Pattern(regexp = "^(?!.*//).*$", message = "{incorrect_format}") private String nodePath; - @NotBlank(message = "{cannot_be_null}") - @ExcelProperty("用例類型") - @Pattern(regexp = "(^functional$)|(^performance$)|(^api$)", message = "{test_case_type_validate}") - private String type; - @NotBlank(message = "{cannot_be_null}") @ExcelProperty("維護人") private String maintainer; diff --git a/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataUs.java b/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataUs.java index c01e79e111..42e158f69d 100644 --- a/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataUs.java +++ b/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataUs.java @@ -35,11 +35,6 @@ public class TestCaseExcelDataUs extends TestCaseExcelData { @Pattern(regexp = "^(?!.*//).*$", message = "{incorrect_format}") private String nodePath; - @NotBlank(message = "{cannot_be_null}") - @ExcelProperty("Type") - @Pattern(regexp = "(^functional$)|(^performance$)|(^api$)", message = "{test_case_type_validate}") - private String type; - @NotBlank(message = "{cannot_be_null}") @ExcelProperty("Maintainer") private String maintainer; diff --git a/backend/src/main/java/io/metersphere/track/controller/IssuesController.java b/backend/src/main/java/io/metersphere/track/controller/IssuesController.java index 63bad01904..e75ccfd902 100644 --- a/backend/src/main/java/io/metersphere/track/controller/IssuesController.java +++ b/backend/src/main/java/io/metersphere/track/controller/IssuesController.java @@ -32,6 +32,12 @@ public class IssuesController { return PageUtils.setPageInfo(page, issuesService.list(request)); } + @PostMapping("/list/relate/{goPage}/{pageSize}") + public Pager> relateList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody IssuesRequest request) { + Page> page = PageHelper.startPage(goPage, pageSize, true); + return PageUtils.setPageInfo(page, issuesService.relateList(request)); + } + @PostMapping("/add") @MsAuditLog(module = "track_bug", type = OperLogConstants.CREATE, content = "#msClass.getLogDetails(#issuesRequest)", msClass = IssuesService.class) public void addIssues(@RequestBody IssuesUpdateRequest issuesRequest) { diff --git a/backend/src/main/java/io/metersphere/track/controller/TestCaseIssuesController.java b/backend/src/main/java/io/metersphere/track/controller/TestCaseIssuesController.java index 1385e96ae7..808afa85b4 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestCaseIssuesController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestCaseIssuesController.java @@ -22,4 +22,9 @@ public class TestCaseIssuesController { public List list(@RequestBody IssuesRelevanceRequest request) { return testCaseIssueService.list(request); } + + @PostMapping("/relate") + public void relate(@RequestBody IssuesRelevanceRequest request) { + testCaseIssueService.relate(request); + } } diff --git a/backend/src/main/java/io/metersphere/track/request/issues/IssuesRelevanceRequest.java b/backend/src/main/java/io/metersphere/track/request/issues/IssuesRelevanceRequest.java index 7e5b724674..deac7ff00d 100644 --- a/backend/src/main/java/io/metersphere/track/request/issues/IssuesRelevanceRequest.java +++ b/backend/src/main/java/io/metersphere/track/request/issues/IssuesRelevanceRequest.java @@ -15,6 +15,8 @@ public class IssuesRelevanceRequest { */ private String issuesId; + private String caseId; + /** * 当选择关联全部用例时把加载条件送到后台,从后台查询 */ @@ -25,5 +27,7 @@ public class IssuesRelevanceRequest { */ private List testCaseIds = new ArrayList<>(); + private List issueIds; + private Boolean checked; } diff --git a/backend/src/main/java/io/metersphere/track/service/IssuesService.java b/backend/src/main/java/io/metersphere/track/service/IssuesService.java index 8821b1b039..a0392ff71f 100644 --- a/backend/src/main/java/io/metersphere/track/service/IssuesService.java +++ b/backend/src/main/java/io/metersphere/track/service/IssuesService.java @@ -423,4 +423,8 @@ public class IssuesService { } return null; } + + public List relateList(IssuesRequest request) { + return extIssuesMapper.getRelateIssues(request); + } } diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseIssueService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseIssueService.java index 5f711f0664..3222a533c7 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseIssueService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseIssueService.java @@ -6,6 +6,7 @@ import io.metersphere.base.mapper.IssuesMapper; import io.metersphere.base.mapper.TestCaseIssuesMapper; import io.metersphere.track.dto.TestCaseDTO; import io.metersphere.track.request.issues.IssuesRelevanceRequest; +import org.apache.commons.lang3.StringUtils; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -13,6 +14,7 @@ import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.util.List; +import java.util.UUID; import java.util.stream.Collectors; @Service @@ -58,4 +60,30 @@ public class TestCaseIssueService { .map(TestCaseIssues::getTestCaseId) .collect(Collectors.toList()); } + + public void relate(IssuesRelevanceRequest request) { + if (StringUtils.isNotBlank(request.getCaseId())) { + List issueIds = request.getIssueIds(); + if (!CollectionUtils.isEmpty(issueIds)) { + issueIds.forEach(issueId -> { + create(request.getCaseId(), issueId); + }); + } + } else if (StringUtils.isNotBlank(request.getIssuesId())) { + List caseIds = request.getTestCaseIds(); + if (!CollectionUtils.isEmpty(caseIds)) { + caseIds.forEach(caseId -> { + create(caseId, request.getIssuesId()); + }); + } + } + } + + public void create(String caseId, String issueId) { + TestCaseIssues testCaseIssues = new TestCaseIssues(); + testCaseIssues.setId(UUID.randomUUID().toString()); + testCaseIssues.setTestCaseId(caseId); + testCaseIssues.setIssuesId(issueId); + testCaseIssuesMapper.insert(testCaseIssues); + } } diff --git a/frontend/src/business/components/track/case/components/IssueRelateList.vue b/frontend/src/business/components/track/case/components/IssueRelateList.vue new file mode 100644 index 0000000000..330b8140e8 --- /dev/null +++ b/frontend/src/business/components/track/case/components/IssueRelateList.vue @@ -0,0 +1,102 @@ + + + + + diff --git a/frontend/src/business/components/track/case/components/TestCaseIssueRelate.vue b/frontend/src/business/components/track/case/components/TestCaseIssueRelate.vue index df90b74ee7..02bc814813 100644 --- a/frontend/src/business/components/track/case/components/TestCaseIssueRelate.vue +++ b/frontend/src/business/components/track/case/components/TestCaseIssueRelate.vue @@ -1,6 +1,7 @@ @@ -70,9 +72,10 @@ import MsTable from "@/business/components/common/components/table/MsTable"; import MsTableColumn from "@/business/components/common/components/table/Ms-table-column"; import IssueDescriptionTableItem from "@/business/components/track/issue/IssueDescriptionTableItem"; import {ISSUE_STATUS_MAP} from "@/common/js/table-constants"; +import IssueRelateList from "@/business/components/track/case/components/IssueRelateList"; export default { name: "TestCaseIssueRelate", - components: {IssueDescriptionTableItem, MsTableColumn, MsTable, TestPlanIssueEdit}, + components: {IssueRelateList, IssueDescriptionTableItem, MsTableColumn, MsTable, TestPlanIssueEdit}, data() { return { issues: [], @@ -100,6 +103,13 @@ export default { } this.$refs.issueEdit.open(); }, + relateIssue() { + if (!this.caseId) { + this.$warning(this.$t('api_test.automation.save_case_info')); + return; + } + this.$refs.issueRelate.open(); + }, closeIssue(row) { if (row.status === 'closed') { this.$success(this.$t('test_track.issue.close_success')); diff --git a/frontend/src/business/components/track/issue/IssueEditDetail.vue b/frontend/src/business/components/track/issue/IssueEditDetail.vue index 635f12e1cc..9264892b60 100644 --- a/frontend/src/business/components/track/issue/IssueEditDetail.vue +++ b/frontend/src/business/components/track/issue/IssueEditDetail.vue @@ -1,5 +1,5 @@