This commit is contained in:
chenjianxing 2021-02-02 18:54:19 +08:00
commit ee1e55ac29
3 changed files with 71 additions and 19 deletions

View File

@ -39,8 +39,14 @@ public class TestReviewTestCaseController {
@PostMapping("/batch/delete")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void deleteTestCaseBath(@RequestBody TestReviewCaseBatchRequest request) {
testReviewTestCaseService.deleteTestCaseBath(request);
public void deleteTestCaseBatch(@RequestBody TestReviewCaseBatchRequest request) {
testReviewTestCaseService.deleteTestCaseBatch(request);
}
@PostMapping("/batch/edit/status")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void editTestCaseBatch(@RequestBody TestReviewCaseBatchRequest request) {
testReviewTestCaseService.editTestCaseBatchStatus(request);
}
@PostMapping("/list/all")

View File

@ -18,6 +18,7 @@ import io.metersphere.track.request.testreview.QueryCaseReviewRequest;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
@ -97,7 +98,7 @@ public class TestReviewTestCaseService {
}
}
public void deleteTestCaseBath(TestReviewCaseBatchRequest request) {
public void deleteTestCaseBatch(TestReviewCaseBatchRequest request) {
checkReviewer(request.getReviewId());
TestCaseReviewTestCaseExample example = new TestCaseReviewTestCaseExample();
example.createCriteria().andIdIn(request.getIds());
@ -105,15 +106,7 @@ public class TestReviewTestCaseService {
}
public void editTestCase(TestCaseReviewTestCase testCaseReviewTestCase) {
String currentUserId = SessionUtils.getUser().getId();
String reviewId = testCaseReviewTestCase.getReviewId();
TestCaseReviewUsersExample testCaseReviewUsersExample = new TestCaseReviewUsersExample();
testCaseReviewUsersExample.createCriteria().andReviewIdEqualTo(reviewId);
List<TestCaseReviewUsers> testCaseReviewUsers = testCaseReviewUsersMapper.selectByExample(testCaseReviewUsersExample);
List<String> reviewIds = testCaseReviewUsers.stream().map(TestCaseReviewUsers::getUserId).collect(Collectors.toList());
if (!reviewIds.contains(currentUserId)) {
MSException.throwException("非此用例的评审人员!");
}
checkReviewCase(testCaseReviewTestCase.getReviewId());
// 记录测试用例评审状态变更
testCaseReviewTestCase.setStatus(testCaseReviewTestCase.getStatus());
@ -137,4 +130,37 @@ public class TestReviewTestCaseService {
public TestReviewCaseDTO get(String reviewId) {
return extTestReviewCaseMapper.get(reviewId);
}
public void editTestCaseBatchStatus(TestReviewCaseBatchRequest request) {
List<String> ids = request.getIds();
if (CollectionUtils.isEmpty(ids)) {
return;
}
if (StringUtils.isBlank(request.getReviewId())) {
return;
} else {
checkReviewCase(request.getReviewId());
}
// 更新状态
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);
}
}
private void checkReviewCase(String reviewId) {
String currentUserId = SessionUtils.getUser().getId();
TestCaseReviewUsersExample testCaseReviewUsersExample = new TestCaseReviewUsersExample();
testCaseReviewUsersExample.createCriteria().andReviewIdEqualTo(reviewId);
List<TestCaseReviewUsers> testCaseReviewUsers = testCaseReviewUsersMapper.selectByExample(testCaseReviewUsersExample);
List<String> reviewIds = testCaseReviewUsers.stream().map(TestCaseReviewUsers::getUserId).collect(Collectors.toList());
if (!reviewIds.contains(currentUserId)) {
MSException.throwException("非此用例的评审人员!");
}
}
}

View File

@ -146,6 +146,9 @@
@refreshTable="search"/>
</el-card>
<batch-edit ref="batchEdit" @batchEdit="batchEdit"
:type-arr="typeArr" :value-arr="valueArr" :dialog-title="$t('test_track.case.batch_edit_case')"/>
</div>
</template>
@ -214,21 +217,21 @@ export default {
],
showMore: false,
buttons: [
{
name: this.$t('test_track.case.batch_edit_case'), handleClick: this.handleEditBatch
},
{
name: this.$t('test_track.case.batch_unlink'), handleClick: this.handleDeleteBatch
}
],
typeArr: [
{id: 'status', name: this.$t('test_track.plan_view.execute_result')},
{id: 'executor', name: this.$t('test_track.plan_view.executor')},
{id: 'status', name: this.$t('test_track.review_view.execute_result')},
],
valueArr: {
executor: [],
status: [
{name: this.$t('test_track.plan_view.pass'), id: 'Pass'},
{name: this.$t('test_track.plan_view.failure'), id: 'Failure'},
{name: this.$t('test_track.plan_view.blocking'), id: 'Blocking'},
{name: this.$t('test_track.plan_view.skip'), id: 'Skip'}
{name: this.$t('test_track.case.status_prepare'), id: 'Prepare'},
{name: this.$t('test_track.case.status_pass'), id: 'Pass'},
{name: this.$t('test_track.case.status_un_pass'), id: 'UnPass'},
]
},
}
@ -339,6 +342,23 @@ export default {
this.$success(this.$t('test_track.cancel_relevance_success'));
});
},
handleEditBatch() {
this.$refs.batchEdit.open(this.selectRows.size);
},
batchEdit(form) {
let reviewId = this.reviewId;
let param = {};
param[form.type] = form.value;
param.ids = Array.from(this.selectRows).map(row => row.caseId);
param.reviewId = reviewId;
this.$post('/test/review/case/batch/edit/status', param, () => {
this.selectRows.clear();
this.status = '';
this.$post('/test/case/review/edit/status/' + reviewId);
this.$success(this.$t('commons.save_success'));
this.$emit('refresh');
});
},
handleSelectAll(selection) {
if (selection.length > 0) {
this.tableData.forEach(item => {