refactor(性能测试): 重构部分接口,projectID, workspaceID使用接口传入的值

This commit is contained in:
Captain.B 2021-04-26 12:42:03 +08:00 committed by 刘瑞斌
parent 82026932c8
commit e5dbdcb83a
11 changed files with 204 additions and 199 deletions

View File

@ -29,12 +29,9 @@ public class PerformanceReportController {
@Resource
private ReportService reportService;
@GetMapping("/recent/{count}")
@PostMapping("/recent/{count}")
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR)
public List<ReportDTO> recentProjects(@PathVariable int count) {
String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId();
ReportRequest request = new ReportRequest();
request.setWorkspaceId(currentWorkspaceId);
public List<ReportDTO> recentProjects(@PathVariable int count, @RequestBody ReportRequest request) {
request.setUserId(SessionUtils.getUserId());
// 最近 `count` 个项目
PageHelper.startPage(1, count);
@ -43,8 +40,6 @@ public class PerformanceReportController {
@PostMapping("/list/all/{goPage}/{pageSize}")
public Pager<List<ReportDTO>> getReportList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ReportRequest request) {
String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId();
request.setWorkspaceId(currentWorkspaceId);
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, reportService.getReportList(request));
}

View File

@ -55,8 +55,6 @@ public class PerformanceTestController {
@PostMapping("/list/{goPage}/{pageSize}")
public Pager<List<LoadTestDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
request.setProjectId(SessionUtils.getCurrentProjectId());
return PageUtils.setPageInfo(page, performanceTestService.list(request));
}

View File

@ -524,8 +524,8 @@ public class PerformanceTestService {
if (!resourceIds.isEmpty()) {
LoadTestExample example = new LoadTestExample();
LoadTestExample.Criteria criteria = example.createCriteria();
if (StringUtils.isNotBlank(SessionUtils.getCurrentProjectId())) {
criteria.andProjectIdEqualTo(SessionUtils.getCurrentProjectId());
if (StringUtils.isNotBlank(request.getProjectId())) {
criteria.andProjectIdEqualTo(request.getProjectId());
}
criteria.andIdIn(resourceIds);
List<LoadTest> loadTests = loadTestMapper.selectByExample(example);

View File

@ -69,13 +69,11 @@ public class ReportService {
orderRequest.setType("desc");
orders.add(orderRequest);
request.setOrders(orders);
request.setProjectId(SessionUtils.getCurrentProjectId());
return extLoadTestReportMapper.getReportList(request);
}
public List<ReportDTO> getReportList(ReportRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
request.setProjectId(SessionUtils.getCurrentProjectId());
return extLoadTestReportMapper.getReportList(request);
}

View File

@ -27,7 +27,7 @@
</template>
<script>
import {getCurrentWorkspaceId} from "../../../../common/js/utils";
import {getCurrentProjectID, getCurrentWorkspaceId} from "../../../../common/js/utils";
import CrontabResult from "../../common/cron/CrontabResult";
import {SCHEDULE_TYPE} from "../../../../common/js/constants";
@ -40,7 +40,7 @@
tableData: [],
loading: false,
operators: {}
}
};
},
props: {
group: String
@ -55,6 +55,7 @@
if (this.operators.listUrl) {
this.result = this.$post(this.operators.listUrl, {
workspaceId: getCurrentWorkspaceId(),
projectId: getCurrentProjectID(),
group: this.group
}, response => {
this.tableData = response.data;
@ -64,7 +65,7 @@
link(row) {
this.$router.push({
path: this.operators.linkUrl + row.resourceId,
})
});
},
update(schedule) {
this.result = this.$post(this.operators.updateUrl, schedule, response => {
@ -96,7 +97,7 @@
activated() {
this.init();
}
}
};
</script>
<style scoped>

View File

@ -15,8 +15,8 @@
</template>
<script>
import {hasRoles} from "../../../../common/js/utils";
import {ROLE_TEST_MANAGER, ROLE_TEST_USER, ROLE_TEST_VIEWER} from "../../../../common/js/constants";
import {hasRoles} from "@/common/js/utils";
import {ROLE_TEST_MANAGER, ROLE_TEST_USER, ROLE_TEST_VIEWER} from "@/common/js/constants";
export default {
name: "MsRecentList",
@ -30,26 +30,31 @@
return {
result: {},
items: []
}
};
},
computed: {
getIndex: function () {
return function (item) {
return this.options.index(item);
}
};
},
getRouter: function () {
return function (item) {
if (this.options.router) {
return this.options.router(item);
}
}
};
}
},
methods: {
recent: function () {
recent() {
if (hasRoles(ROLE_TEST_VIEWER, ROLE_TEST_USER, ROLE_TEST_MANAGER)) {
if (this.options.condition) {
this.result = this.$post(this.options.url, this.options.condition, (response) => {
this.items = response.data;
});
} else {
this.result = this.$get(this.options.url, (response) => {
this.items = response.data;
});
@ -57,6 +62,7 @@
}
}
}
};
</script>
<style scoped>

View File

@ -46,6 +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";
export default {
name: "PerformanceHeaderMenus",
@ -71,6 +72,10 @@ export default {
reportRecent: {
title: this.$t('report.recent'),
url: "/performance/report/recent/5",
condition: {
workspaceId: getCurrentWorkspaceId(),
projectId: getCurrentProjectID(),
},
showTime: true,
index(item) {
return '/performance/report/view/' + item.id;
@ -79,7 +84,7 @@ export default {
}
},
currentProject: ''
}
};
},
methods: {
registerEvents() {
@ -95,7 +100,7 @@ export default {
beforeDestroy() {
PerformanceEvent.$off(LIST_CHANGE);
}
}
};
</script>

View File

@ -33,6 +33,7 @@
import MsPerformanceReportStatus from "../report/PerformanceReportStatus";
import ReportTriggerModeItem from "../../common/tableItem/ReportTriggerModeItem";
import {getCurrentProjectID, getCurrentWorkspaceId} from "@/common/js/utils";
export default {
name: "MsPerformanceReportRecentList",
@ -41,19 +42,23 @@
return {
result: {},
tableData: []
}
};
},
methods: {
search() {
this.result = this.$get("/performance/report/recent/5", response => {
let condition = {
workspaceId: getCurrentWorkspaceId(),
projectId: getCurrentProjectID(),
};
this.result = this.$post("/performance/report/recent/5", condition, response => {
this.tableData = response.data;
});
},
link(row) {
this.$router.push({
path: '/performance/report/view/' + row.id,
})
});
}
},
@ -63,7 +68,7 @@
activated() {
this.search();
}
}
};
</script>
<style scoped>

