refactor: 性能测试删除支持指定版本

This commit is contained in:
CaptainB 2022-01-20 15:01:42 +08:00 committed by 刘瑞斌
parent baf498e452
commit af1ea68d23
7 changed files with 70 additions and 59 deletions

View File

@ -130,17 +130,22 @@ public class PerformanceTestService {
} }
public void delete(DeleteTestPlanRequest request) { public void delete(DeleteTestPlanRequest request) {
String testId = request.getId();
LoadTestWithBLOBs loadTest = loadTestMapper.selectByPrimaryKey(request.getId());
LoadTestExample example = new LoadTestExample();
example.createCriteria().andRefIdEqualTo(loadTest.getRefId());
List<LoadTest> loadTests = loadTestMapper.selectByExample(example);
loadTests.forEach(test -> {
if (!request.isForceDelete()) { if (!request.isForceDelete()) {
testCaseService.checkIsRelateTest(testId); testCaseService.checkIsRelateTest(test.getId());
} }
// 删除时保存jmx内容 // 删除时保存jmx内容
List<FileMetadata> fileMetadataList = getFileMetadataByTestId(testId); List<FileMetadata> fileMetadataList = getFileMetadataByTestId(test.getId());
List<FileMetadata> jmxFiles = fileMetadataList.stream().filter(f -> StringUtils.equalsIgnoreCase(f.getType(), FileType.JMX.name())).collect(Collectors.toList()); List<FileMetadata> jmxFiles = fileMetadataList.stream().filter(f -> StringUtils.equalsIgnoreCase(f.getType(), FileType.JMX.name())).collect(Collectors.toList());
byte[] bytes = EngineFactory.mergeJmx(jmxFiles); byte[] bytes = EngineFactory.mergeJmx(jmxFiles);
LoadTestReportExample loadTestReportExample = new LoadTestReportExample(); LoadTestReportExample loadTestReportExample = new LoadTestReportExample();
loadTestReportExample.createCriteria().andTestIdEqualTo(testId); loadTestReportExample.createCriteria().andTestIdEqualTo(test.getId());
List<LoadTestReport> loadTestReports = loadTestReportMapper.selectByExample(loadTestReportExample); List<LoadTestReport> loadTestReports = loadTestReportMapper.selectByExample(loadTestReportExample);
loadTestReports.forEach(loadTestReport -> { loadTestReports.forEach(loadTestReport -> {
LoadTestReportWithBLOBs record = new LoadTestReportWithBLOBs(); LoadTestReportWithBLOBs record = new LoadTestReportWithBLOBs();
@ -149,16 +154,17 @@ public class PerformanceTestService {
extLoadTestReportMapper.updateJmxContentIfAbsent(record); extLoadTestReportMapper.updateJmxContentIfAbsent(record);
}); });
//delete scheduleFunctionalCases //delete scheduleFunctionalCases
scheduleService.deleteByResourceId(testId, ScheduleGroup.PERFORMANCE_TEST.name()); scheduleService.deleteByResourceId(test.getId(), ScheduleGroup.PERFORMANCE_TEST.name());
// delete load_test // delete load_test
loadTestMapper.deleteByPrimaryKey(request.getId()); loadTestMapper.deleteByPrimaryKey(test.getId());
testPlanLoadCaseService.deleteByTestId(testId); testPlanLoadCaseService.deleteByTestId(test.getId());
detachFileByTestId(request.getId()); detachFileByTestId(test.getId());
deleteFollows(request.getId()); deleteFollows(test.getId());
});
} }
private void deleteFollows(String testId) { private void deleteFollows(String testId) {

View File

@ -290,7 +290,7 @@
<ms-task-center ref="taskCenter" :show-menu="false"/> <ms-task-center ref="taskCenter" :show-menu="false"/>
<relationship-graph-drawer :graph-data="graphData" ref="relationshipGraph"/> <relationship-graph-drawer :graph-data="graphData" ref="relationshipGraph"/>
<!-- 删除接口提示 --> <!-- 删除接口提示 -->
<api-delete-confirm ref="apiDeleteConfirm" @handleDelete="_handleDelete"/> <list-item-delete-confirm ref="apiDeleteConfirm" @handleDelete="_handleDelete"/>
</div> </div>
</template> </template>
@ -316,7 +316,7 @@ import axios from "axios";
import {getGraphByCondition} from "@/network/graph"; import {getGraphByCondition} from "@/network/graph";
import MsTableSearchBar from "@/business/components/common/components/MsTableSearchBar"; import MsTableSearchBar from "@/business/components/common/components/MsTableSearchBar";
import MsTableAdvSearchBar from "@/business/components/common/components/search/MsTableAdvSearchBar"; import MsTableAdvSearchBar from "@/business/components/common/components/search/MsTableAdvSearchBar";
import ApiDeleteConfirm from "@/business/components/api/definition/components/list/ApiDeleteConfirm"; import ListItemDeleteConfirm from "@/business/components/common/components/ListItemDeleteConfirm";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/); const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const relationshipGraphDrawer = requireComponent.keys().length > 0 ? requireComponent("./graph/RelationshipGraphDrawer.vue") : {}; const relationshipGraphDrawer = requireComponent.keys().length > 0 ? requireComponent("./graph/RelationshipGraphDrawer.vue") : {};
@ -324,7 +324,7 @@ const relationshipGraphDrawer = requireComponent.keys().length > 0 ? requireComp
export default { export default {
name: "MsApiScenarioList", name: "MsApiScenarioList",
components: { components: {
ApiDeleteConfirm, ListItemDeleteConfirm,
MsTableAdvSearchBar, MsTableAdvSearchBar,
MsTableSearchBar, MsTableSearchBar,
MsTable, MsTable,

View File

@ -207,7 +207,7 @@
<relationship-graph-drawer :graph-data="graphData" ref="relationshipGraph"/> <relationship-graph-drawer :graph-data="graphData" ref="relationshipGraph"/>
<!-- 删除接口提示 --> <!-- 删除接口提示 -->
<api-delete-confirm ref="apiDeleteConfirm" @handleDelete="_handleDelete"/> <list-item-delete-confirm ref="apiDeleteConfirm" @handleDelete="_handleDelete"/>
</span> </span>
</template> </template>
@ -227,7 +227,7 @@ import MsTableColumn from "@/business/components/common/components/table/MsTable
import MsBottomContainer from "../BottomContainer"; import MsBottomContainer from "../BottomContainer";
import MsBatchEdit from "../basis/BatchEdit"; import MsBatchEdit from "../basis/BatchEdit";
import {API_METHOD_COLOUR, API_STATUS, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData"; import {API_METHOD_COLOUR, API_STATUS, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData";
import {downloadFile, getCurrentProjectID, getUUID, hasLicense} from "@/common/js/utils"; import {downloadFile, getCurrentProjectID, hasLicense} from "@/common/js/utils";
import {API_LIST} from '@/common/js/constants'; import {API_LIST} from '@/common/js/constants';
import MsTableHeaderSelectPopover from "@/business/components/common/components/table/MsTableHeaderSelectPopover"; import MsTableHeaderSelectPopover from "@/business/components/common/components/table/MsTableHeaderSelectPopover";
import ApiStatus from "@/business/components/api/definition/components/list/ApiStatus"; import ApiStatus from "@/business/components/api/definition/components/list/ApiStatus";
@ -247,7 +247,7 @@ import {Body} from "@/business/components/api/definition/model/ApiTestModel";
import {editApiDefinitionOrder} from "@/network/api"; import {editApiDefinitionOrder} from "@/network/api";
import {getProtocolFilter} from "@/business/components/api/definition/api-definition"; import {getProtocolFilter} from "@/business/components/api/definition/api-definition";
import {getGraphByCondition} from "@/network/graph"; import {getGraphByCondition} from "@/network/graph";
import ApiDeleteConfirm from "@/business/components/api/definition/components/list/ApiDeleteConfirm"; import ListItemDeleteConfirm from "@/business/components/common/components/ListItemDeleteConfirm";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/); const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const relationshipGraphDrawer = requireComponent.keys().length > 0 ? requireComponent("./graph/RelationshipGraphDrawer.vue") : {}; const relationshipGraphDrawer = requireComponent.keys().length > 0 ? requireComponent("./graph/RelationshipGraphDrawer.vue") : {};
@ -256,7 +256,7 @@ const relationshipGraphDrawer = requireComponent.keys().length > 0 ? requireComp
export default { export default {
name: "ApiList", name: "ApiList",
components: { components: {
ApiDeleteConfirm, ListItemDeleteConfirm,
HeaderLabelOperate, HeaderLabelOperate,
CaseBatchMove, CaseBatchMove,
ApiStatus, ApiStatus,

View File

@ -23,7 +23,7 @@
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter"; import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
export default { export default {
name: "ApiDeleteConfirm", name: "ListItemDeleteConfirm",
components: {MsDialogFooter}, components: {MsDialogFooter},
data() { data() {
return { return {

View File

@ -22,7 +22,7 @@
<i class="el-icon-star-on" style="color: #783987; font-size: 28px; margin-right: 15px;cursor: pointer;position: relative; top: 5px; " @click="saveFollow" /> <i class="el-icon-star-on" style="color: #783987; font-size: 28px; margin-right: 15px;cursor: pointer;position: relative; top: 5px; " @click="saveFollow" />
</el-tooltip> </el-tooltip>
<el-link type="primary" size="small" style="margin-right: 20px" @click="openHis" v-if="test.id"> <el-link type="primary" size="small" style="margin-right: 5px" @click="openHis" v-if="test.id">
{{ $t('operating_log.change_history') }} {{ $t('operating_log.change_history') }}
</el-link> </el-link>
<ms-version-history v-xpack <ms-version-history v-xpack

View File

@ -106,6 +106,8 @@
:total="total"/> :total="total"/>
</el-card> </el-card>
</ms-main-container> </ms-main-container>
<!-- 删除接口提示 -->
<list-item-delete-confirm ref="apiDeleteConfirm" @handleDelete="_handleDelete"/>
</ms-container> </ms-container>
</template> </template>
@ -122,9 +124,11 @@ import {TEST_CONFIGS} from "../../common/components/search/search-components";
import {getLastTableSortField} from "@/common/js/tableUtils"; import {getLastTableSortField} from "@/common/js/tableUtils";
import MsTable from "@/business/components/common/components/table/MsTable"; import MsTable from "@/business/components/common/components/table/MsTable";
import {editLoadTestCaseOrder} from "@/network/load-test"; import {editLoadTestCaseOrder} from "@/network/load-test";
import ListItemDeleteConfirm from "@/business/components/common/components/ListItemDeleteConfirm";
export default { export default {
components: { components: {
ListItemDeleteConfirm,
MsTable, MsTable,
MsTableHeader, MsTableHeader,
MsPerformanceTestStatus, MsPerformanceTestStatus,
@ -252,24 +256,24 @@ export default {
}); });
}, },
handleDelete(test) { handleDelete(test) {
this.$alert(this.$t('load_test.delete_confirm') + test.name + "", '', { //
confirmButtonText: this.$t('commons.confirm'), this.$refs.apiDeleteConfirm.open(test, this.$t('load_test.delete_confirm'));
callback: (action) => {
if (action === 'confirm') {
this._handleDelete(test);
}
}
});
}, },
_handleDelete(test) { _handleDelete(test, deleteCurrentVersion) {
if (deleteCurrentVersion) {
this.$get('performance/delete/' + test.id + '/' + test.refId, () => {
this.$success(this.$t('commons.delete_success'));
this.getVersionHistory();
});
} else {
let data = { let data = {
id: test.id id: test.id
}; };
this.result = this.$post(this.deletePath, data, () => { this.result = this.$post(this.deletePath, data, () => {
this.$success(this.$t('commons.delete_success')); this.$success(this.$t('commons.delete_success'));
this.initTableData(); this.initTableData();
}); });
}
}, },
link(row) { link(row) {
this.$router.push({ this.$router.push({

View File

@ -227,7 +227,7 @@
<!--高级搜索--> <!--高级搜索-->
<ms-table-adv-search-bar :condition.sync="condition" :showLink="false" ref="searchBar" @search="search"/> <ms-table-adv-search-bar :condition.sync="condition" :showLink="false" ref="searchBar" @search="search"/>
<!-- 删除接口提示 --> <!-- 删除接口提示 -->
<api-delete-confirm ref="apiDeleteConfirm" @handleDelete="_handleDeleteVersion"/> <list-item-delete-confirm ref="apiDeleteConfirm" @handleDelete="_handleDeleteVersion"/>
</span> </span>
</template> </template>
@ -259,14 +259,15 @@ import {
deepClone, deepClone,
getCustomFieldBatchEditOption, getCustomFieldBatchEditOption,
getCustomFieldValue, getCustomFieldValue,
getCustomTableWidth, getLastTableSortField, getCustomTableWidth,
getLastTableSortField,
getPageInfo, getPageInfo,
getTableHeaderWithCustomFields, getTableHeaderWithCustomFields,
initCondition, initCondition,
} from "@/common/js/tableUtils"; } from "@/common/js/tableUtils";
import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate"; import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate";
import PlanStatusTableItem from "@/business/components/track/common/tableItems/plan/PlanStatusTableItem"; import PlanStatusTableItem from "@/business/components/track/common/tableItems/plan/PlanStatusTableItem";
import {getCurrentProjectID, getCurrentUserId, getCurrentWorkspaceId, hasLicense} from "@/common/js/utils"; import {getCurrentProjectID, getCurrentUserId, getCurrentWorkspaceId, getUUID, hasLicense} from "@/common/js/utils";
import {getTestTemplate} from "@/network/custom-field-template"; import {getTestTemplate} from "@/network/custom-field-template";
import {getProjectMember} from "@/network/user"; import {getProjectMember} from "@/network/user";
import MsTable from "@/business/components/common/components/table/MsTable"; import MsTable from "@/business/components/common/components/table/MsTable";
@ -277,14 +278,15 @@ import TestCasePreview from "@/business/components/track/case/components/TestCas
import {editTestCaseOrder} from "@/network/testCase"; import {editTestCaseOrder} from "@/network/testCase";
import {getGraphByCondition} from "@/network/graph"; import {getGraphByCondition} from "@/network/graph";
import MsTableAdvSearchBar from "@/business/components/common/components/search/MsTableAdvSearchBar"; import MsTableAdvSearchBar from "@/business/components/common/components/search/MsTableAdvSearchBar";
import {getUUID} from "@/common/js/utils"; import ListItemDeleteConfirm from "@/business/components/common/components/ListItemDeleteConfirm";
import ApiDeleteConfirm from "@/business/components/api/definition/components/list/ApiDeleteConfirm";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/); const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const relationshipGraphDrawer = requireComponent.keys().length > 0 ? requireComponent("./graph/RelationshipGraphDrawer.vue") : {}; const relationshipGraphDrawer = requireComponent.keys().length > 0 ? requireComponent("./graph/RelationshipGraphDrawer.vue") : {};
export default { export default {
name: "TestCaseList", name: "TestCaseList",
components: { components: {
ListItemDeleteConfirm,
MsTableAdvSearchBar, MsTableAdvSearchBar,
TestCasePreview, TestCasePreview,
BatchMove, BatchMove,
@ -310,7 +312,6 @@ export default {
ReviewStatus, ReviewStatus,
MsTag, ApiStatus, MsTag, ApiStatus,
"relationshipGraphDrawer": relationshipGraphDrawer.default, "relationshipGraphDrawer": relationshipGraphDrawer.default,
ApiDeleteConfirm
}, },
data() { data() {
return { return {