refactor: 修改方法名;调整条件筛选sql

This commit is contained in:
wenyann 2020-07-24 18:20:15 +08:00
parent 9bd0b71662
commit dd39904c5d
6 changed files with 56 additions and 18 deletions

View File

@ -16,7 +16,7 @@ public interface ExtTestCaseMapper {
List<TestCaseDTO> listByMethod(@Param("request") QueryTestCaseRequest request);
List<TestCaseDTO> listBytestCaseIds(@Param("request") TestCaseBatchRequest request);
List<TestCaseDTO> listByTestCaseIds(@Param("request") TestCaseBatchRequest request);
TestCase getMaxNumByProjectId(@Param("projectId") String projectId);

View File

@ -128,10 +128,20 @@
<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 test_case.${key} in
<choose>
<when test="key=='priority'">
and test_case.priority in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<otherwise>
and test_case.type in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</otherwise>
</choose>
</if>
</foreach>
</if>
@ -214,7 +224,7 @@
</if>
</where>
</select>
<select id="listBytestCaseIds" resultType="io.metersphere.track.dto.TestCaseDTO">
<select id="listByTestCaseIds" resultType="io.metersphere.track.dto.TestCaseDTO">
select test_case.*,api_test.name as apiName,load_test.name AS performName from test_case left join api_test on
test_case.test_id=api_test.id left join load_test on test_case.test_id=load_test.id
<where>

View File

@ -95,7 +95,8 @@
</if>
</sql>
<select id="list" resultMap="BaseResultMap" parameterType="io.metersphere.track.request.testcase.QueryTestPlanRequest">
<select id="list" resultMap="BaseResultMap"
parameterType="io.metersphere.track.request.testcase.QueryTestPlanRequest">
select test_plan.*, project.name as project_name
from test_plan
left join project on test_plan.project_id = project.id
@ -126,10 +127,21 @@
<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
<choose>
<when test="key=='stage'">
and test_plan.stage in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<otherwise>
and test_plan.status in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</otherwise>
</choose>
</if>
</foreach>
</if>

View File

@ -157,10 +157,26 @@
<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
<choose>
<when test="key=='priority'">
and test_case.priority in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<when test="key=='type'">
and test_case.type in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<otherwise>
and test_case.method in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</otherwise>
</choose>
</if>
</foreach>
</if>

View File

@ -44,7 +44,7 @@ public class TestCaseController {
return testCaseService.listTestCase(request);
}
/*项目下自动测试*/
@GetMapping("/list/method/{projectId}")
public List<TestCaseDTO> listByMethod(@PathVariable String projectId) {
QueryTestCaseRequest request = new QueryTestCaseRequest();

View File

@ -353,7 +353,7 @@ public class TestCaseService {
}
private List<TestCaseExcelData> generateTestCaseExcel(TestCaseBatchRequest request) {
List<TestCaseDTO> TestCaseList = extTestCaseMapper.listBytestCaseIds(request);
List<TestCaseDTO> TestCaseList = extTestCaseMapper.listByTestCaseIds(request);
List<TestCaseExcelData> list = new ArrayList<>();
SessionUser user = SessionUtils.getUser();
StringBuilder step = new StringBuilder("");