fix(测试跟踪): 修复复制测试用例时附件未复制的问题

This commit is contained in:
shiziyuan9527 2020-10-21 21:36:25 +08:00
parent 0d6d47091d
commit 040b10c2f5
7 changed files with 31 additions and 6 deletions

View File

@ -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"})

View File

@ -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<>();
}

View File

@ -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

View File

@ -174,6 +174,7 @@
let item = {};
Object.assign(item, testCase);
item.name = '';
item.isCopy = true;
this.$refs.testCaseEditDialog.open(item);
},
showTestCaseDetail(testCase) {

View File

@ -505,6 +505,11 @@ export default {
formData.append("file", f);
});
if (param.isCopy) {
// copyID
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