提交 328fa284 authored 作者: 黄夏豪's avatar 黄夏豪

feat(base): 新增了一个根据projectId查所有Data的接口

上级 9563427f
......@@ -25,4 +25,6 @@ public interface ITestDataService extends IService<TestData> {
* {{@link #toCaseBTO(Long)}} 的重载方法
*/
TestCaseBTO toCaseBTO(TestData testData);
}
......@@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.matrix.database.entity.TestCase;
import org.matrix.database.mapper.TestCaseMapper;
import org.matrix.database.service.ITestCaseService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import java.io.Serializable;
/**
* <p>
* 服务实现类
......
......@@ -28,7 +28,6 @@ import org.matrix.testNg.web.entity.ReportMessage;
import org.matrix.testNg.web.report.TestNgImpl;
import org.matrix.testNg.web.vo.DataBeansJobVo;
import org.matrix.testNg.web.vo.DataBeansMoveVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.CloseStatus;
......
package org.matrix.autotest.controller;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.matrix.database.entity.TestCase;
import org.matrix.database.entity.TestCaseBTO;
import org.matrix.database.entity.TestData;
import org.matrix.database.service.ITestCaseService;
import org.matrix.database.service.ITestDataService;
import org.matrix.database.vo.CommonResult;
import org.matrix.database.vo.CommonResultObj;
import org.matrix.database.vo.TestCaseData;
import org.matrix.exception.GlobalException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import static java.util.Optional.ofNullable;
/**
* TestDataController
* @author huangxiahao
*/
@CrossOrigin
@RestController
@RequestMapping("/testCases")
@Api(tags = "对用例test_data的基本操作")
public class TestDataController {
@Autowired
ITestCaseService testCaseService;
@Autowired
ITestDataService testDataService;
/**
* 根据projectId,查询出对应的TestData
*
* @return {@link TestCaseData}
*/
@GetMapping("/listVo")
@ApiOperation(value = "根据用例id查,用例以及,用例下的数据组")
public ResponseEntity<CommonResultObj<List<TestCaseData>>> listVo(Long projectId) {
List<TestCaseData> result = new ArrayList<>();
List<TestCase> list = testCaseService.list(Wrappers.lambdaQuery(TestCase.class).eq(TestCase::getProjectId, projectId));
for (TestCase testCase : list) {
List<TestData> testDataList = ofNullable(testDataService.list(Wrappers.lambdaQuery(TestData.class)
.eq(TestData::getTestCaseId, testCase.getId())))
.orElse(new ArrayList<>());
result.add(new TestCaseData(testCase,testDataList));
}
return CommonResult.success(result, "查询成功");
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论