refactor(性能测试): 最近的测试和报告接口重构

This commit is contained in:
Captain.B 2021-04-26 13:06:40 +08:00 committed by 刘瑞斌
parent e5dbdcb83a
commit 4e7a039d49
6 changed files with 50 additions and 40 deletions

View File

@ -32,7 +32,6 @@ public class PerformanceReportController {
@PostMapping("/recent/{count}")
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR)
public List<ReportDTO> recentProjects(@PathVariable int count, @RequestBody ReportRequest request) {
request.setUserId(SessionUtils.getUserId());
// 最近 `count` 个项目
PageHelper.startPage(1, count);
return reportService.getRecentReportList(request);

View File

@ -42,12 +42,8 @@ public class PerformanceTestController {
@Resource
private CheckPermissionService checkPermissionService;
@GetMapping("recent/{count}")
public List<LoadTestDTO> recentTestPlans(@PathVariable int count) {
String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId();
QueryTestPlanRequest request = new QueryTestPlanRequest();
request.setWorkspaceId(currentWorkspaceId);
request.setUserId(SessionUtils.getUserId());
@PostMapping("recent/{count}")
public List<LoadTestDTO> recentTestPlans(@PathVariable int count, @RequestBody QueryTestPlanRequest request) {
PageHelper.startPage(1, count, true);
return performanceTestService.recentTestPlans(request);
}

View File

@ -382,7 +382,6 @@ public class PerformanceTestService {
orderRequest.setType("desc");
orders.add(orderRequest);
request.setOrders(orders);
request.setProjectId(SessionUtils.getCurrentProjectId());
return extLoadTestMapper.list(request);
}

View File

@ -46,7 +46,7 @@ import MsShowAll from "../../common/head/ShowAll";
import {LIST_CHANGE, PerformanceEvent} from "@/business/components/common/head/ListEvent";
import SearchList from "@/business/components/common/head/SearchList";
import ProjectChange from "@/business/components/common/head/ProjectSwitch";
import {getCurrentProjectID, getCurrentWorkspaceId} from "@/common/js/utils";
import {getCurrentProjectID, getCurrentUserId, getCurrentWorkspaceId} from "@/common/js/utils";
export default {
name: "PerformanceHeaderMenus",
@ -63,6 +63,11 @@ export default {
testRecent: {
title: this.$t('load_test.recent'),
url: "/performance/recent/5",
condition: {
workspaceId: getCurrentWorkspaceId(),
projectId: getCurrentProjectID(),
userId: getCurrentUserId()
},
index(item) {
return '/performance/test/edit/' + item.id;
},
@ -75,6 +80,7 @@ export default {
condition: {
workspaceId: getCurrentWorkspaceId(),
projectId: getCurrentProjectID(),
userId: getCurrentUserId()
},
showTime: true,
index(item) {

View File

@ -1,7 +1,7 @@
<template>
<el-card class="table-card" v-loading="result.loading">
<template v-slot:header>
<span class="title">{{$t('commons.test')}}</span>
<span class="title">{{ $t('commons.test') }}</span>
</template>
<el-table border :data="tableData" class="adjust-table table-content" @row-click="link" height="300px">
<el-table-column prop="name" :label="$t('commons.name')" width="150" show-overflow-tooltip/>
@ -27,44 +27,49 @@
<script>
import MsPerformanceTestStatus from "../test/PerformanceTestStatus";
import MsPerformanceTestStatus from "../test/PerformanceTestStatus";
import {getCurrentProjectID, getCurrentWorkspaceId} from "@/common/js/utils";
export default {
name: "MsPerformanceTestRecentList",
components: {MsPerformanceTestStatus},
data() {
return {
result: {},
tableData: []
}
},
export default {
name: "MsPerformanceTestRecentList",
components: {MsPerformanceTestStatus},
data() {
return {
result: {},
tableData: []
};
},
methods: {
search() {
this.result = this.$get("/performance/recent/5", response => {
this.tableData = response.data;
});
},
link(row) {
this.$router.push({
path: '/performance/test/edit/' + row.id,
})
}
methods: {
search() {
let condition = {
workspaceId: getCurrentWorkspaceId(),
projectId: getCurrentProjectID()
};
this.result = this.$post("/performance/recent/5", condition, response => {
this.tableData = response.data;
});
},
created() {
this.search();
},
activated() {
this.search();
link(row) {
this.$router.push({
path: '/performance/test/edit/' + row.id,
});
}
},
created() {
this.search();
},
activated() {
this.search();
}
};
</script>
<style scoped>
.el-table {
cursor:pointer;
}
.el-table {
cursor: pointer;
}
</style>

View File

@ -95,6 +95,11 @@ export function getCurrentUser() {
return JSON.parse(localStorage.getItem(TokenKey));
}
export function getCurrentUserId() {
let user = JSON.parse(localStorage.getItem(TokenKey));
return user.id;
}
export function getCurrentProjectID() {
return localStorage.getItem(PROJECT_ID);
}