fix(接口测试): 修复场景转测试计划不显示责任人的缺陷

--bug=1018863 --user=王孝刚 【接口测试】接口测试-接口自动化转测试计划中测试计划的进度显示不正确
https://www.tapd.cn/55049933/s/1292768
This commit is contained in:
wxg0103 2022-11-08 19:08:45 +08:00 committed by wxg0103
parent 722de82676
commit a7e91ddb00
8 changed files with 84 additions and 16 deletions

View File

@ -1,8 +1,8 @@
package io.metersphere.controller.remote; package io.metersphere.controller.remote;
import io.metersphere.service.remote.RemoteTestPlanService;
import io.metersphere.api.dto.QueryTestPlanRequest; import io.metersphere.api.dto.QueryTestPlanRequest;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.service.remote.RemoteTestPlanService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -22,6 +22,11 @@ public class TestPlanController {
add("test/plan/scenario/case"); add("test/plan/scenario/case");
}}; }};
@PostMapping("/list/all/{goPage}/{pageSize}")
public Object planListAll(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanRequest request) {
return remoteTestPlanService.planListAll("/test/plan", goPage, pageSize, request);
}
@GetMapping("/**") @GetMapping("/**")
public List getStageOption(HttpServletRequest request) { public List getStageOption(HttpServletRequest request) {
excludeApi(request.getRequestURI()); excludeApi(request.getRequestURI());
@ -37,6 +42,7 @@ public class TestPlanController {
/** /**
* 解决不同模块路径冲突导致循环调用 * 解决不同模块路径冲突导致循环调用
* todo 待优化 * todo 待优化
*
* @param url * @param url
*/ */
public void excludeApi(String url) { public void excludeApi(String url) {

View File

@ -39,4 +39,13 @@ public class RemoteTestPlanService {
return new ArrayList(); return new ArrayList();
} }
} }
public Object planListAll(String url, int goPage, int pageSize, QueryTestPlanRequest request) {
try {
return microService.postForData(MicroServiceName.TEST_TRACK, url + String.format("/list/all/%s/%s", goPage, pageSize), request);
} catch (Exception e) {
LogUtil.info("测试计划服务调用失败", e);
return new ArrayList();
}
}
} }

View File

