diff --git a/backend/src/main/java/io/metersphere/api/controller/APITestController.java b/backend/src/main/java/io/metersphere/api/controller/APITestController.java index d2c5505922..506362d0ec 100644 --- a/backend/src/main/java/io/metersphere/api/controller/APITestController.java +++ b/backend/src/main/java/io/metersphere/api/controller/APITestController.java @@ -45,9 +45,10 @@ public class APITestController { return PageUtils.setPageInfo(page, apiTestService.list(request)); } - @GetMapping("/list/{projectId}") - public List<ApiTest> list(@PathVariable String projectId) { - return apiTestService.getApiTestByProjectId(projectId); + /*查询某个api测试状态*/ + @GetMapping("/list/all/{testId}") + public ApiTest list(@PathVariable String testId) { + return apiTestService.getApiTestByProjectId(testId); } @PostMapping(value = "/schedule/update") @@ -89,4 +90,5 @@ public class APITestController { public String run(@RequestBody SaveAPITestRequest request) { return apiTestService.run(request); } + } diff --git a/backend/src/main/java/io/metersphere/api/service/APITestService.java b/backend/src/main/java/io/metersphere/api/service/APITestService.java index 91227bb4b0..69e96738f6 100644 --- a/backend/src/main/java/io/metersphere/api/service/APITestService.java +++ b/backend/src/main/java/io/metersphere/api/service/APITestService.java @@ -126,8 +126,8 @@ public class APITestService { return apiTest; } - public List<ApiTest> getApiTestByProjectId(String projectId) { - return extApiTestMapper.getApiTestByProjectId(projectId); + public ApiTest getApiTestByProjectId(String testId) { + return apiTestMapper.selectByPrimaryKey(testId); } public void delete(String testId) { diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestMapper.xml index bcb23d82fd..4458cdd58d 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestMapper.xml @@ -45,7 +45,7 @@ </if> </select> <select id="getApiTestByProjectId" resultType="io.metersphere.base.domain.ApiTest"> - select id,name + select id,name,status from api_test where project_id = #{projectId} </select> diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java index a08cca5f97..7a1aa58b2b 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java @@ -12,4 +12,7 @@ public interface ExtTestCaseMapper { List<TestCase> getTestCaseNames(@Param("request") QueryTestCaseRequest request); List<TestCaseDTO> list(@Param("request") QueryTestCaseRequest request); + + List<TestCaseDTO> listByMethod(@Param("request") QueryTestCaseRequest request); + } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml index 32aa2cb719..fb38255072 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml @@ -53,4 +53,23 @@ </foreach> </if> </select> + <select id="listByMethod" resultType="io.metersphere.track.dto.TestCaseDTO"> + select test_case.* from test_case + <where> + <if test="request.method != null"> + and test_case.method =#{request.method} + </if> + <if test="request.nodeIds != null and request.nodeIds.size() > 0"> + and test_case.node_id in + <foreach collection="request.nodeIds" item="nodeId" separator="," open="(" close=")"> + #{nodeId} + </foreach> + </if> + <if test="request.projectId != null"> + and test_case.project_id = #{request.projectId} + </if> + + </where> + + </select> </mapper> \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.java index b4cb348f91..3ecbb207c4 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.java @@ -16,6 +16,8 @@ public interface ExtTestPlanTestCaseMapper { List<TestPlanCaseDTO> list(@Param("request") QueryTestPlanCaseRequest request); + List<TestPlanCaseDTO> listByNode(@Param("request") QueryTestPlanCaseRequest request); + List<String> findRelateTestPlanId(@Param("userId") String userId, @Param("workspaceId") String workspaceId); List<TestPlanCaseDTO> getRecentTestedTestCase(@Param("request") QueryTestPlanCaseRequest request); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml index cabc50ee96..32c8bfa95b 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml @@ -63,6 +63,42 @@ </foreach> </if> </select> + <select id="listByNode" resultType="io.metersphere.track.dto.TestPlanCaseDTO"> + select test_plan_test_case.*, test_case.* + from test_plan_test_case + inner join test_case on test_plan_test_case.case_id = test_case.id + <where> + <if test="request.name != null"> + and test_case.name like CONCAT('%', #{request.name},'%') + </if> + <if test="request.id != null"> + and test_case.id = #{request.id} + </if> + <if test="request.node != null"> + and test_case.node_id =#{request.node} + </if> + <if test="request.status != null"> + and test_plan_test_case.status = #{request.status} + </if> + <if test="request.executor != null"> + and test_plan_test_case.executor = #{request.executor} + </if> + <if test="request.planId != null"> + and test_plan_test_case.plan_id = #{request.planId} + </if> + <if test="request.filters != null and request.filters.size() > 0"> + <foreach collection="request.filters.entrySet()" index="key" item="values"> + <if test="values != null and values.size() > 0"> + and ${key} in + <foreach collection="values" item="value" separator="," open="(" close=")"> + #{value} + </foreach> + </if> + </foreach> + </if> + </where> + + </select> <select id="findRelateTestPlanId" resultType="java.lang.String"> select distinct plan_id from test_plan_test_case diff --git a/backend/src/main/java/io/metersphere/controller/ProjectController.java b/backend/src/main/java/io/metersphere/controller/ProjectController.java index 578556b786..d2d302ea71 100644 --- a/backend/src/main/java/io/metersphere/controller/ProjectController.java +++ b/backend/src/main/java/io/metersphere/controller/ProjectController.java @@ -31,6 +31,14 @@ public class ProjectController { return projectService.getProjectList(request); } + /*jenkins项目列表*/ + @GetMapping("/listAll/{workspaceId}") + public List<ProjectDTO> jlistAll(@PathVariable String workspaceId) { + ProjectRequest request = new ProjectRequest(); + request.setWorkspaceId(workspaceId); + return projectService.getProjectList(request); + } + @GetMapping("/recent/{count}") @RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR) public List<Project> recentProjects(@PathVariable int count) { diff --git a/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java b/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java index 78e77a9e6e..b4c3c0ace7 100644 --- a/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java +++ b/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java @@ -54,6 +54,12 @@ public class PerformanceTestController { return performanceTestService.getLoadTestByProjectId(projectId); } + /*查询某个测试状态*/ + @GetMapping("/list/all/{testId}") + public LoadTest listByTestId(@PathVariable String testId) { + return performanceTestService.getLoadTestBytestId(testId); + } + @PostMapping(value = "/save", consumes = {"multipart/form-data"}) public String save( @RequestPart("request") SaveTestPlanRequest request, diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java index e89f46dfa5..75517fb612 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java @@ -339,6 +339,10 @@ public class PerformanceTestService { return extLoadTestMapper.getLoadTestByProjectId(projectId); } + public LoadTest getLoadTestBytestId(String testId) { + return loadTestMapper.selectByPrimaryKey(testId); + } + public void copy(SaveTestPlanRequest request) { // copy test LoadTestWithBLOBs copy = loadTestMapper.selectByPrimaryKey(request.getId()); diff --git a/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java b/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java index 2a27594936..5debcbb7cc 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java @@ -36,6 +36,23 @@ public class TestCaseController { return PageUtils.setPageInfo(page, testCaseService.listTestCase(request)); } + @GetMapping("/list/{projectId}") + public List<TestCaseDTO> list(@PathVariable String projectId) { + QueryTestCaseRequest request = new QueryTestCaseRequest(); + request.setProjectId(projectId); + return testCaseService.listTestCase(request); + } + + /*项目下自动测试用例*/ + @GetMapping("/list/method/{projectId}") + public List<TestCaseDTO> listByMethod(@PathVariable String projectId) { + QueryTestCaseRequest request = new QueryTestCaseRequest(); + request.setProjectId(projectId); + request.setMethod("auto"); + return testCaseService.listTestCaseMthod(request); + } + + @GetMapping("recent/{count}") public List<TestCase> recentTestPlans(@PathVariable int count) { String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId(); diff --git a/backend/src/main/java/io/metersphere/track/controller/TestCaseNodeController.java b/backend/src/main/java/io/metersphere/track/controller/TestCaseNodeController.java index 8c43da0220..317d121899 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestCaseNodeController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestCaseNodeController.java @@ -23,7 +23,7 @@ public class TestCaseNodeController { public List<TestCaseNodeDTO> getNodeByProjectId(@PathVariable String projectId){ return testCaseNodeService.getNodeTreeByProjectId(projectId); } - + /*模块列表列表*/ @GetMapping("/list/all/plan/{planId}") public List<TestCaseNodeDTO> getAllNodeByPlanId(@PathVariable String planId){ return testCaseNodeService.getAllNodeByPlanId(planId); diff --git a/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java b/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java index e4dbba3a23..7aed6f4aa6 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java @@ -35,6 +35,15 @@ public class TestPlanController { return PageUtils.setPageInfo(page, testPlanService.listTestPlan(request)); } + /*jenkins测试计划*/ + @GetMapping("/list/all/{projectId}/{workspaceId}") + public List<TestPlanDTO> listByprojectId(@PathVariable String projectId, @PathVariable String workspaceId) { + QueryTestPlanRequest request = new QueryTestPlanRequest(); + request.setWorkspaceId(workspaceId); + request.setProjectId(projectId); + return testPlanService.listTestPlan(request); + } + @PostMapping("/list/all") public List<TestPlan> listAll() { String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId(); diff --git a/backend/src/main/java/io/metersphere/track/controller/TestPlanTestCaseController.java b/backend/src/main/java/io/metersphere/track/controller/TestPlanTestCaseController.java index ad010a9029..87e6ab0e79 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestPlanTestCaseController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestPlanTestCaseController.java @@ -26,18 +26,26 @@ public class TestPlanTestCaseController { TestPlanTestCaseService testPlanTestCaseService; @PostMapping("/list/{goPage}/{pageSize}") - public Pager<List<TestPlanCaseDTO>> getTestPlanCases(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanCaseRequest request){ + public Pager<List<TestPlanCaseDTO>> getTestPlanCases(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanCaseRequest request) { Page<Object> page = PageHelper.startPage(goPage, pageSize, true); return PageUtils.setPageInfo(page, testPlanTestCaseService.list(request)); } + @GetMapping("/list/{planId}/{nodeId}") + public List<TestPlanCaseDTO> getTestPlanCases(@PathVariable String planId, @PathVariable String nodeId) { + QueryTestPlanCaseRequest request = new QueryTestPlanCaseRequest(); + request.setPlanId(planId); + request.setNode(nodeId); + return testPlanTestCaseService.listByNode(request); + } + @GetMapping("/get/{caseId}") - public TestPlanCaseDTO getTestPlanCases(@PathVariable String caseId){ + public TestPlanCaseDTO getTestPlanCases(@PathVariable String caseId) { return testPlanTestCaseService.get(caseId); } @PostMapping("recent/{count}") - public List<TestPlanCaseDTO> getRecentTestCases(@PathVariable int count, @RequestBody QueryTestPlanCaseRequest request){ + public List<TestPlanCaseDTO> getRecentTestCases(@PathVariable int count, @RequestBody QueryTestPlanCaseRequest request) { return testPlanTestCaseService.getRecentTestCases(request, count); } diff --git a/backend/src/main/java/io/metersphere/track/request/testplancase/QueryTestPlanCaseRequest.java b/backend/src/main/java/io/metersphere/track/request/testplancase/QueryTestPlanCaseRequest.java index c4af29338c..0cb0923c09 100644 --- a/backend/src/main/java/io/metersphere/track/request/testplancase/QueryTestPlanCaseRequest.java +++ b/backend/src/main/java/io/metersphere/track/request/testplancase/QueryTestPlanCaseRequest.java @@ -27,4 +27,6 @@ public class QueryTestPlanCaseRequest extends TestPlanTestCase { private String name; private String status; + + private String node; } diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java index b66be54637..b2578aeb90 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -125,14 +125,20 @@ public class TestCaseService { return extTestCaseMapper.list(request); } + public List<TestCaseDTO> listTestCaseMthod(QueryTestCaseRequest request) { + return extTestCaseMapper.listByMethod(request); + } + + /** * 获取测试用例 * 过滤已关联 + * * @param request * @return */ public List<TestCase> getTestCaseNames(QueryTestCaseRequest request) { - if ( StringUtils.isNotBlank(request.getPlanId()) ) { + if (StringUtils.isNotBlank(request.getPlanId())) { TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getPlanId()); request.setProjectId(testPlan.getProjectId()); } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java index cf9dc7a496..5cc4e02222 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java @@ -55,6 +55,11 @@ public class TestPlanTestCaseService { return list; } + public List<TestPlanCaseDTO> listByNode(QueryTestPlanCaseRequest request) { + List<TestPlanCaseDTO> list = extTestPlanTestCaseMapper.listByNode(request); + return list; + } + public void editTestCase(TestPlanTestCaseWithBLOBs testPlanTestCase) { if (StringUtils.equals(TestPlanTestCaseStatus.Prepare.name(), testPlanTestCase.getStatus())) { testPlanTestCase.setStatus(TestPlanTestCaseStatus.Underway.name());