From be712b42f7810552509ad0e571cac8b44996731a Mon Sep 17 00:00:00 2001 From: haifeng414 Date: Wed, 12 Feb 2020 14:21:23 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=B9=B6=E8=BE=93=E5=87=BA=E5=88=B0=E6=8E=A7=E5=88=B6=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TestPlanController.java | 22 +++++++++++++++++++ .../io/metersphere/service/FileService.java | 18 +++++++++++++++ .../components/testPlan/CreateTestPlan.vue | 11 ++++++++-- .../testPlan/components/BasicConfig.vue | 18 ++++++++++----- 4 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 backend/src/main/java/io/metersphere/controller/TestPlanController.java create mode 100644 backend/src/main/java/io/metersphere/service/FileService.java diff --git a/backend/src/main/java/io/metersphere/controller/TestPlanController.java b/backend/src/main/java/io/metersphere/controller/TestPlanController.java new file mode 100644 index 0000000000..48d4f27dca --- /dev/null +++ b/backend/src/main/java/io/metersphere/controller/TestPlanController.java @@ -0,0 +1,22 @@ +package io.metersphere.controller; + +import io.metersphere.service.FileService; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import java.io.IOException; + +@RestController +@RequestMapping(value = "/testplan") +public class TestPlanController { + @Resource + private FileService fileService; + + @PostMapping("/file/upload") + public void upload(MultipartFile file) throws IOException { + fileService.upload(file.getOriginalFilename(), file); + } +} diff --git a/backend/src/main/java/io/metersphere/service/FileService.java b/backend/src/main/java/io/metersphere/service/FileService.java new file mode 100644 index 0000000000..f6b7090a73 --- /dev/null +++ b/backend/src/main/java/io/metersphere/service/FileService.java @@ -0,0 +1,18 @@ +package io.metersphere.service; + +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.stream.Collectors; + +@Service +public class FileService { + public void upload(String name, MultipartFile file) throws IOException { + String result = new BufferedReader(new InputStreamReader(file.getInputStream())) + .lines().collect(Collectors.joining("\n")); + System.out.println(String.format("upload file: %s, content: \n%s", name, result)); + } +} \ No newline at end of file diff --git a/frontend/src/performance/components/testPlan/CreateTestPlan.vue b/frontend/src/performance/components/testPlan/CreateTestPlan.vue index 6b78f60479..3be9afc501 100644 --- a/frontend/src/performance/components/testPlan/CreateTestPlan.vue +++ b/frontend/src/performance/components/testPlan/CreateTestPlan.vue @@ -1,6 +1,6 @@