diff --git a/backend/src/main/java/io/metersphere/track/controller/TestCaseReviewController.java b/backend/src/main/java/io/metersphere/track/controller/TestCaseReviewController.java index d69cd5121e..ac3544d130 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestCaseReviewController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestCaseReviewController.java @@ -91,14 +91,14 @@ public class TestCaseReviewController { @PostMapping("/projects") public List getProjectByReviewId(@RequestBody TestReviewRelevanceRequest request) { - List projectIds = testReviewProjectService.getProjectIdsByReviewId(request.getReviewId()); + List projectIds = testReviewProjectService.getProjectIdsByReviewId(); request.setProjectIds(projectIds); return testReviewProjectService.getProject(request); } @PostMapping("/project/{goPage}/{pageSize}") public Pager> getProjectByReviewId(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody TestReviewRelevanceRequest request) { - List projectIds = testReviewProjectService.getProjectIdsByReviewId(request.getReviewId()); + List projectIds = testReviewProjectService.getProjectIdsByReviewId(); request.setProjectIds(projectIds); Page page = PageHelper.startPage(goPage, pageSize, true); return PageUtils.setPageInfo(page, testReviewProjectService.getProject(request)); diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java index fedd336094..e8058ea0f8 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java @@ -9,6 +9,7 @@ import io.metersphere.base.mapper.ext.ExtTestCaseNodeMapper; import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper; import io.metersphere.commons.constants.TestCaseConstants; import io.metersphere.commons.exception.MSException; +import io.metersphere.commons.utils.SessionUtils; import io.metersphere.exception.ExcelException; import io.metersphere.i18n.Translator; import io.metersphere.service.NodeTreeService; @@ -197,10 +198,11 @@ public class TestCaseNodeService extends NodeTreeService { public List getNodeByReviewId(String reviewId) { List list = new ArrayList<>(); - TestCaseReview testCaseReview = new TestCaseReview(); - testCaseReview.setId(reviewId); - List project = testCaseReviewService.getProjectByReviewId(testCaseReview); - List projectIds = project.stream().map(Project::getId).collect(Collectors.toList()); + ProjectExample example = new ProjectExample(); + example.createCriteria().andWorkspaceIdEqualTo(SessionUtils.getCurrentWorkspaceId()); + List projects = projectMapper.selectByExample(example); + List projectIds = projects.stream().map(Project::getId).collect(Collectors.toList()); + projectIds.forEach(id -> { String name = projectMapper.selectByPrimaryKey(id).getName(); diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java index 9e59f6e02e..a5944ec526 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java @@ -81,19 +81,7 @@ public class TestCaseReviewService { public void saveTestCaseReview(SaveTestCaseReviewRequest reviewRequest) { checkCaseReviewExist(reviewRequest); String reviewId = UUID.randomUUID().toString(); - List projectIds = reviewRequest.getProjectIds(); List userIds = reviewRequest.getUserIds();//执行人 - if (!CollectionUtils.isEmpty(projectIds)) { - List ids = projectIds.stream().distinct().collect(Collectors.toList()); - // 如果关联项目id中包含当前项目id进行移除 - ids.remove(SessionUtils.getCurrentProjectId()); - ids.forEach(projectId -> { - TestCaseReviewProject testCaseReviewProject = new TestCaseReviewProject(); - testCaseReviewProject.setProjectId(projectId); - testCaseReviewProject.setReviewId(reviewId); - testCaseReviewProjectMapper.insertSelective(testCaseReviewProject); - }); - } userIds.forEach(userId -> { TestCaseReviewUsers testCaseReviewUsers = new TestCaseReviewUsers(); @@ -216,7 +204,6 @@ public class TestCaseReviewService { public void editCaseReview(SaveTestCaseReviewRequest testCaseReview) { editCaseReviewer(testCaseReview); - editCaseReviewProject(testCaseReview); testCaseReview.setUpdateTime(System.currentTimeMillis()); checkCaseReviewExist(testCaseReview); testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview); @@ -259,56 +246,6 @@ public class TestCaseReviewService { testCaseReviewUsersMapper.deleteByExample(example); } - private void editCaseReviewProject(SaveTestCaseReviewRequest testCaseReview) { - List projectIds = testCaseReview.getProjectIds(); - if (!CollectionUtils.isEmpty(projectIds)) { - projectIds.remove(testCaseReview.getProjectId()); - } - String id = testCaseReview.getId(); - if (StringUtils.isNotBlank(testCaseReview.getProjectId())) { - TestCaseReviewProjectExample testCaseReviewProjectExample = new TestCaseReviewProjectExample(); - testCaseReviewProjectExample.createCriteria().andReviewIdEqualTo(id); - List testCaseReviewProjects = testCaseReviewProjectMapper.selectByExample(testCaseReviewProjectExample); - List dbProjectIds = testCaseReviewProjects.stream().map(TestCaseReviewProject::getProjectId).collect(Collectors.toList()); - projectIds.forEach(projectId -> { - if (!dbProjectIds.contains(projectId)) { - TestCaseReviewProject testCaseReviewProject = new TestCaseReviewProject(); - testCaseReviewProject.setReviewId(id); - testCaseReviewProject.setProjectId(projectId); - testCaseReviewProjectMapper.insert(testCaseReviewProject); - } - }); - - TestCaseReviewProjectExample example = new TestCaseReviewProjectExample(); - TestCaseReviewProjectExample.Criteria criteria1 = example.createCriteria().andReviewIdEqualTo(id); - if (!CollectionUtils.isEmpty(projectIds)) { - criteria1.andProjectIdNotIn(projectIds); - } - testCaseReviewProjectMapper.deleteByExample(example); - - - // 关联的项目下的用例idList - List caseIds = null; - // 测试计划所属项目下的用例不解除关联 - projectIds.add(testCaseReview.getProjectId()); - // 关联的项目下的用例idList - if (!CollectionUtils.isEmpty(projectIds)) { - TestCaseExample testCaseExample = new TestCaseExample(); - testCaseExample.createCriteria().andProjectIdIn(projectIds); - List caseList = testCaseMapper.selectByExample(testCaseExample); - caseIds = caseList.stream().map(TestCase::getId).collect(Collectors.toList()); - } - - TestCaseReviewTestCaseExample testCaseReviewTestCaseExample = new TestCaseReviewTestCaseExample(); - TestCaseReviewTestCaseExample.Criteria criteria = testCaseReviewTestCaseExample.createCriteria().andReviewIdEqualTo(id); - if (!CollectionUtils.isEmpty(caseIds)) { - criteria.andCaseIdNotIn(caseIds); - } - testCaseReviewTestCaseMapper.deleteByExample(testCaseReviewTestCaseExample); - } - - } - private void checkCaseReviewExist(TestCaseReview testCaseReview) { if (testCaseReview.getName() != null) { TestCaseReviewExample example = new TestCaseReviewExample(); diff --git a/backend/src/main/java/io/metersphere/track/service/TestReviewProjectService.java b/backend/src/main/java/io/metersphere/track/service/TestReviewProjectService.java index 00f0259c8c..ecf1c92449 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestReviewProjectService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestReviewProjectService.java @@ -2,8 +2,7 @@ package io.metersphere.track.service; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.ProjectMapper; -import io.metersphere.base.mapper.TestCaseReviewMapper; -import io.metersphere.base.mapper.TestCaseReviewProjectMapper; +import io.metersphere.commons.utils.SessionUtils; import io.metersphere.track.request.testreview.TestReviewRelevanceRequest; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -19,32 +18,14 @@ public class TestReviewProjectService { @Resource private ProjectMapper projectMapper; - @Resource - private TestCaseReviewProjectMapper testCaseReviewProjectMapper; - @Resource - private TestCaseReviewMapper testCaseReviewMapper; - public List getProjectIdsByReviewId(String reviewId) { - TestCaseReviewProjectExample example = new TestCaseReviewProjectExample(); - example.createCriteria().andReviewIdEqualTo(reviewId); - List projectIds = testCaseReviewProjectMapper.selectByExample(example) - .stream() - .map(TestCaseReviewProject::getProjectId) - .collect(Collectors.toList()); - TestCaseReview caseReview = testCaseReviewMapper.selectByPrimaryKey(reviewId); - if (caseReview != null && StringUtils.isNotBlank(caseReview.getProjectId())) { - if (!projectIds.contains(caseReview.getProjectId())) { - projectIds.add(caseReview.getProjectId()); - } - } - if (projectIds.isEmpty()) { - return null; - } - - return projectIds; + public List getProjectIdsByReviewId() { + ProjectExample example = new ProjectExample(); + example.createCriteria().andWorkspaceIdEqualTo(SessionUtils.getCurrentWorkspaceId()); + List projects = projectMapper.selectByExample(example); + return projects.stream().map(Project::getId).collect(Collectors.toList()); } - public List getProject(TestReviewRelevanceRequest request) { ProjectExample projectExample = new ProjectExample(); ProjectExample.Criteria criteria = projectExample.createCriteria(); diff --git a/frontend/src/business/components/track/review/components/TestCaseReviewEdit.vue b/frontend/src/business/components/track/review/components/TestCaseReviewEdit.vue index b8016b36b1..b9e8948757 100644 --- a/frontend/src/business/components/track/review/components/TestCaseReviewEdit.vue +++ b/frontend/src/business/components/track/review/components/TestCaseReviewEdit.vue @@ -21,30 +21,6 @@ - - - - - - - - - - @@ -148,14 +124,12 @@ export default { }, formLabelWidth: "120px", operationType: '', - projects: [], reviewerOptions: [] }; }, methods: { openCaseReviewEditDialog(caseReview) { this.resetForm(); - this.getProjects(); this.setReviewerOptions(); this.operationType = 'save'; if (caseReview) { @@ -184,52 +158,17 @@ export default { return false; } - if (this.operationType === 'edit') { - const nowIds = param.projectIds; - let sign = true; - this.dbProjectIds.forEach(dbId => { - if (nowIds.indexOf(dbId) === -1 && sign) { - sign = false; - this.$confirm(this.$t('test_track.case.cancel_relevance_project'), this.$t('commons.prompt'), { - confirmButtonText: this.$t('commons.confirm'), - cancelButtonText: this.$t('commons.cancel'), - type: 'warning' - }).then(() => { - this.editTestReview(param); - }).catch(() => { - this.$info(this.$t('commons.cancel')) - }); - } - }); - if (sign) { - this.editTestReview(param); - } - } else { - this.editTestReview(param); - } - + this.result = this.$post('/test/case/review/' + this.operationType, param, () => { + this.$success(this.$t('commons.save_success')); + this.dialogFormVisible = false; + this.$emit("refresh"); + }); } else { return false; } }); }, - editTestReview(param) { - this.result = this.$post('/test/case/review/' + this.operationType, param, () => { - this.$success(this.$t('commons.save_success')); - this.dialogFormVisible = false; - this.$emit("refresh"); - }); - }, - getProjects() { - this.result = this.$get("/project/listAll", (response) => { - if (response.success) { - this.projects = response.data.filter(da => da.id !== getCurrentProjectID()); - } else { - this.$warning(response.message); - } - }); - }, setReviewerOptions() { let workspaceId = localStorage.getItem(WORKSPACE_ID); this.result = this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => {