Merge branch 'dev' of https://github.com/metersphere/server into dev
This commit is contained in:
commit
1b6cdb648d
|
@ -1,7 +1,6 @@
|
|||
package io.metersphere.api.service;
|
||||
|
||||
import io.metersphere.api.dto.APITestResult;
|
||||
import io.metersphere.api.dto.DeleteAPITestRequest;
|
||||
import io.metersphere.api.dto.QueryAPITestRequest;
|
||||
import io.metersphere.api.dto.SaveAPITestRequest;
|
||||
import io.metersphere.api.jmeter.JMeterService;
|
||||
|
@ -11,6 +10,7 @@ import io.metersphere.base.mapper.ApiTestMapper;
|
|||
import io.metersphere.base.mapper.ext.ExtApiTestMapper;
|
||||
import io.metersphere.commons.constants.APITestStatus;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.ServiceUtils;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import io.metersphere.service.FileService;
|
||||
|
@ -19,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
@ -26,8 +27,6 @@ import java.util.Objects;
|
|||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class APITestService {
|
||||
|
@ -46,6 +45,7 @@ public class APITestService {
|
|||
private APIReportService apiReportService;
|
||||
|
||||
public List<APITestResult> list(QueryAPITestRequest request) {
|
||||
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
||||
return extApiTestMapper.list(request);
|
||||
}
|
||||
|
||||
|
@ -130,6 +130,7 @@ public class APITestService {
|
|||
test.setScenarioDefinition(request.getScenarioDefinition());
|
||||
test.setUpdateTime(System.currentTimeMillis());
|
||||
test.setStatus(APITestStatus.Saved.name());
|
||||
checkApiTestPlanExist(test);
|
||||
apiTestMapper.updateByPrimaryKeySelective(test);
|
||||
return test;
|
||||
}
|
||||
|
@ -150,10 +151,22 @@ public class APITestService {
|
|||
test.setUpdateTime(System.currentTimeMillis());
|
||||
test.setStatus(APITestStatus.Saved.name());
|
||||
test.setUserId(Objects.requireNonNull(SessionUtils.getUser()).getId());
|
||||
checkApiTestPlanExist(test);
|
||||
apiTestMapper.insert(test);
|
||||
return test;
|
||||
}
|
||||
|
||||
private void checkApiTestPlanExist(ApiTest apiTest) {
|
||||
if (apiTest.getName() != null) {
|
||||
ApiTestExample example = new ApiTestExample();
|
||||
example.createCriteria()
|
||||
.andNameEqualTo(apiTest.getName());
|
||||
if (apiTestMapper.selectByExample(example).size() > 0) {
|
||||
MSException.throwException(Translator.get("api_test_name_already_exists"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveFile(String testId, List<MultipartFile> files) {
|
||||
files.forEach(file -> {
|
||||
final FileMetadata fileMetadata = fileService.saveFile(file);
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
:title="$t('commons.test')"
|
||||
@create="create" :createTip="$t('load_test.create')"/>
|
||||
</template>
|
||||
<el-table :data="tableData" class="table-content">
|
||||
<el-table :data="tableData" class="table-content" @sort-change="sort"
|
||||
@filter-change="filter">
|
||||
<el-table-column :label="$t('commons.name')" width="250" show-overflow-tooltip>
|
||||
<template v-slot:default="scope">
|
||||
<el-link type="info" @click="handleEdit(scope.row)">{{ scope.row.name }}</el-link>
|
||||
|
@ -28,7 +29,7 @@
|
|||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="status" :label="$t('commons.status')"
|
||||
:filter-method="filter"
|
||||
column-key="status"
|
||||
:filters="statusFilters">
|
||||
<template v-slot:default="{row}">
|
||||
<ms-api-test-status :row="row"/>
|
||||
|
@ -55,6 +56,7 @@
|
|||
import MsMainContainer from "../../common/components/MsMainContainer";
|
||||
import MsApiTestStatus from "./ApiTestStatus";
|
||||
import MsTableOperators from "../../common/components/MsTableOperators";
|
||||
import {_filter, _sort} from "../../../../common/js/utils";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
|
@ -150,9 +152,17 @@
|
|||
this.projectId = this.$route.params.projectId;
|
||||
this.search();
|
||||
},
|
||||
filter(value, row) {
|
||||
/* filter(value, row) {
|
||||
return row.status === value;
|
||||
}
|
||||
}*/
|
||||
sort(column) {
|
||||
_sort(column, this.condition);
|
||||
this.initTableData();
|
||||
},
|
||||
filter(filters) {
|
||||
_filter(filters, this.condition);
|
||||
this.initTableData();
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.init();
|
||||
|
|
Loading…
Reference in New Issue