refactor(接口测试): 优化接口导入
This commit is contained in:
parent
4053e5c206
commit
9488fa681d
|
@ -152,15 +152,22 @@ public class ApiDefinitionImportUtilService {
|
||||||
if (StringUtils.isNotBlank(request.getModuleId())) {
|
if (StringUtils.isNotBlank(request.getModuleId())) {
|
||||||
BaseTreeNode baseTreeNode = idModuleMap.get(request.getModuleId());
|
BaseTreeNode baseTreeNode = idModuleMap.get(request.getModuleId());
|
||||||
String modulePath = baseTreeNode.getPath();
|
String modulePath = baseTreeNode.getPath();
|
||||||
importData.forEach(t -> {
|
//如果选择了未规划模块, 导入的数据的模块清空, 只导入数据,不处理模块信息
|
||||||
t.setModulePath(modulePath + t.getModulePath());
|
if ("root".equals(request.getModuleId())) {
|
||||||
});
|
importData.forEach(t -> {
|
||||||
|
t.setModulePath(modulePath);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
importData.forEach(t -> {
|
||||||
|
t.setModulePath(modulePath + t.getModulePath());
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//去掉apiLists中不存在的模块数据
|
//去掉apiLists中不存在的模块数据
|
||||||
apiLists = apiLists.stream().filter(t -> modulePathMap.containsKey(t.getModulePath())).toList();
|
|
||||||
apiLists.forEach(t -> {
|
apiLists.forEach(t -> {
|
||||||
t.setModulePath(idModuleMap.get(t.getModuleId()) != null ? idModuleMap.get(t.getModuleId()).getPath() : StringUtils.EMPTY);
|
t.setModulePath(idModuleMap.get(t.getModuleId()) != null ? idModuleMap.get(t.getModuleId()).getPath() : StringUtils.EMPTY);
|
||||||
});
|
});
|
||||||
|
apiLists = apiLists.stream().filter(t -> modulePathMap.containsKey(t.getModulePath())).toList();
|
||||||
ApiDetailWithData apiDealWithData = new ApiDetailWithData();
|
ApiDetailWithData apiDealWithData = new ApiDetailWithData();
|
||||||
//判断数据是否是唯一的
|
//判断数据是否是唯一的
|
||||||
checkApiDataOnly(request, importData, apiLists, apiDealWithData);
|
checkApiDataOnly(request, importData, apiLists, apiDealWithData);
|
||||||
|
@ -419,7 +426,7 @@ public class ApiDefinitionImportUtilService {
|
||||||
//判断模块是否一样
|
//判断模块是否一样
|
||||||
if (!StringUtils.equals(apiDefinitionDTO.getModulePath(), importDTO.getModulePath())) {
|
if (!StringUtils.equals(apiDefinitionDTO.getModulePath(), importDTO.getModulePath())) {
|
||||||
//不一样的模块需要更
|
//不一样的模块需要更
|
||||||
apiDefinitionDTO.setModulePath(apiDefinitionDTO.getModulePath());
|
apiDefinitionDTO.setModulePath(importDTO.getModulePath());
|
||||||
updateModuleData.add(apiDefinitionDTO);
|
updateModuleData.add(apiDefinitionDTO);
|
||||||
logMap.put(apiDefinitionDTO.getId(), importDTO);
|
logMap.put(apiDefinitionDTO.getId(), importDTO);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1539,6 +1539,7 @@ public class ApiDefinitionControllerTests extends BaseTest {
|
||||||
.getPath()));
|
.getPath()));
|
||||||
file = new MockMultipartFile("file", "openapi1.json", MediaType.APPLICATION_OCTET_STREAM_VALUE, inputStream);
|
file = new MockMultipartFile("file", "openapi1.json", MediaType.APPLICATION_OCTET_STREAM_VALUE, inputStream);
|
||||||
paramMap.add("file", file);
|
paramMap.add("file", file);
|
||||||
|
request.setModuleId("root");
|
||||||
request.setCoverModule(true);
|
request.setCoverModule(true);
|
||||||
request.setCoverData(true);
|
request.setCoverData(true);
|
||||||
paramMap.add("request", JSON.toJSONString(request));
|
paramMap.add("request", JSON.toJSONString(request));
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
class="w-[436px]"
|
class="w-[436px]"
|
||||||
:field-names="{ title: 'name', key: 'id', children: 'children' }"
|
:field-names="{ title: 'name', key: 'id', children: 'children' }"
|
||||||
allow-search
|
allow-search
|
||||||
|
allow-clear
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item>
|
<a-form-item>
|
||||||
|
|
|
@ -409,6 +409,7 @@
|
||||||
label: 'common.delete',
|
label: 'common.delete',
|
||||||
eventTag: 'delete',
|
eventTag: 'delete',
|
||||||
danger: true,
|
danger: true,
|
||||||
|
permission: ['PROJECT_API_DEFINITION:READ+DELETE'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue