| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- package seecoder.devcloud.web.controller.APITest;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiImplicitParam;
- import io.swagger.annotations.ApiOperation;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import seecoder.devcloud.web.model.po.APITest.APITestResult;
- import seecoder.devcloud.web.model.vo.APITest.APITestBodyVO;
- import seecoder.devcloud.web.model.vo.APITest.APITestInfoVO;
- import seecoder.devcloud.web.model.vo.APITest.APITestResultVO;
- import seecoder.devcloud.web.model.vo.Response;
- import seecoder.devcloud.web.service.APITest.APITestService;
- import java.util.List;
- /**
- * @Author zxr
- * @Description 接口测试相关操作
- */
- @Api(tags = "接口测试 API")
- @RestController
- @RequestMapping("/test")
- public class APITestController {
- private final APITestService apiTestService;
- @Autowired
- public APITestController(APITestService apiTestService) {
- this.apiTestService = apiTestService;
- }
- @PostMapping("/create")
- @ApiOperation(value = "创建一个新的测试任务", httpMethod = "POST")
- public Response createAPITestMission(@RequestBody APITestBodyVO apiTestBodyVO) {
- apiTestService.createAPITest(apiTestBodyVO);
- return Response.buildSuccess();
- }
- @GetMapping("/list/{projectId}")
- @ApiOperation(value = "获取指定项目的所有测试任务", httpMethod = "GET")
- @ApiImplicitParam(name = "projectId", dataType ="int",paramType = "query")
- public Response<List<APITestInfoVO>> getAPITestInfosByProjectId(@PathVariable("projectId") Integer projectId) {
- return Response.buildSuccess(apiTestService.getAPITestsByProjectId(projectId));
- }
- @GetMapping("/delete/{testId}")
- @ApiOperation(value = "删除指定测试任务", httpMethod = "DELETE")
- @ApiImplicitParam(name = "testId", dataType = "int", paramType = "query")
- public Response deleteAPITestInfoByTestId(@PathVariable("testId") Integer testId) {
- apiTestService.deleteAPITest(testId);
- return Response.buildSuccess();
- }
- @GetMapping("/execute/{testId}")
- @ApiOperation(value = "执行制定测试任务", httpMethod = "GET")
- @ApiImplicitParam(name = "testID", dataType = "int", paramType = "query")
- public Response executeAPITestByTestId(@PathVariable("testId") Integer testId) throws InterruptedException {
- apiTestService.executeAPITest(testId);
- return Response.buildSuccess();
- }
- @GetMapping("/result/{testId}")
- @ApiOperation(value = "获取执行测试任务的执行结果列表", httpMethod = "GET")
- @ApiImplicitParam(name = "testId", dataType = "int", paramType = "query")
- public Response<List<APITestResultVO>> getAPITestResultByTestId(@PathVariable("testId") Integer testId) {
- return Response.buildSuccess(apiTestService.getAPITestResultByTestId(testId));
- }
- @GetMapping("/latest/{testId}")
- @ApiOperation(value = "获取测试任务的最近一次执行信息", httpMethod = "GET")
- @ApiImplicitParam(name = "testId", dataType = "int", paramType = "query")
- public Response<APITestResultVO> getLatestTestResultByTestId(@PathVariable("testId") Integer testId) {
- return Response.buildSuccess(apiTestService.getLatestTestResultByTestId(testId));
- }
- }
|