refactor: 去掉 $$get 方法

This commit is contained in:
Captain.B 2020-12-25 15:26:24 +08:00
parent 414674d833
commit fa5a693d1f
7 changed files with 28 additions and 34 deletions

View File

@ -1,5 +1,6 @@
package io.metersphere.api.controller; package io.metersphere.api.controller;
import io.metersphere.api.dto.ApiMonitorRequest;
import io.metersphere.api.dto.ApiMonitorSearch; import io.metersphere.api.dto.ApiMonitorSearch;
import io.metersphere.api.dto.ApiResponseCodeMonitor; import io.metersphere.api.dto.ApiResponseCodeMonitor;
import io.metersphere.api.dto.ApiResponseTimeMonitor; import io.metersphere.api.dto.ApiResponseTimeMonitor;
@ -32,24 +33,24 @@ public class ApiMonitorController {
/** /**
* 查询响应时间 * 查询响应时间
*/ */
@GetMapping("/getResponseTime") @PostMapping("/getResponseTime")
public List<ApiResponseTimeMonitor> responseTimeData(@RequestHeader("apiUrl") String url, String startTime, String endTime) { public List<ApiResponseTimeMonitor> responseTimeData(@RequestBody ApiMonitorRequest request) {
return apiMonitorService.getApiResponseTimeData(url, startTime, endTime); return apiMonitorService.getApiResponseTimeData(request.getUrl(), request.getStartTime(), request.getEndTime());
} }
/** /**
* 查询状态码 * 查询状态码
*/ */
@GetMapping("/getResponseCode") @PostMapping("/getResponseCode")
public List<ApiResponseCodeMonitor> responseCodeData(@RequestHeader("apiUrl") String url, String startTime, String endTime) { public List<ApiResponseCodeMonitor> responseCodeData(@RequestBody ApiMonitorRequest request) {
return apiMonitorService.getApiResponseCodeData(url, startTime, endTime); return apiMonitorService.getApiResponseCodeData(request.getUrl(), request.getStartTime(), request.getEndTime());
} }
/** /**
* 查询reportId * 查询reportId
*/ */
@GetMapping("/getReportId") @PostMapping("/getReportId")
public String searchReportId(@RequestHeader("apiUrl") String url, @RequestParam("startTime") String startTime) { public String searchReportId(@RequestBody ApiMonitorRequest request) {
return apiMonitorService.getReportId(url, startTime); return apiMonitorService.getReportId(request.getUrl(), request.getStartTime());
} }
} }

View File

@ -0,0 +1,11 @@
package io.metersphere.api.dto;
import lombok.Data;
@Data
public class ApiMonitorRequest {
private String url;
private String startTime;
private String endTime;
}

@ -1 +1 @@
Subproject commit 79343a2763b014355f91fc21b2356a95ae437973 Subproject commit f27d1609d77f7d6c988d37d709466e844d350e17

View File

@ -80,9 +80,8 @@ export default {
this.getResponseCode(this.apiUrl, today1, today2); this.getResponseCode(this.apiUrl, today1, today2);
}, },
getResponseTime(apiUrl, startTime, endTime) { getResponseTime(apiUrl, startTime, endTime) {
return this.$$get('/api/monitor/getResponseTime', return this.$post('/api/monitor/getResponseTime',
{'startTime': startTime, 'endTime': endTime}, {'startTime': startTime, 'endTime': endTime, 'apiUrl': apiUrl}, response => {
{'apiUrl': apiUrl}, response => {
Object.values(response.data).forEach(value => { Object.values(response.data).forEach(value => {
this.rspTimexAxis.push(value.startTime); this.rspTimexAxis.push(value.startTime);
this.rspTimeData.push(value.responseTime); this.rspTimeData.push(value.responseTime);
@ -90,9 +89,8 @@ export default {
}); });
}, },
getResponseCode(apiUrl, startTime, endTime) { getResponseCode(apiUrl, startTime, endTime) {
return this.$$get('/api/monitor/getResponseCode', return this.$post('/api/monitor/getResponseCode',
{'startTime': startTime, 'endTime': endTime}, {'startTime': startTime, 'endTime': endTime, 'apiUrl': this.apiUrl}, response => {
{'apiUrl': this.apiUrl}, response => {
Object.values(response.data).forEach(value => { Object.values(response.data).forEach(value => {
this.rspCodexAxis.push(value.startTime); this.rspCodexAxis.push(value.startTime);
this.rspCodeData.push(value.responseCode); this.rspCodeData.push(value.responseCode);

View File

@ -28,9 +28,7 @@ export default {
methods: { methods: {
click(params) { click(params) {
let startTime = params.name; let startTime = params.name;
this.result = this.$$get('/api/monitor/getReportId', {'startTime': startTime}, { this.result = this.$post('/api/monitor/getReportId', {'startTime': startTime, 'apiUrl': this.apiUrl}, response => {
'apiUrl': this.apiUrl
}, response => {
this.reportId = response.data; this.reportId = response.data;
let reportId = this.reportId let reportId = this.reportId
let url = '#/api/report/view/' + reportId; let url = '#/api/report/view/' + reportId;

@ -1 +1 @@
Subproject commit 8cda5c873cd9985c97adb34efacf507167fa4182 Subproject commit 7d43154a7c19732407a8e9ace8a7d1ea13c91f36

View File

@ -74,20 +74,6 @@ export default {
} }
} }
Vue.prototype.$$get = function (url, data, header, success) {
let result = {loading: true};
if (!success) {
return axios.get(url, {params: data, headers: header});
} else {
axios.get(url, {params: data, headers: header}).then(response => {
then(success, response, result);
}).catch(error => {
exception(error, result, url);
});
return result;
}
};
Vue.prototype.$get = function (url, success) { Vue.prototype.$get = function (url, success) {
let result = {loading: true}; let result = {loading: true};
if (!success) { if (!success) {