refactor(接口测试): 环境组选项查询时过滤掉不存在的项目

--bug=1011599 --user=李玉号 【接口测试】场景批量执行,带自定义请求的场景,选择环境组,提示缺少项目环境
https://www.tapd.cn/55049933/s/1124186
This commit is contained in:
shiziyuan9527 2022-03-23 12:57:12 +08:00 committed by shiziyuan9527
parent 7ce28d2589
commit 274fe5c7c0

View File

@ -287,12 +287,18 @@ public class EnvironmentGroupService {
example.createCriteria().andWorkspaceIdEqualTo(SessionUtils.getCurrentWorkspaceId());
List<EnvironmentGroupDTO> result = new ArrayList<>();
List<EnvironmentGroup> groups = environmentGroupMapper.selectByExample(example);
List<String> ids = new ArrayList<>();
if (CollectionUtils.isNotEmpty(projectIds)) {
List<Project> projects = projectMapper.selectByExample(new ProjectExample());
List<String> allProjectIds = projects.stream().map(Project::getId).collect(Collectors.toList());
ids = projectIds.stream().filter(allProjectIds::contains).collect(Collectors.toList());
}
for (EnvironmentGroup group : groups) {
Map<String, String> envMap = environmentGroupProjectService.getEnvMap(group.getId());
EnvironmentGroupDTO dto = new EnvironmentGroupDTO();
BeanUtils.copyProperties(group, dto);
if (CollectionUtils.isNotEmpty(projectIds)) {
boolean b = envMap.keySet().containsAll(projectIds);
if (CollectionUtils.isNotEmpty(ids)) {
boolean b = envMap.keySet().containsAll(ids);
if (BooleanUtils.isFalse(b)) {
dto.setDisabled(true);
}