View File

@ -98,7 +98,7 @@ import MsTablePagination from "../../common/pagination/TablePagination";
import MsContainer from "../../common/components/MsContainer";
import MsMainContainer from "../../common/components/MsMainContainer";
import MsPerformanceReportStatus from "./PerformanceReportStatus";
import {getCurrentProjectID} from "@/common/js/utils";
import {getCurrentProjectID, getCurrentWorkspaceId} from "@/common/js/utils";
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton";
import ReportTriggerModeItem from "../../common/tableItem/ReportTriggerModeItem";
import {REPORT_CONFIGS} from "../../common/components/search/search-components";
@ -130,7 +130,6 @@ export default {
data() {
return {
result: {},
queryPath: "/performance/report/list/all",
deletePath: "/performance/report/delete/",
condition: {
components: REPORT_CONFIGS
@ -184,7 +183,9 @@ export default {
if (!getCurrentProjectID()) {
return;
}
this.result = this.$post(this.buildPagePath(this.queryPath), this.condition, response => {
this.condition.workspaceId = getCurrentWorkspaceId();
this.condition.projectId = getCurrentProjectID();
this.result = this.$post(this.buildPagePath('/performance/report/list/all'), this.condition, response => {
let data = response.data;
this.total = data.itemCount;
this.tableData = data.listObject;

View File

@ -50,6 +50,7 @@
import MsTablePagination from "@/business/components/common/pagination/TablePagination";
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
import ReportTriggerModeItem from "@/business/components/common/tableItem/ReportTriggerModeItem";
import {WORKSPACE_ID} from "@/common/js/constants";
export default {
name: "SameTestReports",

View File

@ -94,11 +94,11 @@ import MsContainer from "../../common/components/MsContainer";
import MsMainContainer from "../../common/components/MsMainContainer";
import MsPerformanceTestStatus from "./PerformanceTestStatus";
import MsTableOperators from "../../common/components/MsTableOperators";
import {getCurrentProjectID} from "@/common/js/utils";
import {getCurrentProjectID, getCurrentWorkspaceId} from "@/common/js/utils";
import MsTableHeader from "../../common/components/MsTableHeader";
import {TEST_CONFIGS} from "../../common/components/search/search-components";
import {LIST_CHANGE, PerformanceEvent} from "@/business/components/common/head/ListEvent";
import {WORKSPACE_ID} from "@/common/js/constants";
import {PROJECT_ID, WORKSPACE_ID} from "@/common/js/constants";
import {_filter, _sort} from "@/common/js/tableUtils";
export default {
@ -114,7 +114,6 @@ export default {
data() {
return {
result: {},
queryPath: "/performance/list",
deletePath: "/performance/delete",
condition: {
components: TEST_CONFIGS
@ -163,7 +162,7 @@ export default {
},
methods: {
getMaintainerOptions() {
let workspaceId = localStorage.getItem(WORKSPACE_ID);
let workspaceId = getCurrentWorkspaceId();
this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => {
this.userFilters = response.data.map(u => {
return {text: u.name, value: u.id};
@ -171,13 +170,9 @@ export default {
});
},
initTableData() {
if (this.projectId !== 'all') {
this.condition.projectId = this.projectId;
if (!this.condition.projectId) {
return;
}
}
this.result = this.$post(this.buildPagePath(this.queryPath), this.condition, response => {
this.condition.projectId = getCurrentProjectID();
this.condition.workspaceId = getCurrentWorkspaceId();
this.result = this.$post(this.buildPagePath('/performance/list'), this.condition, response => {
let data = response.data;
this.total = data.itemCount;
this.tableData = data.listObject;