diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml
index 2465d59e21..4e54e75cba 100644
--- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml
+++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml
@@ -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
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 test_case
set case_public = false
- where ref_id = #{request.refId}
+
+
+ ref_id =#{request.refId}
+
+
+ and version_id =#{request.versionId}
+
+
diff --git a/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java b/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java
index ff068f90d1..6bddf4def7 100644
--- a/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java
+++ b/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java
@@ -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 ids) {
+ testCaseService.deleteToGcBatchPublic(ids);
}
@PostMapping("/reduction")
diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java
index d6d2a2e6a1..550d97518c 100644
--- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java
+++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java
@@ -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) {
diff --git a/frontend/src/business/components/track/case/components/TestCaseList.vue b/frontend/src/business/components/track/case/components/TestCaseList.vue
index 4c75c44fff..f88b70ca0b 100644
--- a/frontend/src/business/components/track/case/components/TestCaseList.vue
+++ b/frontend/src/business/components/track/case/components/TestCaseList.vue
@@ -226,6 +226,8 @@
+
+
@@ -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;