diff --git a/backend/src/main/java/io/metersphere/controller/TestPlanController.java b/backend/src/main/java/io/metersphere/controller/TestPlanController.java index 98efe3242d..a95cea2036 100644 --- a/backend/src/main/java/io/metersphere/controller/TestPlanController.java +++ b/backend/src/main/java/io/metersphere/controller/TestPlanController.java @@ -1,32 +1,71 @@ package io.metersphere.controller; +import com.github.pagehelper.Page; +import io.metersphere.commons.utils.PageUtils; +import io.metersphere.commons.utils.Pager; +import io.metersphere.controller.request.testplan.DeleteTestPlanRequest; import io.metersphere.controller.request.testplan.FileOperationRequest; +import io.metersphere.controller.request.testplan.QueryTestPlanRequest; import io.metersphere.controller.request.testplan.SaveTestPlanRequest; +import io.metersphere.dto.LoadTestDTO; import io.metersphere.service.FileService; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; @RestController @RequestMapping(value = "/testplan") public class TestPlanController { + private static List loadTests = new ArrayList<>(); + + static { + // 模拟数据 + for (int i = 0; i < 100; i++) { + final LoadTestDTO loadTest = new LoadTestDTO(); + loadTest.setId(String.valueOf(i)); + loadTest.setName("load test " + i); + loadTest.setDescription("no description"); + loadTest.setScenarioDefinition("no scenario description"); + loadTest.setCreateTime(System.currentTimeMillis()); + loadTest.setUpdateTime(System.currentTimeMillis()); + loadTest.setProjectId(String.valueOf(i)); + loadTest.setProjectName("project " + i); + loadTests.add(loadTest); + } + } + @Resource private FileService fileService; + @PostMapping("/list/{goPage}/{pageSize}") + public Pager> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanRequest request) { + final Page page = new Page((int) Math.ceil(loadTests.size() * 1.0 / pageSize), pageSize); + page.setTotal(loadTests.size()); + return PageUtils.setPageInfo( + page, + loadTests.stream().skip((goPage - 1) * pageSize).limit(pageSize).collect(Collectors.toList()) + ); + } + @PostMapping("/save") public void save(@RequestBody SaveTestPlanRequest request) { System.out.println(String.format("save test plan: %s", request.getName())); } + @PostMapping("/delete") + public void delete(@RequestBody DeleteTestPlanRequest request) { + System.out.println(String.format("delete test plan: %s", request.getName())); + } + @PostMapping("/file/upload") public void uploadJmx(MultipartFile file) throws IOException { fileService.upload(file.getOriginalFilename(), file); diff --git a/backend/src/main/java/io/metersphere/controller/request/testplan/DeleteTestPlanRequest.java b/backend/src/main/java/io/metersphere/controller/request/testplan/DeleteTestPlanRequest.java new file mode 100644 index 0000000000..91860f1966 --- /dev/null +++ b/backend/src/main/java/io/metersphere/controller/request/testplan/DeleteTestPlanRequest.java @@ -0,0 +1,4 @@ +package io.metersphere.controller.request.testplan; + +public class DeleteTestPlanRequest extends TestPlanRequest { +} diff --git a/backend/src/main/java/io/metersphere/controller/request/testplan/QueryTestPlanRequest.java b/backend/src/main/java/io/metersphere/controller/request/testplan/QueryTestPlanRequest.java new file mode 100644 index 0000000000..0adcdca228 --- /dev/null +++ b/backend/src/main/java/io/metersphere/controller/request/testplan/QueryTestPlanRequest.java @@ -0,0 +1,4 @@ +package io.metersphere.controller.request.testplan; + +public class QueryTestPlanRequest extends TestPlanRequest { +} diff --git a/backend/src/main/java/io/metersphere/controller/request/testplan/SaveTestPlanRequest.java b/backend/src/main/java/io/metersphere/controller/request/testplan/SaveTestPlanRequest.java index 48b3a3b206..e967729910 100644 --- a/backend/src/main/java/io/metersphere/controller/request/testplan/SaveTestPlanRequest.java +++ b/backend/src/main/java/io/metersphere/controller/request/testplan/SaveTestPlanRequest.java @@ -1,31 +1,4 @@ package io.metersphere.controller.request.testplan; -public class SaveTestPlanRequest { - private String fileId; - private String project; - private String name; - - public String getFileId() { - return fileId; - } - - public void setFileId(String fileId) { - this.fileId = fileId; - } - - public String getProject() { - return project; - } - - public void setProject(String project) { - this.project = project; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } +public class SaveTestPlanRequest extends TestPlanRequest { } diff --git a/backend/src/main/java/io/metersphere/controller/request/testplan/TestPlanRequest.java b/backend/src/main/java/io/metersphere/controller/request/testplan/TestPlanRequest.java new file mode 100644 index 0000000000..299c30c4bf --- /dev/null +++ b/backend/src/main/java/io/metersphere/controller/request/testplan/TestPlanRequest.java @@ -0,0 +1,32 @@ +package io.metersphere.controller.request.testplan; + +public class TestPlanRequest { + private String fileId; + private String project; + private String name; + + public String getFileId() { + return fileId; + } + + public void setFileId(String fileId) { + this.fileId = fileId; + } + + public String getProject() { + return project; + } + + public void setProject(String project) { + this.project = project; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} diff --git a/backend/src/main/java/io/metersphere/dto/LoadTestDTO.java b/backend/src/main/java/io/metersphere/dto/LoadTestDTO.java new file mode 100644 index 0000000000..f6a0ed2c12 --- /dev/null +++ b/backend/src/main/java/io/metersphere/dto/LoadTestDTO.java @@ -0,0 +1,15 @@ +package io.metersphere.dto; + +import io.metersphere.base.domain.LoadTest; + +public class LoadTestDTO extends LoadTest { + private String projectName; + + public String getProjectName() { + return projectName; + } + + public void setProjectName(String projectName) { + this.projectName = projectName; + } +} diff --git a/frontend/src/performance/components/HeaderMenus.vue b/frontend/src/performance/components/HeaderMenus.vue index e3bed233da..a4accf8d01 100644 --- a/frontend/src/performance/components/HeaderMenus.vue +++ b/frontend/src/performance/components/HeaderMenus.vue @@ -20,6 +20,11 @@ + + + + 所有测试 + 创建测试 @@ -59,3 +64,9 @@ color: inherit; } + + diff --git a/frontend/src/performance/components/router/router.js b/frontend/src/performance/components/router/router.js index d232709cd8..9ef10cc49f 100644 --- a/frontend/src/performance/components/router/router.js +++ b/frontend/src/performance/components/router/router.js @@ -5,6 +5,7 @@ import Setting from "../settings/Setting"; import Workspace from "../settings/Workspace"; import User from "../settings/User"; import CreateTestPlan from "../testPlan/CreateTestPlan"; +import AllTestPlan from "../testPlan/AllTestPlan"; import Organization from "../settings/Organization"; import WorkspaceUser from "../settings/WorkSpcaeUser"; import TestResourcePool from "../settings/TestResourcePool"; @@ -59,6 +60,11 @@ const router = new VueRouter({ content: CreateTestPlan } }, + { + path: "/allTest", components: { + content: AllTestPlan + } + }, ] }); diff --git a/frontend/src/performance/components/testPlan/AllTestPlan.vue b/frontend/src/performance/components/testPlan/AllTestPlan.vue new file mode 100644 index 0000000000..0faefe89d9 --- /dev/null +++ b/frontend/src/performance/components/testPlan/AllTestPlan.vue @@ -0,0 +1,149 @@ + + + + + diff --git a/frontend/src/performance/components/testPlan/CreateTestPlan.vue b/frontend/src/performance/components/testPlan/CreateTestPlan.vue index 4e35e56120..6a3a587879 100644 --- a/frontend/src/performance/components/testPlan/CreateTestPlan.vue +++ b/frontend/src/performance/components/testPlan/CreateTestPlan.vue @@ -98,7 +98,9 @@ }); }, saveAndRun() { - window.console.log("saveAndRun"); + if (!this.validTestPlan()) { + return; + } /// todo: saveAndRun this.$message({ @@ -106,6 +108,9 @@ type: 'success' }); }, + cancel() { + this.$router.push({path: '/'}) + }, changeTestPlan(updateFunc) { updateFunc(this.testPlan); window.console.log(this.testPlan); @@ -140,9 +145,6 @@ /// todo: 其他校验 return true; - }, - cancel() { - this.$router.push({path: '/'}) } } }