fix (接口定义): 修复导入sql类型接口目录错误问题

--bug=1007085 --user=赵勇 【接口测试】导入sql接口定义,没有导入到所选模块中【+github#6024】 https://www.tapd.cn/55049933/s/1056589
This commit is contained in:
fit2-zhao 2021-10-19 11:52:32 +08:00 committed by fit2-zhao
parent cae077582e
commit e1b0467752
4 changed files with 16 additions and 5 deletions

View File

@ -70,12 +70,16 @@ public class ApiDefinitionImportUtil {
private static void createNodeTree(NodeTree nodeTree, String pid, String projectId,
ApiModuleService apiModuleService, String path, int baseLevel) {
ApiModule apiModule = apiModuleService.get(pid);
ApiModule module = new ApiModule();
BeanUtils.copyBean(module, nodeTree);
apiModuleService.buildNewModule(module);
module.setProjectId(projectId);
module.setParentId(pid);
module.setLevel(module.getLevel() + baseLevel);
if (apiModule != null) {
module.setProtocol(apiModule.getProtocol());
}
createModule(module, SessionUtils.getUserId());
nodeTree.setNewId(module.getId());
path = path + nodeTree.getName();
@ -91,6 +95,7 @@ public class ApiDefinitionImportUtil {
/**
* 根据导出的模块树创建新的模块树
*
* @param nodeTree
* @param projectId
*/
@ -124,12 +129,14 @@ public class ApiDefinitionImportUtil {
}
public static void createModule(ApiModule module) {
createModule(module, null);
createModule(module, null);
}
public static void createModule(ApiModule module, String userId) {
ApiModuleService apiModuleService = CommonBeanFactory.getBean(ApiModuleService.class);
module.setProtocol(RequestType.HTTP);
if (StringUtils.isEmpty(module.getProtocol())) {
module.setProtocol(RequestType.HTTP);
}
if (module.getName().length() > 64) {
module.setName(module.getName().substring(0, 64));
}

View File

@ -60,6 +60,9 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
super(ApiModuleDTO.class);
}
public ApiModule get(String id) {
return apiModuleMapper.selectByPrimaryKey(id);
}
public List<ApiModuleDTO> getNodeTreeByProjectId(String projectId, String protocol) {
// 判断当前项目下是否有默认模块没有添加默认模块
this.getDefaultNode(projectId,protocol);

View File

@ -70,9 +70,9 @@ function getScenarioFiles(obj) {
return scenarioFiles;
}
export function saveScenario(url, scenario, scenarioDefinition, _this,success) {
export function saveScenario(url, scenario, scenarioDefinition, _this, success) {
let bodyFiles = getBodyUploadFiles(scenario, scenarioDefinition);
if (_this.$store.state.pluginFiles && _this.$store.state.pluginFiles.length > 0) {
if (_this && _this.$store && _this.$store.state && _this.$store.state.pluginFiles && _this.$store.state.pluginFiles.length > 0) {
_this.$store.state.pluginFiles.forEach(fileItem => {
if (fileItem.file) {
scenario.bodyFileRequestIds.push(fileItem.file.uid);

View File

@ -101,7 +101,8 @@
this.$emit('saveAsEdit', this.scenarioForm);
this.visible = false;
} else {
saveScenario(path, this.scenarioForm, [], () => {
saveScenario(path, this.scenarioForm, [], this,(response) => {
this.$success(this.$t('commons.save_success'));
this.visible = false;
this.$emit('refresh');
});