feat(测试跟踪): 用例评审默认关联工作空间下所有项目
This commit is contained in:
parent
b289b4d267
commit
eb5b2d3de1
|
@ -91,14 +91,14 @@ public class TestCaseReviewController {
|
|||
|
||||
@PostMapping("/projects")
|
||||
public List<Project> getProjectByReviewId(@RequestBody TestReviewRelevanceRequest request) {
|
||||
List<String> projectIds = testReviewProjectService.getProjectIdsByReviewId(request.getReviewId());
|
||||
List<String> projectIds = testReviewProjectService.getProjectIdsByReviewId();
|
||||
request.setProjectIds(projectIds);
|
||||
return testReviewProjectService.getProject(request);
|
||||
}
|
||||
|
||||
@PostMapping("/project/{goPage}/{pageSize}")
|
||||
public Pager<List<Project>> getProjectByReviewId(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody TestReviewRelevanceRequest request) {
|
||||
List<String> projectIds = testReviewProjectService.getProjectIdsByReviewId(request.getReviewId());
|
||||
List<String> projectIds = testReviewProjectService.getProjectIdsByReviewId();
|
||||
request.setProjectIds(projectIds);
|
||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||
return PageUtils.setPageInfo(page, testReviewProjectService.getProject(request));
|
||||
|
|
|
@ -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<TestCaseNodeDTO> {
|
|||
|
||||
public List<TestCaseNodeDTO> getNodeByReviewId(String reviewId) {
|
||||
List<TestCaseNodeDTO> list = new ArrayList<>();
|
||||
TestCaseReview testCaseReview = new TestCaseReview();
|
||||
testCaseReview.setId(reviewId);
|
||||
List<Project> project = testCaseReviewService.getProjectByReviewId(testCaseReview);
|
||||
List<String> projectIds = project.stream().map(Project::getId).collect(Collectors.toList());
|
||||
ProjectExample example = new ProjectExample();
|
||||
example.createCriteria().andWorkspaceIdEqualTo(SessionUtils.getCurrentWorkspaceId());
|
||||
List<Project> projects = projectMapper.selectByExample(example);
|
||||
List<String> projectIds = projects.stream().map(Project::getId).collect(Collectors.toList());
|
||||
|
||||
projectIds.forEach(id -> {
|
||||
String name = projectMapper.selectByPrimaryKey(id).getName();
|
||||
|
||||
|
|
|
@ -81,19 +81,7 @@ public class TestCaseReviewService {
|
|||
public void saveTestCaseReview(SaveTestCaseReviewRequest reviewRequest) {
|
||||
checkCaseReviewExist(reviewRequest);
|
||||
String reviewId = UUID.randomUUID().toString();
|
||||
List<String> projectIds = reviewRequest.getProjectIds();
|
||||
List<String> userIds = reviewRequest.getUserIds();//执行人
|
||||
if (!CollectionUtils.isEmpty(projectIds)) {
|
||||
List<String> 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<String> 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<TestCaseReviewProject> testCaseReviewProjects = testCaseReviewProjectMapper.selectByExample(testCaseReviewProjectExample);
|
||||
List<String> 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<String> caseIds = null;
|
||||
// 测试计划所属项目下的用例不解除关联
|
||||
projectIds.add(testCaseReview.getProjectId());
|
||||
// 关联的项目下的用例idList
|
||||
if (!CollectionUtils.isEmpty(projectIds)) {
|
||||
TestCaseExample testCaseExample = new TestCaseExample();
|
||||
testCaseExample.createCriteria().andProjectIdIn(projectIds);
|
||||
List<TestCase> 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();
|
||||
|
|
|
@ -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<String> getProjectIdsByReviewId(String reviewId) {
|
||||
TestCaseReviewProjectExample example = new TestCaseReviewProjectExample();
|
||||
example.createCriteria().andReviewIdEqualTo(reviewId);
|
||||
List<String> 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<String> getProjectIdsByReviewId() {
|
||||
ProjectExample example = new ProjectExample();
|
||||
example.createCriteria().andWorkspaceIdEqualTo(SessionUtils.getCurrentWorkspaceId());
|
||||
List<Project> projects = projectMapper.selectByExample(example);
|
||||
return projects.stream().map(Project::getId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
public List<Project> getProject(TestReviewRelevanceRequest request) {
|
||||
ProjectExample projectExample = new ProjectExample();
|
||||
ProjectExample.Criteria criteria = projectExample.createCriteria();
|
||||
|
|
|
@ -21,30 +21,6 @@
|
|||
<el-input v-model="form.name"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="11" :offset="2">
|
||||
<el-form-item :label-width="formLabelWidth" prop="projectIds">
|
||||
<template slot="label">
|
||||
<el-tooltip class="item" effect="dark" :content="$t('test_track.review.related_tip')" placement="top">
|
||||
<i class="el-icon-warning"/>
|
||||
</el-tooltip>
|
||||
{{ $t('test_track.review.related_project') }}
|
||||
</template>
|
||||
<el-select
|
||||
v-model="form.projectIds"
|
||||
:placeholder="$t('test_track.review.input_review_project')"
|
||||
multiple
|
||||
style="width: 100%"
|
||||
filterable>
|
||||
<el-option
|
||||
v-for="item in projects"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row>
|
||||
|
@ -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 => {
|
||||
|
|
Loading…
Reference in New Issue