mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-05 05:29:29 +08:00
fix(测试跟踪): 修复复制测试用例时附件未复制的问题
This commit is contained in:
parent
0d6d47091d
commit
040b10c2f5
@ -107,8 +107,8 @@ public class TestCaseController {
|
||||
|
||||
@PostMapping(value = "/add", consumes = {"multipart/form-data"})
|
||||
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
||||
public void addTestCase(@RequestPart("request") TestCaseWithBLOBs testCase, @RequestPart(value = "file") List<MultipartFile> files) {
|
||||
testCaseService.save(testCase, files);
|
||||
public void addTestCase(@RequestPart("request") EditTestCaseRequest request, @RequestPart(value = "file") List<MultipartFile> files) {
|
||||
testCaseService.save(request, files);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/edit", consumes = {"multipart/form-data"})
|
||||
|
@ -5,10 +5,15 @@ import io.metersphere.base.domain.TestCaseWithBLOBs;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class EditTestCaseRequest extends TestCaseWithBLOBs {
|
||||
private List<FileMetadata> updatedFileList;
|
||||
/**
|
||||
* 复制测试用例后,要进行复制的文件Id list
|
||||
*/
|
||||
private List<String> fileIds = new ArrayList<>();
|
||||
}
|
||||
|
@ -583,11 +583,25 @@ public class TestCaseService {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String save(TestCaseWithBLOBs testCase, List<MultipartFile> files) {
|
||||
public String save(EditTestCaseRequest request, List<MultipartFile> files) {
|
||||
if (files == null) {
|
||||
throw new IllegalArgumentException(Translator.get("file_cannot_be_null"));
|
||||
}
|
||||
final TestCaseWithBLOBs testCaseWithBLOBs = addTestCase(testCase);
|
||||
|
||||
final TestCaseWithBLOBs testCaseWithBLOBs = addTestCase(request);
|
||||
|
||||
// 复制用例时传入文件ID进行复制
|
||||
if (!CollectionUtils.isEmpty(request.getFileIds())) {
|
||||
List<String> fileIds = request.getFileIds();
|
||||
fileIds.forEach(id -> {
|
||||
FileMetadata fileMetadata = fileService.copyFile(id);
|
||||
TestCaseFile testCaseFile = new TestCaseFile();
|
||||
testCaseFile.setCaseId(testCaseWithBLOBs.getId());
|
||||
testCaseFile.setFileId(fileMetadata.getId());
|
||||
testCaseFileMapper.insert(testCaseFile);
|
||||
});
|
||||
}
|
||||
|
||||
files.forEach(file -> {
|
||||
final FileMetadata fileMetadata = fileService.saveFile(file);
|
||||
TestCaseFile testCaseFile = new TestCaseFile();
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit cf6b06526324326a563d933e07118fac014a63b4
|
||||
Subproject commit ee74568be0beba46da19616f5832e83f9164c688
|
@ -174,6 +174,7 @@
|
||||
let item = {};
|
||||
Object.assign(item, testCase);
|
||||
item.name = '';
|
||||
item.isCopy = true;
|
||||
this.$refs.testCaseEditDialog.open(item);
|
||||
},
|
||||
showTestCaseDetail(testCase) {
|
||||
|
@ -505,6 +505,11 @@ export default {
|
||||
formData.append("file", f);
|
||||
});
|
||||
|
||||
if (param.isCopy) {
|
||||
// 如果是copy,则把文件的ID传到后台进行文件复制
|
||||
param.fileIds = this.fileList.map(f => f.id);
|
||||
}
|
||||
|
||||
param.updatedFileList = this.fileList;
|
||||
|
||||
let requestJson = JSON.stringify(param, function (key, value) {
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 06d935cd1d22ab36f09763745c2aff8ad3fb08c1
|
||||
Subproject commit cc38137a69a0f20fadece9c0f9f50a9468c4ace9
|
Loading…
Reference in New Issue
Block a user