refactor: 场景列表新增运行环境列
--story=1003532 --user=lyh 6.单接口用例列表和场景列表新增 运行环境 参考测试计划列表的运行环境展示 https://www.tapd.cn/55049933/s/1061128
This commit is contained in:
parent
eea1ea6d30
commit
17d52a6e19
|
@ -47,7 +47,8 @@ public class ApiAutomationController {
|
||||||
@RequiresPermissions("PROJECT_API_SCENARIO:READ")
|
@RequiresPermissions("PROJECT_API_SCENARIO:READ")
|
||||||
public Pager<List<ApiScenarioDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiScenarioRequest request) {
|
public Pager<List<ApiScenarioDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiScenarioRequest request) {
|
||||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||||
|
// 查询场景环境
|
||||||
|
request.setSelectEnvironment(true);
|
||||||
return PageUtils.setPageInfo(page, apiAutomationService.list(request));
|
return PageUtils.setPageInfo(page, apiAutomationService.list(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,5 +368,6 @@ public class ApiAutomationController {
|
||||||
public List<String> getFollows(@PathVariable String scenarioId) {
|
public List<String> getFollows(@PathVariable String scenarioId) {
|
||||||
return apiAutomationService.getFollows(scenarioId);
|
return apiAutomationService.getFollows(scenarioId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
|
@ -24,4 +25,9 @@ public class ApiScenarioDTO extends ApiScenarioWithBLOBs {
|
||||||
|
|
||||||
private String caseId;
|
private String caseId;
|
||||||
private String environment;
|
private String environment;
|
||||||
|
/**
|
||||||
|
* 场景列表 环境
|
||||||
|
*/
|
||||||
|
private String env;
|
||||||
|
private Map<String, String> environmentMap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,4 +28,8 @@ public class ApiScenarioRequest extends BaseQueryRequest {
|
||||||
private String operator;
|
private String operator;
|
||||||
//操作时间
|
//操作时间
|
||||||
private Long operationTime;
|
private Long operationTime;
|
||||||
|
/**
|
||||||
|
* 是否需要查询环境字段
|
||||||
|
*/
|
||||||
|
private boolean selectEnvironment = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,9 +174,58 @@ public class ApiAutomationService {
|
||||||
public List<ApiScenarioDTO> list(ApiScenarioRequest request) {
|
public List<ApiScenarioDTO> list(ApiScenarioRequest request) {
|
||||||
request = this.initRequest(request, true, true);
|
request = this.initRequest(request, true, true);
|
||||||
List<ApiScenarioDTO> list = extApiScenarioMapper.list(request);
|
List<ApiScenarioDTO> list = extApiScenarioMapper.list(request);
|
||||||
|
if (BooleanUtils.isTrue(request.isSelectEnvironment())) {
|
||||||
|
this.setApiScenarioEnv(list);
|
||||||
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setApiScenarioEnv(List<ApiScenarioDTO> list) {
|
||||||
|
List<Project> projectList = projectMapper.selectByExample(new ProjectExample());
|
||||||
|
List<ApiTestEnvironmentWithBLOBs> apiTestEnvironments = apiTestEnvironmentMapper.selectByExampleWithBLOBs(new ApiTestEnvironmentExample());
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
String env = list.get(i).getEnv();
|
||||||
|
// 环境属性为空 跳过
|
||||||
|
if (StringUtils.isBlank(env)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Map map = JSON.parseObject(env, Map.class);
|
||||||
|
Set<String> set = map.keySet();
|
||||||
|
HashMap<String, String> envMap = new HashMap<>(16);
|
||||||
|
// 项目为空 跳过
|
||||||
|
if (set.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (String projectId : set) {
|
||||||
|
String envId = (String) map.get(projectId);
|
||||||
|
if (StringUtils.isBlank(envId)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
List<Project> projects = projectList.stream().filter(p -> StringUtils.equals(p.getId(), projectId)).collect(Collectors.toList());
|
||||||
|
if (CollectionUtils.isEmpty(projects)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Project project = projects.get(0);
|
||||||
|
List<ApiTestEnvironmentWithBLOBs> envs = apiTestEnvironments.stream().filter(e -> StringUtils.equals(e.getId(), envId)).collect(Collectors.toList());
|
||||||
|
if (CollectionUtils.isEmpty(envs)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ApiTestEnvironmentWithBLOBs environment = envs.get(0);
|
||||||
|
String projectName = project.getName();
|
||||||
|
String envName = environment.getName();
|
||||||
|
if (StringUtils.isBlank(projectName) || StringUtils.isBlank(envName)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
envMap.put(projectName, envName);
|
||||||
|
}
|
||||||
|
list.get(i).setEnvironmentMap(envMap);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtil.error("api scenario environment map incorrect parsing. api scenario id:" + list.get(i).getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<ApiScenarioWithBLOBs> listAll(ApiScenarioBatchRequest request) {
|
public List<ApiScenarioWithBLOBs> listAll(ApiScenarioBatchRequest request) {
|
||||||
ServiceUtils.getSelectAllIds(request, request.getCondition(),
|
ServiceUtils.getSelectAllIds(request, request.getCondition(),
|
||||||
(query) -> extApiScenarioMapper.selectIdsByQuery(query));
|
(query) -> extApiScenarioMapper.selectIdsByQuery(query));
|
||||||
|
|
|
@ -84,4 +84,5 @@ public interface ExtApiScenarioMapper {
|
||||||
Long getLastOrder(@Param("projectId") String projectId, @Param("baseOrder") Long baseOrder);
|
Long getLastOrder(@Param("projectId") String projectId, @Param("baseOrder") Long baseOrder);
|
||||||
|
|
||||||
List<RelationshipGraphData.Node> getTestCaseForGraph(@Param("ids") Set<String> ids);
|
List<RelationshipGraphData.Node> getTestCaseForGraph(@Param("ids") Set<String> ids);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,6 +153,9 @@
|
||||||
<select id="list" resultMap="BaseResultMap">
|
<select id="list" resultMap="BaseResultMap">
|
||||||
select api_scenario.id, api_scenario.project_id, api_scenario.tags, api_scenario.user_id, api_scenario.num,
|
select api_scenario.id, api_scenario.project_id, api_scenario.tags, api_scenario.user_id, api_scenario.num,
|
||||||
api_scenario.custom_num, api_scenario.version,
|
api_scenario.custom_num, api_scenario.version,
|
||||||
|
<if test="request.selectEnvironment == true">
|
||||||
|
api_scenario.scenario_definition -> '$.environmentMap' as env,
|
||||||
|
</if>
|
||||||
api_scenario.api_scenario_module_id,api_scenario.module_path, api_scenario.name, api_scenario.level,
|
api_scenario.api_scenario_module_id,api_scenario.module_path, api_scenario.name, api_scenario.level,
|
||||||
api_scenario.status, api_scenario.principal, api_scenario.step_total,
|
api_scenario.status, api_scenario.principal, api_scenario.step_total,
|
||||||
api_scenario.last_result,api_scenario.pass_rate,api_scenario.report_id,
|
api_scenario.last_result,api_scenario.pass_rate,api_scenario.report_id,
|
||||||
|
@ -607,4 +610,5 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
and api_scenario.status != 'Trash';
|
and api_scenario.status != 'Trash';
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -341,7 +341,7 @@ public class TestPlanScenarioCaseService {
|
||||||
return testPlanApiScenarioMapper.countByExample(example) > 0 ? true : false;
|
return testPlanApiScenarioMapper.countByExample(example) > 0 ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getScenarioCaseEnv(HashMap<String, String> map) {
|
public Map<String, String> getScenarioCaseEnv(Map<String, String> map) {
|
||||||
Set<String> set = map.keySet();
|
Set<String> set = map.keySet();
|
||||||
HashMap<String, String> envMap = new HashMap<>(16);
|
HashMap<String, String> envMap = new HashMap<>(16);
|
||||||
if (set.isEmpty()) {
|
if (set.isEmpty()) {
|
||||||
|
|
|
@ -132,6 +132,39 @@
|
||||||
:field="item"
|
:field="item"
|
||||||
:fields-width="fieldsWidth"
|
:fields-width="fieldsWidth"
|
||||||
sortable="custom"/>
|
sortable="custom"/>
|
||||||
|
|
||||||
|
<ms-table-column
|
||||||
|
:field="item"
|
||||||
|
:fields-width="fieldsWidth"
|
||||||
|
prop="environmentMap"
|
||||||
|
:label="$t('commons.environment')"
|
||||||
|
min-width="180">
|
||||||
|
<template v-slot:default="{row}">
|
||||||
|
<div v-if="row.environmentMap">
|
||||||
|
<span v-for="(k, v, index) in row.environmentMap" :key="index">
|
||||||
|
<span v-if="index===0">
|
||||||
|
<span class="project-name" :title="v">{{v}}</span>:
|
||||||
|
<el-tag type="success" size="mini" effect="plain">
|
||||||
|
<span class="project-env">{{k}}</span>
|
||||||
|
</el-tag>
|
||||||
|
<br/>
|
||||||
|
</span>
|
||||||
|
<el-popover
|
||||||
|
placement="top"
|
||||||
|
width="350"
|
||||||
|
trigger="click">
|
||||||
|
<div v-for="(k, v, index) in row.environmentMap" :key="index">
|
||||||
|
<span class="plan-case-env">{{v}}:
|
||||||
|
<el-tag type="success" size="mini" effect="plain">{{k}}</el-tag><br/>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<el-link v-if="index === 1" slot="reference" type="info" :underline="false" icon="el-icon-more"/>
|
||||||
|
</el-popover>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</ms-table-column>
|
||||||
|
|
||||||
<ms-table-column prop="updateTime"
|
<ms-table-column prop="updateTime"
|
||||||
:field="item"
|
:field="item"
|
||||||
:fields-width="fieldsWidth"
|
:fields-width="fieldsWidth"
|
||||||
|
@ -1196,4 +1229,34 @@ export default {
|
||||||
border-color: #dd3636;
|
border-color: #dd3636;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.plan-case-env {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0 0;
|
||||||
|
max-width: 350px;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
margin-top: 2px;
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-name {
|
||||||
|
display: inline-block;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
width: 80px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-env{
|
||||||
|
display: inline-block;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
width: 50px;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -73,6 +73,7 @@ export let CUSTOM_TABLE_HEADER = {
|
||||||
{id: 'tags', key: '5', label: 'commons.tag'},
|
{id: 'tags', key: '5', label: 'commons.tag'},
|
||||||
{id: 'userName', key: '6', label: 'api_test.automation.creator'},
|
{id: 'userName', key: '6', label: 'api_test.automation.creator'},
|
||||||
{id: 'principalName', key: '7', label: 'api_test.definition.api_principal'},
|
{id: 'principalName', key: '7', label: 'api_test.definition.api_principal'},
|
||||||
|
{id: 'environmentMap', key: 'e', label: 'commons.environment'},
|
||||||
{id: 'updateTime', key: '8', label: 'api_test.definition.api_last_time'},
|
{id: 'updateTime', key: '8', label: 'api_test.definition.api_last_time'},
|
||||||
{id: 'stepTotal', key: '9', label: 'api_test.automation.step'},
|
{id: 'stepTotal', key: '9', label: 'api_test.automation.step'},
|
||||||
{id: 'lastResult', key: 'a', label: 'api_test.automation.last_result'},
|
{id: 'lastResult', key: 'a', label: 'api_test.automation.last_result'},
|
||||||
|
|
Loading…
Reference in New Issue