Merge branch 'refector'

This commit is contained in:
shiziyuan9527 2020-11-30 14:59:37 +08:00
commit 834baeac31
5 changed files with 66 additions and 21 deletions

View File

@ -39,4 +39,18 @@ public interface ExtTestPlanTestCaseMapper {
List<TestPlanCaseDTO> listTestCaseByProjectIds(@Param("ids") List<String> ids); List<TestPlanCaseDTO> listTestCaseByProjectIds(@Param("ids") List<String> ids);
TestPlanCaseDTO get(String testPlanTestCaseId); TestPlanCaseDTO get(String testPlanTestCaseId);
/**
* 获取完整的测试计划下用例的详细信息
* @param request id(test_plan_test_case.id) 不能为空
* @return TestPlanCaseDTO
*/
TestPlanCaseDTO getTestPlanTestCase(@Param("request") QueryTestPlanCaseRequest request);
/**
* 获取测试计划下的 TestPlanTestCaseID TestCaseName
* @param request planId 不能为空
* @return List<TestPlanCaseDTO>
*/
List<TestPlanCaseDTO> getTestPlanTestCaseList(@Param("request") QueryTestPlanCaseRequest request);
} }

View File

@ -121,7 +121,9 @@
</select> </select>
<select id="list" resultType="io.metersphere.track.dto.TestPlanCaseDTO"> <select id="list" resultType="io.metersphere.track.dto.TestPlanCaseDTO">
select test_case.remark, test_plan_test_case.id as id, test_plan_test_case.*,test_case.*,test_case_node.name as model, project.name as projectName select test_plan_test_case.id as id, test_case.id as caseId, test_case.name, test_case.priority, test_case.type,
test_case.node_path, test_case.method, test_case.num, test_plan_test_case.executor, test_plan_test_case.status,
test_plan_test_case.update_time, test_case_node.name as model, project.name as projectName, test_plan_test_case.plan_id as planId
from test_plan_test_case from test_plan_test_case
inner join test_case on test_plan_test_case.case_id = test_case.id inner join test_case on test_plan_test_case.case_id = test_case.id
left join test_case_node on test_case_node.id=test_case.node_id left join test_case_node on test_case_node.id=test_case.node_id
@ -134,7 +136,8 @@
</include> </include>
</if> </if>
<if test="request.name != null"> <if test="request.name != null">
and (test_case.name like CONCAT('%', #{request.name},'%') or test_case.num like CONCAT('%', #{request.name},'%')) and (test_case.name like CONCAT('%', #{request.name},'%') or test_case.num like
CONCAT('%',#{request.name},'%'))
</if> </if>
<if test="request.id != null"> <if test="request.id != null">
and test_case.id = #{request.id} and test_case.id = #{request.id}
@ -210,6 +213,23 @@
</foreach> </foreach>
</if> </if>
</select> </select>
<select id="getTestPlanTestCase" resultType="io.metersphere.track.dto.TestPlanCaseDTO">
select test_case.remark, test_plan_test_case.id as id, test_plan_test_case.*,test_case.*,test_case_node.name as model, project.name as projectName
from test_plan_test_case
inner join test_case on test_plan_test_case.case_id = test_case.id
left join test_case_node on test_case_node.id=test_case.node_id
inner join project on project.id = test_case.project_id
where test_plan_test_case.id = #{request.id}
</select>
<select id="getTestPlanTestCaseList" resultType="io.metersphere.track.dto.TestPlanCaseDTO">
select test_plan_test_case.id as id, test_case.name
from test_plan_test_case
inner join test_case on test_plan_test_case.case_id = test_case.id
where test_plan_test_case.plan_id = #{request.planId}
</select>
<select id="listTestCaseByProjectIds" resultType="io.metersphere.track.dto.TestPlanCaseDTO"> <select id="listTestCaseByProjectIds" resultType="io.metersphere.track.dto.TestPlanCaseDTO">
select distinct * from test_plan_test_case, test_case select distinct * from test_plan_test_case, test_case
where test_plan_test_case.case_id = test_case.id where test_plan_test_case.case_id = test_case.id

View File

@ -83,6 +83,16 @@ public class TestPlanTestCaseController {
return testPlanTestCaseService.list(request); return testPlanTestCaseService.list(request);
} }
@PostMapping("/list/ids")
public List<TestPlanCaseDTO> getTestPlanCaseIds(@RequestBody QueryTestPlanCaseRequest request) {
return testPlanTestCaseService.list(request);
}
@PostMapping("/get")
public TestPlanCaseDTO getTestPlanCase(@RequestBody QueryTestPlanCaseRequest request) {
return testPlanTestCaseService.getTestPlanCase(request);
}
@PostMapping("/edit") @PostMapping("/edit")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void editTestCase(@RequestBody TestPlanTestCaseWithBLOBs testPlanTestCase) { public void editTestCase(@RequestBody TestPlanTestCaseWithBLOBs testPlanTestCase) {

View File

@ -146,4 +146,8 @@ public class TestPlanTestCaseService {
public int updateTestCaseStates(List<String> ids, String reportStatus) { public int updateTestCaseStates(List<String> ids, String reportStatus) {
return extTestPlanTestCaseMapper.updateTestCaseStates(ids, reportStatus); return extTestPlanTestCaseMapper.updateTestCaseStates(ids, reportStatus);
} }
public TestPlanCaseDTO getTestPlanCase(QueryTestPlanCaseRequest request) {
return extTestPlanTestCaseMapper.getTestPlanTestCase(request);
}
} }

View File

@ -473,25 +473,22 @@ export default {
}, },
getTestCase(index) { getTestCase(index) {
let testCase = this.testCases[index]; let testCase = this.testCases[index];
let item = {}; // id TestPlanTestCase id
Object.assign(item, testCase); this.result = this.$post('/test/plan/case/get', {id: testCase.id}, response => {
item.results = JSON.parse(item.results); let item = {};
item.steps = JSON.parse(item.steps); Object.assign(item, response.data);
if (item.issues) { item.results = JSON.parse(item.results);
item.issues = JSON.parse(item.issues); item.steps = JSON.parse(item.steps);
} else { item.steptResults = [];
item.issues = {}; for (let i = 0; i < item.steps.length; i++) {
item.issues.hasIssues = false; if (item.results[i]) {
} item.steps[i].actualResult = item.results[i].actualResult;
item.steptResults = []; item.steps[i].executeResult = item.results[i].executeResult;
for (let i = 0; i < item.steps.length; i++) { }
if (item.results[i]) { item.steptResults.push(item.steps[i]);
item.steps[i].actualResult = item.results[i].actualResult;
item.steps[i].executeResult = item.results[i].executeResult;
} }
item.steptResults.push(item.steps[i]); this.testCase = item;
} })
this.testCase = item;
this.initTest(); this.initTest();
this.getIssues(testCase.caseId); this.getIssues(testCase.caseId);
this.stepResultChange(); this.stepResultChange();
@ -546,7 +543,7 @@ export default {
this.$post('/test/plan/case/edit', {id: this.testCase.id, reportId: reportId}); this.$post('/test/plan/case/edit', {id: this.testCase.id, reportId: reportId});
}, },
initData(testCase) { initData(testCase) {
this.result = this.$post('/test/plan/case/list/all', this.searchParam, response => { this.result = this.$post('/test/plan/case/list/ids', this.searchParam, response => {
this.testCases = response.data; this.testCases = response.data;
for (let i = 0; i < this.testCases.length; i++) { for (let i = 0; i < this.testCases.length; i++) {
if (this.testCases[i].id === testCase.id) { if (this.testCases[i].id === testCase.id) {