This commit is contained in:
Captain.B 2020-02-27 16:18:35 +08:00
parent ce4c1b0af8
commit 54963b2fa0
4 changed files with 12 additions and 29 deletions

View File

@ -1,6 +1,9 @@
package io.metersphere.service;
import io.metersphere.base.domain.*;
import io.metersphere.base.domain.FileContent;
import io.metersphere.base.domain.FileMetadata;
import io.metersphere.base.domain.LoadTestFile;
import io.metersphere.base.domain.LoadTestWithBLOBs;
import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.ExtLoadTestMapper;
import io.metersphere.commons.constants.EngineType;
@ -9,14 +12,11 @@ import io.metersphere.controller.request.testplan.*;
import io.metersphere.dto.LoadTestDTO;
import io.metersphere.engine.Engine;
import io.metersphere.engine.EngineFactory;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;
@ -40,28 +40,6 @@ public class LoadTestService {
@Resource
private FileService fileService;
// 测试模拟数据
@PostConstruct
public void initData() {
if (!CollectionUtils.isEmpty(loadTestMapper.selectByExample(null))) {
return;
}
final List<Project> projects = projectMapper.selectByExample(null);
for (int i = 0; i < 100; i++) {
final LoadTestWithBLOBs loadTest = new LoadTestWithBLOBs();
loadTest.setId(UUID.randomUUID().toString());
loadTest.setName("load test " + i);
loadTest.setProjectId(projects.get(RandomUtils.nextInt(0, projects.size())).getId());
loadTest.setCreateTime(System.currentTimeMillis());
loadTest.setUpdateTime(System.currentTimeMillis());
loadTest.setScenarioDefinition(UUID.randomUUID().toString());
loadTest.setDescription(UUID.randomUUID().toString());
loadTestMapper.insert(loadTest);
}
}
public List<LoadTestDTO> list(QueryTestPlanRequest request) {
return extLoadTestMapper.list(request);
}

View File

@ -42,6 +42,7 @@ const en_US = {
project: {
'recent': 'Recent Projects',
'create': 'Create Project',
'edit': 'Edit Project',
'delete_confirm': 'Are you sure you want to delete this project?',
'search_by_name': 'Search by name',
'input_name': 'Please enter a workspace name',

View File

@ -42,6 +42,7 @@ const zh_CN = {
project: {
'recent': '最近的项目',
'create': '创建项目',
'edit': '编辑项目',
'delete_confirm': '这个项目确定要删除吗?',
'search_by_name': '根据名称搜索',
'input_name': '请输入项目名称',

View File

@ -44,7 +44,7 @@
</div>
</el-card>
<el-dialog :title="$t('project.create')" :visible.sync="createVisible">
<el-dialog :title="title" :visible.sync="createVisible">
<el-form :model="form" :rules="rules" ref="form" label-position="left" label-width="100px" size="small">
<el-form-item :label="$t('commons.name')">
<el-input v-model="form.name" autocomplete="off"></el-input>
@ -73,6 +73,7 @@
createVisible: false,
result: {},
btnTips: this.$t('project.create'),
title: this.$t('project.create'),
condition: "",
items: [],
form: {},
@ -89,7 +90,7 @@
},
mounted() {
if (this.$route.path.split('/')[2] === 'create') {
this.createVisible = true;
this.create();
this.$router.push('/project/all');
}
this.list();
@ -97,7 +98,7 @@
watch: {
'$route'(to) {
if (to.path.split('/')[2] === 'create') {
this.createVisible = true;
this.create();
this.$router.push('/project/all');
}
}
@ -107,10 +108,12 @@
},
methods: {
create() {
this.title = this.$t('project.create');
this.createVisible = true;
this.form = {};
},
edit(row) {
this.title = this.$t('project.edit');
this.createVisible = true;
this.form = Object.assign({}, row);
},