feat: 测试评审修改评审人和所属项目
This commit is contained in:
parent
fd24ed1246
commit
1c51bc57e9
|
@ -67,7 +67,7 @@ public class TestCaseReviewController {
|
|||
|
||||
@PostMapping("/edit")
|
||||
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
||||
public void editCaseReview(@RequestBody TestCaseReview testCaseReview) {
|
||||
public void editCaseReview(@RequestBody SaveTestCaseReviewRequest testCaseReview) {
|
||||
testCaseReviewService.editCaseReview(testCaseReview);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@ import org.apache.ibatis.session.SqlSession;
|
|||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -54,6 +56,10 @@ public class TestCaseReviewService {
|
|||
ExtProjectMapper extProjectMapper;
|
||||
@Resource
|
||||
UserService userService;
|
||||
@Resource
|
||||
TestCaseMapper testCaseMapper;
|
||||
@Resource
|
||||
TestCaseReviewTestCaseMapper testCaseReviewTestCaseMapper;
|
||||
|
||||
public void saveTestCaseReview(SaveTestCaseReviewRequest reviewRequest) {
|
||||
checkCaseReviewExist(reviewRequest);
|
||||
|
@ -119,20 +125,87 @@ public class TestCaseReviewService {
|
|||
.collect(Collectors.toList());
|
||||
|
||||
UserExample userExample = new UserExample();
|
||||
userExample.createCriteria().andIdIn(userIds);
|
||||
return userMapper.selectByExample(userExample);
|
||||
UserExample.Criteria criteria = userExample.createCriteria();
|
||||
if (!CollectionUtils.isEmpty(userIds)) {
|
||||
criteria.andIdIn(userIds);
|
||||
return userMapper.selectByExample(userExample);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
public List<TestCaseReviewDTO> recent(String currentWorkspaceId) {
|
||||
return extTestCaseReviewMapper.listByWorkspaceId(currentWorkspaceId);
|
||||
}
|
||||
|
||||
public void editCaseReview(TestCaseReview testCaseReview) {
|
||||
public void editCaseReview(SaveTestCaseReviewRequest testCaseReview) {
|
||||
editCaseReviewer(testCaseReview);
|
||||
editCaseReviewProject(testCaseReview);
|
||||
testCaseReview.setUpdateTime(System.currentTimeMillis());
|
||||
checkCaseReviewExist(testCaseReview);
|
||||
testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview);
|
||||
}
|
||||
|
||||
private void editCaseReviewer(SaveTestCaseReviewRequest testCaseReview) {
|
||||
// 要更新的reviewerIds
|
||||
List<String> reviewerIds = testCaseReview.getUserIds();
|
||||
|
||||
String id = testCaseReview.getId();
|
||||
TestCaseReviewUsersExample testCaseReviewUsersExample = new TestCaseReviewUsersExample();
|
||||
testCaseReviewUsersExample.createCriteria().andReviewIdEqualTo(id);
|
||||
List<TestCaseReviewUsers> testCaseReviewUsers = testCaseReviewUsersMapper.selectByExample(testCaseReviewUsersExample);
|
||||
List<String> dbReviewIds = testCaseReviewUsers.stream().map(TestCaseReviewUsers::getUserId).collect(Collectors.toList());
|
||||
|
||||
reviewerIds.forEach(reviewerId -> {
|
||||
if (!dbReviewIds.contains(reviewerId)) {
|
||||
TestCaseReviewUsers caseReviewUser = new TestCaseReviewUsers();
|
||||
caseReviewUser.setUserId(reviewerId);
|
||||
caseReviewUser.setReviewId(id);
|
||||
testCaseReviewUsersMapper.insertSelective(caseReviewUser);
|
||||
}
|
||||
});
|
||||
|
||||
TestCaseReviewUsersExample example = new TestCaseReviewUsersExample();
|
||||
example.createCriteria().andReviewIdEqualTo(id).andUserIdNotIn(reviewerIds);
|
||||
testCaseReviewUsersMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
private void editCaseReviewProject(SaveTestCaseReviewRequest testCaseReview) {
|
||||
List<String> projectIds = testCaseReview.getProjectIds();
|
||||
String id = testCaseReview.getId();
|
||||
if (!CollectionUtils.isEmpty(projectIds)) {
|
||||
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();
|
||||
example.createCriteria().andReviewIdEqualTo(id).andProjectIdNotIn(projectIds);
|
||||
testCaseReviewProjectMapper.deleteByExample(example);
|
||||
|
||||
|
||||
// 关联的项目下的用例idList
|
||||
TestCaseExample testCaseExample = new TestCaseExample();
|
||||
testCaseExample.createCriteria().andProjectIdIn(projectIds);
|
||||
List<TestCase> caseList = testCaseMapper.selectByExample(testCaseExample);
|
||||
List<String> 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();
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit de612c8ef47f93c8720ac918d22aaa172977b6f7
|
||||
Subproject commit 321c869938357e8c2253e5bd86c963828664ae23
|
|
@ -25,7 +25,6 @@
|
|||
<el-col :span="11" :offset="2">
|
||||
<el-form-item :label="$t('test_track.plan.plan_project')" :label-width="formLabelWidth" prop="projectIds">
|
||||
<el-select
|
||||
:disabled="(form.status == null) ? false : true"
|
||||
v-model="form.projectIds"
|
||||
:placeholder="$t('test_track.plan.input_plan_project')"
|
||||
multiple
|
||||
|
@ -51,7 +50,6 @@
|
|||
placeholder="请选择评审人"
|
||||
filterable multiple
|
||||
collapse-tags
|
||||
:disabled="(form.status == null) ? false : true"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in reviewerOptions"
|
||||
|
@ -132,6 +130,7 @@ export default {
|
|||
description: '',
|
||||
endTime: ''
|
||||
},
|
||||
dbProjectIds: [],
|
||||
rules: {
|
||||
name: [
|
||||
{required: true, message: this.$t('test_track.plan.input_plan_name'), trigger: 'blur'},
|
||||
|
@ -161,6 +160,7 @@ export default {
|
|||
let tmp = {};
|
||||
Object.assign(tmp, caseReview);
|
||||
Object.assign(this.form, tmp);
|
||||
this.dbProjectIds = JSON.parse(JSON.stringify(this.form.projectIds));
|
||||
}
|
||||
listenGoBack(this.close);
|
||||
this.dialogFormVisible = true;
|
||||
|
@ -178,16 +178,44 @@ export default {
|
|||
if (this.operationType === 'save') {
|
||||
this.compareTime(new Date().getTime(), this.form.endTime);
|
||||
}
|
||||
this.$post('/test/case/review/' + this.operationType, param, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.dialogFormVisible = false;
|
||||
this.$emit("refresh");
|
||||
});
|
||||
|
||||
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('取消项目关联会同时取消该项目下已关联的测试用例', '提示', {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
editTestReview(param) {
|
||||
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) {
|
||||
|
@ -204,7 +232,8 @@ export default {
|
|||
});
|
||||
},
|
||||
statusChange(status) {
|
||||
|
||||
this.form.status = status;
|
||||
this.$forceUpdate();
|
||||
},
|
||||
close() {
|
||||
removeGoBackListener(this.close);
|
||||
|
|
|
@ -37,42 +37,14 @@
|
|||
<el-table-column
|
||||
prop="status"
|
||||
column-key="status"
|
||||
:filters="statusFilters"
|
||||
:label="$t('test_track.plan.plan_status')"
|
||||
show-overflow-tooltip>
|
||||
<template v-slot:default="scope">
|
||||
<span @click.stop="clickt = 'stop'">
|
||||
<el-dropdown class="test-case-status" @command="statusChange">
|
||||
<span class="el-dropdown-link">
|
||||
<plan-status-table-item :value="scope.row.status"/>
|
||||
</span>
|
||||
<el-dropdown-menu slot="dropdown" chang>
|
||||
<el-dropdown-item :disabled="!isTestManagerOrTestUser" :command="{id: scope.row.id, status: 'Prepare'}">
|
||||
{{ $t('test_track.plan.plan_status_prepare') }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item :disabled="!isTestManagerOrTestUser"
|
||||
:command="{id: scope.row.id, status: 'Underway'}">
|
||||
{{ $t('test_track.plan.plan_status_running') }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item :disabled="!isTestManagerOrTestUser"
|
||||
:command="{id: scope.row.id, status: 'Completed'}">
|
||||
{{ $t('test_track.plan.plan_status_completed') }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
<span class="el-dropdown-link">
|
||||
<plan-status-table-item :value="scope.row.status"/>
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column-->
|
||||
<!-- prop="reviewerSize"-->
|
||||
<!-- label="已评"-->
|
||||
<!-- show-overflow-tooltip>-->
|
||||
<!-- </el-table-column>-->
|
||||
<!-- <el-table-column-->
|
||||
<!-- prop="resultMap"-->
|
||||
<!-- label="结果分布"-->
|
||||
<!-- show-overflow-tooltip>-->
|
||||
<!-- </el-table-column>-->
|
||||
<el-table-column
|
||||
prop="createTime"
|
||||
:label="$t('commons.create_time')"
|
||||
|
@ -94,10 +66,10 @@
|
|||
<template v-slot:default="scope">
|
||||
<ms-table-operator :is-tester-permission="true" @editClick="handleEdit(scope.row)"
|
||||
@deleteClick="handleDelete(scope.row)">
|
||||
<template v-slot:middle>
|
||||
<ms-table-operator-button :isTesterPermission="true" type="success" tip="重新发起" icon="el-icon-document"
|
||||
@exec="reCreate(scope.row)"/>
|
||||
</template>
|
||||
<!-- <template v-slot:middle>-->
|
||||
<!-- <ms-table-operator-button :isTesterPermission="true" type="success" tip="重新发起" icon="el-icon-document"-->
|
||||
<!-- @exec="reCreate(scope.row)"/>-->
|
||||
<!-- </template>-->
|
||||
</ms-table-operator>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
@ -105,7 +77,7 @@
|
|||
|
||||
<ms-table-pagination :change="initTableData" :current-page.sync="currentPage" :page-size.sync="pageSize"
|
||||
:total="total"/>
|
||||
<ms-delete-confirm title="删除用例评审" @delete="_handleDelete" ref="deleteConfirm"/>
|
||||
<ms-delete-confirm title="取消用例关联" @delete="_handleDelete" ref="deleteConfirm"/>
|
||||
|
||||
</el-card>
|
||||
</template>
|
||||
|
@ -217,9 +189,6 @@ export default {
|
|||
_sort(column, this.condition);
|
||||
this.initTableData();
|
||||
},
|
||||
reCreate() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -108,20 +108,8 @@
|
|||
column-key="status"
|
||||
:label="$t('test_track.plan_view.execute_result')">
|
||||
<template v-slot:default="scope">
|
||||
<span @click.stop="clickt = 'stop'">
|
||||
<el-dropdown class="test-case-status" @command="statusChange">
|
||||
<span class="el-dropdown-link">
|
||||
<status-table-item :value="scope.row.status"/>
|
||||
</span>
|
||||
<el-dropdown-menu slot="dropdown" chang>
|
||||
<el-dropdown-item :disabled="!isTestManagerOrTestUser" :command="{id: scope.row.id, status: 'Pass'}">
|
||||
{{$t('test_track.plan_view.pass')}}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item :disabled="!isTestManagerOrTestUser" :command="{id: scope.row.id, status: 'UnPass'}">
|
||||
未通过
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
<span class="el-dropdown-link">
|
||||
<status-table-item :value="scope.row.status"/>
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
@ -459,6 +447,7 @@ export default {
|
|||
},
|
||||
startReview() {
|
||||
if (this.tableData.length !== 0) {
|
||||
this.isReadOnly = false;
|
||||
this.$refs.testReviewTestCaseEdit.openTestCaseEdit(this.tableData[0]);
|
||||
} else {
|
||||
this.$warning("没有关联的评审!");
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 6ae17a7ced8f8175531f959ed0a0a6a707ba27dc
|
||||
Subproject commit f2d5a342c82e629f510550d5778d752bb73bf5e7
|
Loading…
Reference in New Issue