Merge remote-tracking branch 'origin/master'

This commit is contained in:
song.tianyang 2021-03-25 12:02:19 +08:00
commit cf39bb066d
9 changed files with 92 additions and 12 deletions

View File

@ -88,7 +88,12 @@ public class ProjectController {
@PostMapping(value = "upload/files/{projectId}", consumes = {"multipart/form-data"})
public List<FileMetadata> uploadFiles(@PathVariable String projectId, @RequestPart(value = "file") List<MultipartFile> files) {
return projectService.uploadFiles(projectId, files);
return projectService.uploadFiles(projectId, files);
}
@PostMapping(value = "/update/file/{projectId}/{fileId}", consumes = {"multipart/form-data"})
public FileMetadata updateFile(@PathVariable String projectId, @PathVariable String fileId, @RequestPart(value = "file") MultipartFile file) {
return projectService.updateFile(projectId, fileId, file);
}
@GetMapping(value = "delete/file/{fileId}")

View File

@ -73,9 +73,13 @@ public class FileService {
fileContentMapper.deleteByExample(example2);
}
public FileMetadata saveFile(MultipartFile file, String projectId) {
public FileMetadata saveFile(MultipartFile file, String projectId, String fileId) {
final FileMetadata fileMetadata = new FileMetadata();
fileMetadata.setId(UUID.randomUUID().toString());
if (StringUtils.isEmpty(fileId)) {
fileMetadata.setId(UUID.randomUUID().toString());
} else {
fileMetadata.setId(fileId);
}
fileMetadata.setName(file.getOriginalFilename());
fileMetadata.setSize(file.getSize());
fileMetadata.setProjectId(projectId);
@ -97,6 +101,10 @@ public class FileService {
return fileMetadata;
}
public FileMetadata saveFile(MultipartFile file, String projectId) {
return saveFile(file, projectId, null);
}
public FileMetadata saveFile(MultipartFile file) {
return saveFile(file, null);
}
@ -205,7 +213,7 @@ public class FileService {
if (!StringUtils.isEmpty(request.getName())) {
criteria.andNameEqualTo(request.getName());
}
return fileMetadataMapper.selectByExample(example);
return fileMetadataMapper.selectByExample(example);
}
public List<FileMetadata> getFileMetadataByIds(List<String> fileIds) {

View File

@ -186,6 +186,18 @@ public class ProjectService {
return result;
}
public FileMetadata updateFile(String projectId, String fileId, MultipartFile file) {
QueryProjectFileRequest request = new QueryProjectFileRequest();
request.setName(file.getOriginalFilename());
if (CollectionUtils.isEmpty(fileService.getProjectFiles(projectId, request))) {
fileService.deleteFileById(fileId);
return fileService.saveFile(file, projectId);
} else {
MSException.throwException(Translator.get("project_file_already_exists"));
}
return null;
}
public void deleteFile(String fileId) {
LoadTestFileExample example1 = new LoadTestFileExample();
example1.createCriteria().andFileIdEqualTo(fileId);
@ -216,4 +228,5 @@ public class ProjectService {
}
fileService.deleteFileById(fileId);
}
}

View File

@ -206,7 +206,9 @@ create table system_header
(
type varchar(150) null,
props varchar(1000) null
);
)ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4;
-- init system_header
insert into system_header (type, props)
values ('api_scenario_list',

View File

@ -11,8 +11,7 @@
<p style="margin-left: 60px">您好:
</div>
<div style="margin-left: 100px">
successContext = "接口测试定时任务通知:'" + report.getName() + "'执行成功" + "\n" + "【接口定义暂无报告链接】"+"\n" +"请点击下面链接进入测试报告页面" +
"\n" + "(旧版)接口测试路径" + url + "\n" + "(新版)接口测试路径" + url2;
<p>您所执行的 ${testName} 接口测试运行失败<br/>
请点击下面链接进入测试报告页面【接口定义暂无报告路径】<br/>

View File

@ -16,7 +16,7 @@
:before-upload="beforeUploadFile"
:http-request="handleUpload"
:on-exceed="handleExceed"
:file-list="fileList">
>
<ms-table-button :is-tester-permission="true" icon="el-icon-upload2"
:content="$t('load_test.upload_file')"/>
</el-upload>
@ -46,6 +46,23 @@
</el-table-column>
<el-table-column :label="$t('commons.operating')">
<template v-slot:default="scope">
<el-upload
style="width: 38px; float: left;"
accept=".jmx,.jar,.csv,.json,.pdf,.jpg,.png,.jpeg,.doc,.docx,.xlsx"
action=""
:limit="fileNumLimit"
:show-file-list="false"
:before-upload="beforeUploadFile"
:http-request="handleUpdateUpload"
:on-exceed="handleExceed"
>
<el-button circle
type="success"
:disabled="!checkoutTestManagerOrTestUser()"
icon="el-icon-edit"
@click="handleEdit(scope.row)"
size="mini"/>
</el-upload>
<ms-table-operator-button :is-tester-permission="true"
icon="el-icon-delete"
type="danger"
@ -65,7 +82,7 @@
import MsTablePagination from "@/business/components/common/pagination/TablePagination";
import MsTableButton from "@/business/components/common/components/MsTableButton";
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
import {getCurrentProjectID} from "@/common/js/utils";
import {checkoutTestManagerOrTestUser, getCurrentProjectID} from "@/common/js/utils";
import MsTableOperatorButton from "@/business/components/common/components/MsTableOperatorButton";
import {Message} from "element-ui";
import MsTableHeader from "@/business/components/common/components/MsTableHeader";
@ -87,9 +104,11 @@ export default {
fileNumLimit: 10,
condition: {},
projectId: getCurrentProjectID(),
currentRow: null,
}
},
methods: {
checkoutTestManagerOrTestUser,
open(project) {
this.projectId = project.id;
this.loadFileVisible = true;
@ -136,9 +155,40 @@ export default {
this.getProjectFiles();
});
},
handleUpdateUpload(uploadResources) {
let file = uploadResources.file;
let i1 = file.name.lastIndexOf(".");
let i2 = this.currentRow.name.lastIndexOf(".");
let suffix1 = file.name.substring(i1);
let suffix2 = this.currentRow.name.substring(i2);
if (suffix1 !== suffix2) {
this.$error(this.$t('load_test.project_file_update_type_error'));
return;
}
let formData = new FormData();
let url = '/project/update/file/' + this.projectId + '/' + this.currentRow.id
formData.append("file", file);
let options = {
method: 'POST',
url: url,
data: formData,
headers: {
'Content-Type': undefined
}
}
this.$request(options, (response) => {
this.$success(this.$t('commons.save_success'));
this.currentRow = null;
this.getProjectFiles();
});
},
handleExceed() {
this.$error(this.$t('load_test.file_size_limit'));
},
handleEdit(row) {
this.currentRow = row;
},
handleDelete(row) {
console.log(row);
this.$confirm(this.$t('project.file_delete_tip', [row.name]), '', {

View File

@ -540,7 +540,8 @@ export default {
load_exist_jmx: 'Load Project JMX',
threadgroup_at_least_one: 'At least one ThreadGroup is enabled',
load_api_automation_jmx: 'Import API automation scenario',
project_file_exist: "The file already exists in the project, please import it directly"
project_file_exist: "The file already exists in the project, please import it directly",
project_file_update_type_error: 'Updated file types must be consistent'
},
api_test: {
creator: "Creator",

View File

@ -539,7 +539,8 @@ export default {
load_exist_jmx: '加载 JMX 文件',
threadgroup_at_least_one: '至少启用一个线程组',
load_api_automation_jmx: '引用接口自动化场景',
project_file_exist: "项目中已存在该文件,请直接引用"
project_file_exist: "项目中已存在该文件,请直接引用",
project_file_update_type_error: '更新的文件类型必须一致'
},
api_test: {
creator: "创建人",

View File

@ -539,7 +539,8 @@ export default {
load_exist_jmx: '加載 JMX 文件',
threadgroup_at_least_one: '至少啟用一個線程組',
load_api_automation_jmx: '引用接口自動化場景',
project_file_exist: "項目中已存在該文件,請直接引用"
project_file_exist: "項目中已存在該文件,請直接引用",
project_file_update_type_error: '更新的文件類型必須一致'
},
api_test: {
creator: "創建人",