feat(测试跟踪): 功能用例删除增加删除当前版本和全部版本

This commit is contained in:
wxg0103 2022-01-20 14:51:52 +08:00 committed by 刘瑞斌
parent bf141bfbce
commit baf498e452
4 changed files with 64 additions and 35 deletions

View File

@ -227,7 +227,7 @@
test_case.other_test_name, test_case.review_status, test_case.tags,
test_case.demand_id, test_case.demand_name, test_case.`status`,
test_case.custom_num, test_case.step_model, test_case.create_user,u.name as createName,
test_case.custom_fields, project.name as projectName
test_case.custom_fields, project.name as projectName , test_case.ref_id
</if>
from test_case left join user u on test_case.create_user=u.id
left join user deleteUser on test_case.delete_user_id=deleteUser.id
@ -870,7 +870,14 @@
<update id="deletePublic">
update test_case
set case_public = false
where ref_id = #{request.refId}
<where>
<if test="request.refId != null">
ref_id =#{request.refId}
</if>
<if test="request.versionId != null">
and version_id =#{request.versionId}
</if>
</where>
</update>
<update id="reduction">

View File

@ -256,12 +256,12 @@ public class TestCaseController {
return testCaseService.deleteTestCaseToGc(testCaseId);
}
@PostMapping("/deletePublic/{refId}")
@GetMapping("/deletePublic/{versionId}/{refId}")
@MsAuditLog(module = "track_test_case", type = OperLogConstants.GC, beforeEvent = "#msClass.getLogDetails(#testCaseId)", msClass = TestCaseService.class)
@SendNotice(taskType = NoticeConstants.TaskType.TRACK_TEST_CASE_TASK, event = NoticeConstants.Event.DELETE, target = "#targetClass.getTestCase(#testCaseId)", targetClass = TestCaseService.class,
mailTemplate = "track/TestCaseDelete", subject = "测试用例通知")
public int deletePublic(@PathVariable String refId) {
return testCaseService.deleteTestCasePublic(refId);
public void deletePublic(@PathVariable String versionId, @PathVariable String refId) {
testCaseService.deleteTestCasePublic(versionId ,refId);
}
@ -356,8 +356,8 @@ public class TestCaseController {
@MsAuditLog(module = "track_test_case", type = OperLogConstants.BATCH_DEL, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = TestCaseService.class)
@SendNotice(taskType = NoticeConstants.TaskType.TRACK_TEST_CASE_TASK, target = "#targetClass.findByBatchRequest(#request)", targetClass = TestCaseService.class,
event = NoticeConstants.Event.DELETE, mailTemplate = "track/TestCaseDelete", subject = "测试用例通知")
public void deleteToGcBatchPublic(@RequestBody TestCaseBatchRequest request) {
testCaseService.deleteToGcBatchPublic(request.getIds());
public void deleteToGcBatchPublic(@RequestBody List<String> ids) {
testCaseService.deleteToGcBatchPublic(ids);
}
@PostMapping("/reduction")

View File

@ -2144,9 +2144,9 @@ public class TestCaseService {
if (CollectionUtils.isNotEmpty(ids)) {
for (String id : ids) {
TestCase testCase = testCaseMapper.selectByPrimaryKey(id);
if ((StringUtils.isNotEmpty(testCase.getMaintainer()) && testCase.getMaintainer() == SessionUtils.getUserId()) ||
(StringUtils.isNotEmpty(testCase.getCreateUser()) && testCase.getCreateUser() == SessionUtils.getUserId())) {
this.deleteTestCasePublic(testCase.getRefId());
if ((StringUtils.isNotEmpty(testCase.getMaintainer()) && testCase.getMaintainer().equals(SessionUtils.getUserId())) ||
(StringUtils.isNotEmpty(testCase.getCreateUser()) && testCase.getCreateUser().equals(SessionUtils.getUserId()))) {
this.deleteTestCasePublic(null , testCase.getRefId());
} else {
MSException.throwException(Translator.get("check_owner_case"));
}
@ -2438,10 +2438,11 @@ public class TestCaseService {
}
}
public int deleteTestCasePublic(String refId) {
public void deleteTestCasePublic(String versionId , String refId) {
TestCase testCase = new TestCase();
testCase.setRefId(refId);
return extTestCaseMapper.deletePublic(testCase);
testCase.setVersionId(versionId);
extTestCaseMapper.deletePublic(testCase);
}
public Boolean hasOtherInfo(String caseId) {

View File

@ -226,6 +226,8 @@
<!--高级搜索-->
<ms-table-adv-search-bar :condition.sync="condition" :showLink="false" ref="searchBar" @search="search"/>
<!-- 删除接口提示 -->
<api-delete-confirm ref="apiDeleteConfirm" @handleDelete="_handleDeleteVersion"/>
</span>
</template>
@ -276,7 +278,7 @@ import {editTestCaseOrder} from "@/network/testCase";
import {getGraphByCondition} from "@/network/graph";
import MsTableAdvSearchBar from "@/business/components/common/components/search/MsTableAdvSearchBar";
import {getUUID} from "@/common/js/utils";
import ApiDeleteConfirm from "@/business/components/api/definition/components/list/ApiDeleteConfirm";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const relationshipGraphDrawer = requireComponent.keys().length > 0 ? requireComponent("./graph/RelationshipGraphDrawer.vue") : {};
@ -308,6 +310,7 @@ export default {
ReviewStatus,
MsTag, ApiStatus,
"relationshipGraphDrawer": relationshipGraphDrawer.default,
ApiDeleteConfirm
},
data() {
return {
@ -891,18 +894,8 @@ export default {
});
},
handleDeleteToGc(testCase) {
this.$alert(this.$t('test_track.case.delete_confirm') + '\'' + testCase.name + '\'' + "", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
if (this.publicEnable) {
this._handleDeletePublic(testCase);
} else {
this._handleDeleteToGc(testCase);
}
}
}
});
//
this.$refs.apiDeleteConfirm.open(testCase, this.$t('test_track.case.delete_confirm'));
},
batchReduction() {
let param = buildBatchParam(this, this.$refs.table.selectIds);
@ -964,14 +957,6 @@ export default {
this.$success(this.$t('commons.delete_success'));
});
},
_handleDeletePublic(testCase) {
let refId = testCase.refId;
this.$post('/test/case/deletePublic/' + refId, {}, () => {
this.$emit('refreshTable');
this.initTableData();
this.$success(this.$t('commons.delete_success'));
});
},
refresh() {
this.$refs.table.clear();
this.$emit('refresh');
@ -1097,8 +1082,8 @@ export default {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
let param = buildBatchParam(this, this.$refs.table.selectIds);
this.$post('/test/case/batch/movePublic/deleteToGc', param, () => {
let ids = this.$refs.table.selectIds;
this.$post('/test/case/batch/movePublic/deleteToGc', ids, () => {
this.$refs.table.clear();
this.$emit("refresh");
this.$success(this.$t('commons.delete_success'));
@ -1115,6 +1100,42 @@ export default {
this.isMoveBatch = false;
this.$refs.testBatchMove.open(this.treeNodes, this.$refs.table.selectIds, this.moduleOptions);
},
_handleDeleteVersion(testCase, deleteCurrentVersion) {
//
if (deleteCurrentVersion) {
if (this.publicEnable) {
this.$get('/test/case/deletePublic/' + testCase.versionId + '/' + testCase.refId, () => {
this.$success(this.$t('commons.delete_success'));
this.$refs.apiDeleteConfirm.close();
this.$emit("refreshTable");
});
}
else {
this.$get('/test/case/delete/' + testCase.versionId + '/' + testCase.refId, () => {
this.$success(this.$t('commons.delete_success'));
this.$refs.apiDeleteConfirm.close();
this.$emit("refreshTable");
});
}
}
//
else {
if (this.publicEnable) {
let ids = [testCase.id];
this.$post('/test/case/batch/movePublic/deleteToGc', ids, () => {
this.$success(this.$t('commons.delete_success'));
// this.initTable();
this.$refs.apiDeleteConfirm.close();
this.$emit("refreshTable");
});
} else {
this._handleDeleteToGc(testCase);
this.$refs.apiDeleteConfirm.close();
}
}
},
getMaintainerOptions() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.valueArr.maintainer = response.data;