@ -7,7 +7,11 @@ export function getPlanStageOption() {
} }
export function planPage(page, pageSize, params) { export function planPage(page, pageSize, params) {
return post('/test/plan/list/all/', params); return post('/test/plan/list/all/'+ page + '/' + pageSize, params);
}
export function testPlanGetPrincipal(id) {
return get('/test/plan/' + `principal/${id}`);
} }
export function getApiScenarioIdByPlanScenarioId(id) { export function getApiScenarioIdByPlanScenarioId(id) {

View File

@ -34,7 +34,7 @@
show-overflow-tooltip> show-overflow-tooltip>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="userName" prop="principalName"
:label="$t('test_track.plan.plan_principal')" :label="$t('test_track.plan.plan_principal')"
show-overflow-tooltip> show-overflow-tooltip>
</el-table-column> </el-table-column>
@ -109,6 +109,8 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<ms-table-pagination :change="initTableData" :current-page.sync="currentPage" :page-size.sync="pageSize"
:total="total"/>
<ms-delete-confirm :title="$t('test_track.plan.plan_delete')" @delete="_handleDelete" ref="deleteConfirm" <ms-delete-confirm :title="$t('test_track.plan.plan_delete')" @delete="_handleDelete" ref="deleteConfirm"
:with-tip="enableDeleteTip"> :with-tip="enableDeleteTip">
{{ $t('test_track.plan.plan_delete_tip') }} {{ $t('test_track.plan.plan_delete_tip') }}
@ -135,7 +137,7 @@ import {getCurrentProjectID} from "metersphere-frontend/src/utils/token";
import {_filter, _sort} from "metersphere-frontend/src/utils/tableUtils"; import {_filter, _sort} from "metersphere-frontend/src/utils/tableUtils";
import EnvPopover from "@/business/automation/scenario/EnvPopover"; import EnvPopover from "@/business/automation/scenario/EnvPopover";
import {ENV_TYPE} from "metersphere-frontend/src/utils/constants"; import {ENV_TYPE} from "metersphere-frontend/src/utils/constants";
import {getPlanStageOption, planPage} from "@/api/test-plan"; import {getPlanStageOption, planPage, testPlanGetPrincipal} from "@/api/test-plan";
import {getApiScenarioProjectIdByConditions, getScenarioByProjectId} from "@/api/scenario"; import {getApiScenarioProjectIdByConditions, getScenarioByProjectId} from "@/api/scenario";
import {getOwnerProjects} from "@/api/project"; import {getOwnerProjects} from "@/api/project";
@ -277,7 +279,27 @@ export default {
this.result = planPage(this.currentPage, this.pageSize, this.condition).then(response => { this.result = planPage(this.currentPage, this.pageSize, this.condition).then(response => {
let data = response.data; let data = response.data;
this.total = data.itemCount; this.total = data.itemCount;
this.tableData = data; data.listObject.forEach(item => {
testPlanGetPrincipal(item.id)
.then(res => {
let data = res.data;
let principal = "";
let principalIds = data.map(d => d.id);
if (data) {
data.forEach(d => {
if (principal !== "") {
principal = principal + "、" + d.name;
} else {
principal = principal + d.name;
}
})
}
this.$set(item, "principalName", principal);
// id
this.$set(item, "principals", principalIds);
});
});
this.tableData = data.listObject;
}); });
}, },
buildPagePath(path) { buildPagePath(path) {

View File

@ -1,7 +1,6 @@
package io.metersphere.base.mapper.ext; package io.metersphere.base.mapper.ext;
import io.metersphere.base.domain.TestPlan; import io.metersphere.base.domain.TestPlan;
import io.metersphere.dto.ParamsDTO; import io.metersphere.dto.ParamsDTO;
import io.metersphere.dto.TestPlanDTOWithMetric; import io.metersphere.dto.TestPlanDTOWithMetric;
import io.metersphere.plan.dto.TestPlanDTO; import io.metersphere.plan.dto.TestPlanDTO;
@ -52,4 +51,6 @@ public interface ExtTestPlanMapper {
@MapKey("id") @MapKey("id")
Map<String, ParamsDTO> testPlanUiScenarioCount(@Param("planIds") Set<String> planIds); Map<String, ParamsDTO> testPlanUiScenarioCount(@Param("planIds") Set<String> planIds);
List<TestPlanDTO> planListAll(@Param("request") QueryTestPlanRequest params);
} }

View File

@ -406,6 +406,17 @@
</where> </where>
GROUP BY t.test_plan_id GROUP BY t.test_plan_id
</select> </select>
<select id="planListAll" resultType="io.metersphere.plan.dto.TestPlanDTO">
select DISTINCT test_plan.*, project.name as projectName,
(select name from user where user.id = test_plan.creator) as userName
from test_plan
JOIN project on project.id = test_plan.project_id
<where>
<if test="request.projectId != null">
AND test_plan.project_id = #{request.projectId}
</if>
</where>
</select>
<update id="updateActualEndTimeIsNullById"> <update id="updateActualEndTimeIsNullById">
update test_plan update test_plan
set actual_end_time = null set actual_end_time = null

View File

@ -88,6 +88,13 @@ public class TestPlanController {
return testPlanService.listTestAllPlan(request); return testPlanService.listTestAllPlan(request);
} }
@PostMapping("/list/all/{goPage}/{pageSize}")
@RequiresPermissions("PROJECT_TRACK_PLAN:READ")
public Pager<List<TestPlanDTO>> planListAll(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testPlanService.planListAll(request));
}
@GetMapping("/get/stage/option/{projectId}") @GetMapping("/get/stage/option/{projectId}")
public List getStageOption(@PathVariable("projectId") String projectId) { public List getStageOption(@PathVariable("projectId") String projectId) {
return testPlanService.getStageOption(projectId); return testPlanService.getStageOption(projectId);

View File

@ -641,6 +641,14 @@ public class TestPlanService {
return testPlanMapper.selectByExample(example); return testPlanMapper.selectByExample(example);
} }
public List<TestPlanDTO> planListAll(QueryTestPlanRequest request) {
if (StringUtils.isNotBlank(request.getProjectId())) {
request.setProjectId(request.getProjectId());
}
List<TestPlanDTO> testPlanDTOS = extTestPlanMapper.planListAll(request);
return testPlanDTOS;
}
public List<TestPlanCaseDTO> listTestCaseByPlanId(String planId) { public List<TestPlanCaseDTO> listTestCaseByPlanId(String planId) {
QueryTestPlanCaseRequest request = new QueryTestPlanCaseRequest(); QueryTestPlanCaseRequest request = new QueryTestPlanCaseRequest();
request.setPlanId(planId); request.setPlanId(planId);