This commit is contained in:
fit2-zhao 2020-12-11 11:21:33 +08:00
commit 5e22b003df
6 changed files with 39 additions and 21 deletions

View File

@ -17,6 +17,7 @@ import io.metersphere.commons.constants.ReportTriggerMode;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.ServiceUtils; import io.metersphere.commons.utils.ServiceUtils;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.dto.DashboardTestDTO; import io.metersphere.dto.DashboardTestDTO;
import io.metersphere.i18n.Translator; import io.metersphere.i18n.Translator;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -48,11 +49,13 @@ public class APIReportService {
public List<APIReportResult> list(QueryAPIReportRequest request) { public List<APIReportResult> list(QueryAPIReportRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
request.setProjectId(SessionUtils.getCurrentProjectId());
return extApiTestReportMapper.list(request); return extApiTestReportMapper.list(request);
} }
public List<APIReportResult> recentTest(QueryAPIReportRequest request) { public List<APIReportResult> recentTest(QueryAPIReportRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
request.setProjectId(SessionUtils.getCurrentProjectId());
return extApiTestReportMapper.list(request); return extApiTestReportMapper.list(request);
} }

View File

@ -1,6 +1,7 @@
package io.metersphere.api.service; package io.metersphere.api.service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.client.utils.StringUtils;
import io.github.ningyu.jmeter.plugin.dubbo.sample.ProviderService; import io.github.ningyu.jmeter.plugin.dubbo.sample.ProviderService;
import io.metersphere.api.dto.*; import io.metersphere.api.dto.*;
import io.metersphere.api.dto.parse.ApiImport; import io.metersphere.api.dto.parse.ApiImport;
@ -67,11 +68,13 @@ public class APITestService {
public List<APITestResult> list(QueryAPITestRequest request) { public List<APITestResult> list(QueryAPITestRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
request.setProjectId(SessionUtils.getCurrentProjectId());
return extApiTestMapper.list(request); return extApiTestMapper.list(request);
} }
public List<APITestResult> recentTest(QueryAPITestRequest request) { public List<APITestResult> recentTest(QueryAPITestRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
request.setProjectId(SessionUtils.getCurrentProjectId());
return extApiTestMapper.list(request); return extApiTestMapper.list(request);
} }
@ -402,7 +405,11 @@ public class APITestService {
.collect(Collectors.toList()); .collect(Collectors.toList());
if (!resourceIds.isEmpty()) { if (!resourceIds.isEmpty()) {
ApiTestExample example = new ApiTestExample(); ApiTestExample example = new ApiTestExample();
example.createCriteria().andIdIn(resourceIds); ApiTestExample.Criteria criteria = example.createCriteria();
criteria.andIdIn(resourceIds);
if (StringUtils.isNotBlank(SessionUtils.getCurrentProjectId())) {
criteria.andProjectIdEqualTo(SessionUtils.getCurrentProjectId());
}
List<ApiTest> apiTests = apiTestMapper.selectByExample(example); List<ApiTest> apiTests = apiTestMapper.selectByExample(example);
Map<String, String> apiTestMap = apiTests.stream().collect(Collectors.toMap(ApiTest::getId, ApiTest::getName)); Map<String, String> apiTestMap = apiTests.stream().collect(Collectors.toMap(ApiTest::getId, ApiTest::getName));
scheduleService.build(apiTestMap, schedules); scheduleService.build(apiTestMap, schedules);

@ -1 +1 @@
Subproject commit bb494fc68a2367359c9048fa7250c7618de4afb6 Subproject commit 905ca8af61ce966d26109e9c5c8c0aee3ca1324e

View File

@ -110,11 +110,11 @@ export default {
apiTestProjectPath: '', apiTestProjectPath: '',
} }
}, },
watch: { // watch: {
'$route'(to) { // '$route'(to) {
this.init(); // this.init();
}, // },
}, // },
methods: { methods: {
registerEvents() { registerEvents() {
ApiEvent.$on(LIST_CHANGE, () => { ApiEvent.$on(LIST_CHANGE, () => {
@ -133,18 +133,17 @@ export default {
this.isRouterAlive = true; this.isRouterAlive = true;
}); });
}, },
init() { // init() {
let path = this.$route.path; // let path = this.$route.path;
if (path.indexOf("/api/test/list") >= 0 && !!this.$route.params.projectId) { // if (path.indexOf("/api/test/list") >= 0 && !!this.$route.params.projectId) {
this.apiTestProjectPath = path; // this.apiTestProjectPath = path;
// // //
this.isProjectActivation = false; // this.isProjectActivation = false;
this.reload(); // this.reload();
} else { // } else {
this.isProjectActivation = true; // this.isProjectActivation = true;
} // }
// },
},
}, },
mounted() { mounted() {
this.registerEvents(); this.registerEvents();

View File

@ -14,7 +14,10 @@
<div v-else style="height: 120px;overflow: auto"> <div v-else style="height: 120px;overflow: auto">
<el-menu-item :key="i.id" v-for="i in items" @click="change(i.id)"> <el-menu-item :key="i.id" v-for="i in items" @click="change(i.id)">
<template slot="title"> <template slot="title">
<div class="title">{{ i.name }}</div> <div class="title">
{{ i.name }}
<i class="el-icon-check" v-if="i.id === projectId"></i>
</div>
</template> </template>
</el-menu-item> </el-menu-item>
</div> </div>
@ -40,6 +43,7 @@ export default {
items: [], items: [],
search_text: '', search_text: '',
userId: getCurrentUser().id, userId: getCurrentUser().id,
projectId: localStorage.getItem(PROJECT_ID)
} }
}, },
watch: { watch: {
@ -97,4 +101,9 @@ export default {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.el-icon-check {
color: #773888;
margin-left: 10px;
}
</style> </style>

@ -1 +1 @@
Subproject commit a22a3005d9bd254793fcf634d72539cbdf31be3a Subproject commit 29a8fc09602fde5708af06582ac972d98eb69836