This commit is contained in:
chenjianxing 2020-06-01 17:26:20 +08:00
commit e3f364c0b0
8 changed files with 105 additions and 15 deletions

View File

@ -27,7 +27,12 @@
AND load_test.id = #{request.id}
</if>
</where>
order by load_test.update_time desc
<if test="request.orders != null and request.orders.size() > 0">
order by
<foreach collection="request.orders" separator="," item="order">
load_test.${order.name} ${order.type}
</foreach>
</if>
</select>
<select id="countByProjectId" resultType="java.lang.Long">
select count(id) from load_test

View File

@ -140,7 +140,7 @@ public class UserController {
}
@PostMapping("/switch/source/org/{sourceId}")
@RequiresRoles(RoleConstants.ORG_ADMIN)
@RequiresRoles(value = {RoleConstants.ORG_ADMIN, RoleConstants.TEST_MANAGER, RoleConstants.TEST_VIEWER, RoleConstants.TEST_USER}, logical = Logical.OR)
public UserDTO switchOrganization(@PathVariable(value = "sourceId") String sourceId) {
userService.switchUserRole("organization", sourceId);
return SessionUtils.getUser();

View File

@ -20,7 +20,6 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.util.List;
@ -113,4 +112,9 @@ public class PerformanceTestController {
public List<DashboardTestDTO> dashboardTests() {
return performanceTestService.dashboardTests(SessionUtils.getCurrentWorkspaceId());
}
@PostMapping(value = "/copy")
public void copy(@RequestBody SaveTestPlanRequest request) {
performanceTestService.copy(request);
}
}

View File

@ -1,10 +1,12 @@
package io.metersphere.performance.service;
import io.metersphere.api.dto.SaveAPITestRequest;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.ExtLoadTestMapper;
import io.metersphere.base.mapper.ext.ExtLoadTestReportDetailMapper;
import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper;
import io.metersphere.commons.constants.APITestStatus;
import io.metersphere.commons.constants.PerformanceTestStatus;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.LogUtil;
@ -28,6 +30,7 @@ import javax.annotation.Resource;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
@ -285,4 +288,28 @@ public class PerformanceTestService {
public List<LoadTest> getLoadTestByProjectId(String projectId) {
return extLoadTestMapper.getLoadTestByProjectId(projectId);
}
public void copy(SaveTestPlanRequest request) {
// copy test
LoadTestWithBLOBs copy = loadTestMapper.selectByPrimaryKey(request.getId());
copy.setId(UUID.randomUUID().toString());
copy.setName(copy.getName() + " Copy");
copy.setCreateTime(System.currentTimeMillis());
copy.setUpdateTime(System.currentTimeMillis());
copy.setStatus(APITestStatus.Saved.name());
copy.setUserId(Objects.requireNonNull(SessionUtils.getUser()).getId());
loadTestMapper.insert(copy);
// copy test file
LoadTestFileExample loadTestFileExample = new LoadTestFileExample();
loadTestFileExample.createCriteria().andTestIdEqualTo(request.getId());
List<LoadTestFile> loadTestFiles = loadTestFileMapper.selectByExample(loadTestFileExample);
if (!CollectionUtils.isEmpty(loadTestFiles)) {
loadTestFiles.forEach(loadTestFile -> {
FileMetadata fileMetadata = fileService.copyFile(loadTestFile.getFileId());
loadTestFile.setTestId(copy.getId());
loadTestFile.setFileId(fileMetadata.getId());
loadTestFileMapper.insert(loadTestFile);
});
}
}
}

View File

@ -1,10 +1,14 @@
package io.metersphere.track.request.testplan;
import io.metersphere.controller.request.OrderRequest;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class QueryTestPlanRequest extends TestPlanRequest {
private String workspaceId;
private List<OrderRequest> orders;
}

View File

@ -125,7 +125,7 @@
this.$warning(this.$t('report.generation_error'));
return false
} else if (report.status === "Starting") {
this.$info(this.$t('being_generated'))
this.$info(this.$t('report.being_generated'))
return false
}
this.$router.push({

View File

@ -10,17 +10,24 @@
<el-input type="text" size="small" :placeholder="$t('load_test.search_by_name')"
prefix-icon="el-icon-search"
maxlength="60"
v-model="condition" @change="search" clearable/>
v-model="condition.name" @change="search" clearable/>
</span>
</el-row>
</div>
</template>
<el-table :data="tableData" class="test-content">
<!-- @sort-change="sort"-->
<el-table :data="tableData" class="test-content"
:default-sort="{prop: 'createTime', order: 'descending'}"
>
<el-table-column
prop="name"
:label="$t('commons.name')"
width="150"
show-overflow-tooltip>
<template v-slot:default="scope">
<el-link type="info" @click="link(scope.row)">{{ scope.row.name }}</el-link>
</template>
</el-table-column>
<el-table-column
prop="projectName"
@ -36,6 +43,8 @@
</el-table-column>
<el-table-column
width="250"
sortable
prop="createTime"
:label="$t('commons.create_time')">
<template v-slot:default="scope">
<span>{{ scope.row.createTime | timestampFormatDate }}</span>
@ -43,6 +52,8 @@
</el-table-column>
<el-table-column
width="250"
sortable
prop="updateTime"
:label="$t('commons.update_time')">
<template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
@ -59,7 +70,7 @@
width="150"
:label="$t('commons.operating')">
<template v-slot:default="scope">
<ms-table-operator :is-tester-permission="true" @editClick="handleEdit(scope.row)" @deleteClick="handleDelete(scope.row)"/>
<ms-table-operators :buttons="buttons" :row="scope.row"/>
</template>
</el-table-column>
</el-table>
@ -76,6 +87,8 @@
import MsContainer from "../../common/components/MsContainer";
import MsMainContainer from "../../common/components/MsMainContainer";
import MsPerformanceTestStatus from "./PerformanceTestStatus";
import MsTableOperators from "../../common/components/MsTableOperators";
import {_sort} from "../../../../common/js/utils";
export default {
components: {
@ -83,14 +96,15 @@
MsTablePagination,
MsTableOperator,
MsContainer,
MsMainContainer
MsMainContainer,
MsTableOperators
},
data() {
return {
result: {},
queryPath: "/performance/list",
deletePath: "/performance/delete",
condition: "",
condition: {},
projectId: null,
tableData: [],
multipleSelection: [],
@ -99,6 +113,18 @@
total: 0,
loading: false,
testId: null,
buttons: [
{
tip: this.$t('commons.edit'), icon: "el-icon-edit",
exec: this.handleEdit
}, {
tip: this.$t('commons.copy'), icon: "el-icon-copy-document", type: "success",
exec: this.handleCopy
}, {
tip: this.$t('commons.delete'), icon: "el-icon-delete", type: "danger",
exec: this.handleDelete
}
]
}
},
watch: {
@ -113,15 +139,12 @@
},
methods: {
initTableData() {
let param = {
name: this.condition,
};
if (this.projectId !== 'all') {
param.projectId = this.projectId;
this.condition.projectId = this.projectId;
}
this.result = this.$post(this.buildPagePath(this.queryPath), param, response => {
this.result = this.$post(this.buildPagePath(this.queryPath), this.condition, response => {
let data = response.data;
this.total = data.itemCount;
this.tableData = data.listObject;
@ -141,6 +164,12 @@
path: '/performance/test/edit/' + testPlan.id,
})
},
handleCopy(testPlan) {
this.result = this.$post("/performance/copy", {id: testPlan.id}, () => {
this.$success(this.$t('commons.save_success'));
this.search();
});
},
handleDelete(testPlan) {
this.$alert(this.$t('load_test.delete_confirm') + testPlan.name + "", '', {
confirmButtonText: this.$t('commons.confirm'),
@ -161,6 +190,15 @@
this.initTableData();
});
},
// sort(column) {
// _sort(column, this.condition);
// this.initTableData();
// },
link(row) {
this.$router.push({
path: '/performance/test/edit/' + row.id,
})
}
}
}
</script>

View File

@ -7,7 +7,11 @@
:create-tip="btnTips" :title="title"/>
</template>
<el-table :data="items" style="width: 100%">
<el-table-column prop="name" :label="$t('commons.name')"/>
<el-table-column prop="name" :label="$t('commons.name')">
<template v-slot:default="scope">
<el-link type="info" @click="link(scope.row)">{{ scope.row.name }}</el-link>
</template>
</el-table-column>
<el-table-column prop="description" :label="$t('commons.description')"/>
<!--<el-table-column prop="workspaceName" :label="$t('project.owning_workspace')"/>-->
<el-table-column
@ -212,6 +216,14 @@
} else {
return result;
}
},
link(row) {
// performance_test project link
if (this.$route.name === 'perProject') {
this.$router.push({
path: '/performance/test/' + row.id,
})
}
}
}
}