|
@@ -0,0 +1,117 @@
|
|
|
|
|
+package seecoder.devcloud.web.controller.project;
|
|
|
|
|
+
|
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+import seecoder.devcloud.web.model.vo.Response;
|
|
|
|
|
+import seecoder.devcloud.web.model.vo.project.TestCaseVO;
|
|
|
|
|
+import seecoder.devcloud.web.model.vo.project.TestStepVO;
|
|
|
|
|
+import seecoder.devcloud.web.service.project.TestCaseService;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * @author PuHong Weng
|
|
|
|
|
+ * @date 2021/4/10
|
|
|
|
|
+ * @description:
|
|
|
|
|
+ */
|
|
|
|
|
+@Api(tags = "测试用例相关 API")
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/test_cases")
|
|
|
|
|
+public class TestCaseController {
|
|
|
|
|
+
|
|
|
|
|
+ private final TestCaseService testCaseService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ public TestCaseController(TestCaseService testCaseService) {
|
|
|
|
|
+ this.testCaseService = testCaseService;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "获取项目的测试用例列表", httpMethod = "GET")
|
|
|
|
|
+ @ApiImplicitParam(name = "projectId",dataType ="int", paramType = "query")
|
|
|
|
|
+ @GetMapping
|
|
|
|
|
+ public Response<List<TestCaseVO>> getTestCases(@RequestParam("projectId") Integer projectId){
|
|
|
|
|
+ return Response.buildSuccess(testCaseService.getTestCases(projectId));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/steps")
|
|
|
|
|
+ @ApiOperation(value = "获取测试用例的步骤列表", httpMethod = "GET")
|
|
|
|
|
+ @ApiImplicitParam(name = "testCaseId",dataType ="int", paramType = "query")
|
|
|
|
|
+ public Response<List<TestStepVO>> getTestSteps(@RequestParam("testCaseId")Integer testCaseId){
|
|
|
|
|
+ return Response.buildSuccess(testCaseService.getTestSteps(testCaseId));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "创建一个测试用例", httpMethod = "POST")
|
|
|
|
|
+ @PostMapping
|
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
|
+ @ApiImplicitParam(name = "projectId",dataType ="int", paramType = "query"),
|
|
|
|
|
+ @ApiImplicitParam(name = "title",dataType ="string", paramType = "query")
|
|
|
|
|
+ })
|
|
|
|
|
+ public Response createTestCase(@RequestParam("projectId") Integer projectId,@RequestParam("title") String title){
|
|
|
|
|
+ testCaseService.createTestCase(projectId, title);
|
|
|
|
|
+ return Response.buildSuccess();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "更新测试用例标题", httpMethod = "PUT")
|
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
|
+ @ApiImplicitParam(name = "testCaseId",dataType ="int", paramType = "query"),
|
|
|
|
|
+ @ApiImplicitParam(name = "title",dataType ="string", paramType = "query")
|
|
|
|
|
+ })
|
|
|
|
|
+ @PutMapping
|
|
|
|
|
+ public Response updateTestCaseTitle(@RequestParam("testCaseId") Integer testCaseId,@RequestParam("title") String title){
|
|
|
|
|
+ testCaseService.updateTestCaseTitle(testCaseId, title);
|
|
|
|
|
+ return Response.buildSuccess();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "更新测试用例测试状态", httpMethod = "PUT")
|
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
|
+ @ApiImplicitParam(name = "testCaseId",dataType ="int", paramType = "query"),
|
|
|
|
|
+ @ApiImplicitParam(name = "pass",dataType ="boolean", paramType = "query")
|
|
|
|
|
+ })
|
|
|
|
|
+ @PutMapping("/pass")
|
|
|
|
|
+ public Response updateTestCaseState(@RequestParam("testCaseId") Integer testCaseId,@RequestParam("pass") Boolean pass){
|
|
|
|
|
+ testCaseService.updateTestCaseState(testCaseId, pass);
|
|
|
|
|
+ return Response.buildSuccess();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "删除测试用例", httpMethod = "DELETE")
|
|
|
|
|
+ @ApiImplicitParam(name = "testCaseId",dataType ="int", paramType = "query")
|
|
|
|
|
+ @DeleteMapping
|
|
|
|
|
+ public Response deleteTestCase(@RequestParam("testCaseId") Integer testCaseId){
|
|
|
|
|
+ testCaseService.deleteTestCase(testCaseId);
|
|
|
|
|
+ return Response.buildSuccess();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "创建空的测试用例步骤", httpMethod = "POST")
|
|
|
|
|
+ @ApiImplicitParam(name = "testCaseId",dataType ="int", paramType = "query")
|
|
|
|
|
+ @PostMapping("/steps")
|
|
|
|
|
+ public Response createEmptyTestStep(@RequestParam("testCaseId") Integer testCaseId){
|
|
|
|
|
+ testCaseService.createEmptyTestStep(testCaseId);
|
|
|
|
|
+ return Response.buildSuccess();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "更新测试用例步骤内容", httpMethod = "PUT")
|
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
|
+ @ApiImplicitParam(name = "testStepId",dataType ="int", paramType = "query"),
|
|
|
|
|
+ @ApiImplicitParam(name = "description",dataType ="string", paramType = "query")
|
|
|
|
|
+ })
|
|
|
|
|
+ @PutMapping("/steps")
|
|
|
|
|
+ public Response updateTestStepDescription(@RequestParam("testStepId") Integer testStepId, @RequestParam("description") String description){
|
|
|
|
|
+ testCaseService.updateTestStepDescription(testStepId, description);
|
|
|
|
|
+ return Response.buildSuccess();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "删除测试用例步骤", httpMethod = "DELETE")
|
|
|
|
|
+ @ApiImplicitParam(name = "testStepId",dataType ="int", paramType = "query")
|
|
|
|
|
+ @DeleteMapping("/steps")
|
|
|
|
|
+ public Response deleteTestStep(@RequestParam("testStepId") Integer testStepId){
|
|
|
|
|
+ testCaseService.deleteTestStep(testStepId);
|
|
|
|
|
+ return Response.buildSuccess();
|
|
|
|
|
+ }
|
|
|
|
|
+}
|