diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java index 01bcb6121e..b328123763 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java @@ -256,25 +256,21 @@ public abstract class MsTestElement { return getRootParent(element.getParent()); } - protected String getParentName(MsTestElement element, ParameterConfig config) { - if (element != null) { - MsTestElement parent = this.getRootParent(element); - if (parent != null) { - if (MsTestElementConstants.LoopController.name().equals(parent.getType())) { - MsLoopController loopController = (MsLoopController) parent; - if (StringUtils.equals(loopController.getLoopType(), LoopConstants.WHILE.name()) && loopController.getWhileController() != null) { - return "While 循环-" + "${LoopCounterConfigXXX}"; - } - if (StringUtils.equals(loopController.getLoopType(), LoopConstants.FOREACH.name()) && loopController.getForEachController() != null) { - return "ForEach 循环-" + "${LoopCounterConfigXXX}"; - } - if (StringUtils.equals(loopController.getLoopType(), LoopConstants.LOOP_COUNT.name()) && loopController.getCountController() != null) { - return "次数循环-" + "${LoopCounterConfigXXX}"; - } + protected String getParentName(MsTestElement parent, ParameterConfig config) { + if (parent != null) { + if (MsTestElementConstants.LoopController.name().equals(parent.getType())) { + MsLoopController loopController = (MsLoopController) parent; + if (StringUtils.equals(loopController.getLoopType(), LoopConstants.WHILE.name()) && loopController.getWhileController() != null) { + return "While 循环-" + "${LoopCounterConfigXXX}"; + } + if (StringUtils.equals(loopController.getLoopType(), LoopConstants.FOREACH.name()) && loopController.getForEachController() != null) { + return "ForEach 循环-" + "${LoopCounterConfigXXX}"; + } + if (StringUtils.equals(loopController.getLoopType(), LoopConstants.LOOP_COUNT.name()) && loopController.getCountController() != null) { + return "次数循环-" + "${LoopCounterConfigXXX}"; } - return parent.getName(); } - return element.getName(); + return parent.getName(); } else if (config != null && StringUtils.isNotEmpty(config.getStep())) { if (MsTestElementConstants.SCENARIO.name().equals(config.getStepType())) { return config.getStep(); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index 022a7f36d3..6160fa7f57 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -661,7 +661,10 @@ public class ApiDefinitionService { public String getResourceId(SwaggerUrlRequest swaggerUrlRequest) { SwaggerUrlProjectExample swaggerUrlProjectExample = new SwaggerUrlProjectExample(); SwaggerUrlProjectExample.Criteria criteria = swaggerUrlProjectExample.createCriteria(); - criteria.andProjectIdEqualTo(swaggerUrlRequest.getProjectId()).andSwaggerUrlEqualTo(swaggerUrlRequest.getSwaggerUrl()).andModuleIdEqualTo(swaggerUrlRequest.getModuleId()); + criteria.andProjectIdEqualTo(swaggerUrlRequest.getProjectId()).andSwaggerUrlEqualTo(swaggerUrlRequest.getSwaggerUrl()); + if (StringUtils.isNotBlank(swaggerUrlRequest.getModuleId())) { + criteria.andModuleIdEqualTo(swaggerUrlRequest.getModuleId()); + } List list = swaggerUrlProjectMapper.selectByExample(swaggerUrlProjectExample); String resourceId = ""; if (list.size() == 1) { diff --git a/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java b/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java index a36b4ff3d7..0e0d55f483 100644 --- a/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java +++ b/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java @@ -28,7 +28,6 @@ import io.metersphere.base.mapper.ApiTestMapper; import io.metersphere.base.mapper.ext.ExtApiScenarioMapper; import io.metersphere.commons.utils.BeanUtils; import io.metersphere.commons.utils.DateUtils; -import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.SessionUtils; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -42,7 +41,6 @@ import javax.annotation.Resource; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; -import java.net.URL; import java.nio.channels.FileChannel; import java.util.*; @@ -116,18 +114,6 @@ public class HistoricalDataUpgradeService { if (request instanceof HttpRequest) { element = new MsHTTPSamplerProxy(); HttpRequest request1 = (HttpRequest) request; - if (StringUtils.isEmpty(request1.getPath()) && StringUtils.isNotEmpty(request1.getUrl())) { - try { - URL urlObject = new URL(request1.getUrl()); - String envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getPath(); - request1.setPath(envPath); - request1.setUrl(null); - } catch (Exception ex) { - LogUtil.error(ex.getMessage()); - } - } else { - request1.setUrl(null); - } if (request1.getBody() != null) { request1.getBody().setBinary(new ArrayList<>()); if (request1.getBody().isOldKV()) { @@ -136,21 +122,21 @@ public class HistoricalDataUpgradeService { if ("json".equals(request1.getBody().getFormat())) { if ("Raw".equals(request1.getBody().getType())) { request1.getBody().setType(Body.JSON); - } - if (CollectionUtils.isEmpty(request1.getHeaders())) { - List headers = new LinkedList<>(); - headers.add(new KeyValue("Content-Type", "application/json")); - request1.setHeaders(headers); - } else { - boolean isJsonType = false; - for (KeyValue keyValue : request1.getHeaders()) { - if ("Content-Type".equals(keyValue.getName())) { - isJsonType = true; - break; + if (CollectionUtils.isEmpty(request1.getHeaders())) { + List headers = new LinkedList<>(); + headers.add(new KeyValue("Content-Type", "application/json")); + request1.setHeaders(headers); + } else { + boolean isJsonType = false; + for (KeyValue keyValue : request1.getHeaders()) { + if ("Content-Type".equals(keyValue.getName())) { + isJsonType = true; + break; + } + } + if (!isJsonType) { + request1.getHeaders().set(request1.getHeaders().size() - 1, new KeyValue("Content-Type", "application/json")); } - } - if (!isJsonType) { - request1.getHeaders().set(request1.getHeaders().size() - 1, new KeyValue("Content-Type", "application/json")); } } } @@ -161,6 +147,13 @@ public class HistoricalDataUpgradeService { BeanUtils.copyBean(element, request1); ((MsHTTPSamplerProxy) element).setProtocol(RequestType.HTTP); ((MsHTTPSamplerProxy) element).setArguments(request1.getParameters()); + if (StringUtils.isNotEmpty(request1.getPath()) && request1.isUseEnvironment()) { + ((MsHTTPSamplerProxy) element).setPath(request1.getPath()); + ((MsHTTPSamplerProxy) element).setUrl(null); + } else { + ((MsHTTPSamplerProxy) element).setPath(null); + ((MsHTTPSamplerProxy) element).setUrl(request1.getUrl()); + } List keyValues = new LinkedList<>(); keyValues.add(new KeyValue("", "")); ((MsHTTPSamplerProxy) element).setRest(keyValues); @@ -318,9 +311,6 @@ public class HistoricalDataUpgradeService { } private void createApiScenarioWithBLOBs(SaveHistoricalDataUpgrade saveHistoricalDataUpgrade, String id, String name, int total, String scenarioDefinition, ApiScenarioMapper mapper, int num) { - if (StringUtils.isEmpty(name)) { - name = "默认名称-" + DateUtils.getTimeStr(System.currentTimeMillis()); - } ApiScenarioWithBLOBs scenario = getScenario(id, mapper); if (scenario != null) { scenario.setName(name); @@ -377,6 +367,11 @@ public class HistoricalDataUpgradeService { if (CollectionUtils.isNotEmpty(scenarios)) { // 批量处理 for (Scenario scenario : scenarios) { + if (StringUtils.isEmpty(scenario.getName())) { + scenario.setName("默认名称-" + DateUtils.getTimeStr(System.currentTimeMillis())); + } + scenario.setId(test.getId() + "=" + scenario.getId()); + scenario.setName(test.getName() + "_" + scenario.getName()); MsScenario scenario1 = createScenario(scenario); String scenarioDefinition = JSON.toJSONString(scenario1); num++; diff --git a/backend/src/main/resources/db/migration/V71__modify_scenario.sql b/backend/src/main/resources/db/migration/V71__modify_scenario.sql new file mode 100644 index 0000000000..6edc321985 --- /dev/null +++ b/backend/src/main/resources/db/migration/V71__modify_scenario.sql @@ -0,0 +1 @@ +ALTER TABLE api_scenario MODIFY COLUMN id VARCHAR (120); \ No newline at end of file diff --git a/backend/src/main/resources/db/migration/V72__modify_swagger_url_project.sql b/backend/src/main/resources/db/migration/V72__modify_swagger_url_project.sql new file mode 100644 index 0000000000..bba509bd4a --- /dev/null +++ b/backend/src/main/resources/db/migration/V72__modify_swagger_url_project.sql @@ -0,0 +1,6 @@ +ALTER TABLE swagger_url_project + MODIFY COLUMN id VARCHAR(120); +ALTER TABLE swagger_url_project + MODIFY COLUMN project_id VARCHAR(120); +ALTER TABLE swagger_url_project + MODIFY COLUMN mode_id VARCHAR(120); diff --git a/frontend/src/business/components/api/definition/components/import/ApiImport.vue b/frontend/src/business/components/api/definition/components/import/ApiImport.vue index a7bb46b646..82fb716e25 100644 --- a/frontend/src/business/components/api/definition/components/import/ApiImport.vue +++ b/frontend/src/business/components/api/definition/components/import/ApiImport.vue @@ -113,11 +113,11 @@ export default { showEnvironmentSelect: true, modeOptions: [{ id: 'fullCoverage', - name: '全量覆盖' + name: this.$t('commons.cover') }, { id: 'incrementalMerge', - name: '增量合并' + name: this.$t('commons.not_cover') }], protocol: "", platforms: [ @@ -152,8 +152,8 @@ export default { formData: { file: undefined, swaggerUrl: '', - modeId: '', - moduleId: '' + modeId: this.$t('commons.not_cover'), + moduleId: '', }, rules: {}, currentModule: {}, diff --git a/frontend/src/business/components/settings/organization/components/DefectTaskNotification.vue b/frontend/src/business/components/settings/organization/components/DefectTaskNotification.vue index 1375d4ab42..4d82e7ad15 100644 --- a/frontend/src/business/components/settings/organization/components/DefectTaskNotification.vue +++ b/frontend/src/business/components/settings/organization/components/DefectTaskNotification.vue @@ -274,4 +274,7 @@ export default { .el-row { margin-bottom: 10px; } +.el-button { + margin-left: 10px; +} diff --git a/frontend/src/business/components/settings/organization/components/JenkinsNotification.vue b/frontend/src/business/components/settings/organization/components/JenkinsNotification.vue index 14f8bb6109..2d0915dbfe 100644 --- a/frontend/src/business/components/settings/organization/components/JenkinsNotification.vue +++ b/frontend/src/business/components/settings/organization/components/JenkinsNotification.vue @@ -295,4 +295,8 @@ export default { .el-row { margin-bottom: 10px; } + +.el-button { + margin-left: 10px; +} diff --git a/frontend/src/business/components/settings/organization/components/TestPlanTaskNotification.vue b/frontend/src/business/components/settings/organization/components/TestPlanTaskNotification.vue index 2708c60379..f5ba6d642b 100644 --- a/frontend/src/business/components/settings/organization/components/TestPlanTaskNotification.vue +++ b/frontend/src/business/components/settings/organization/components/TestPlanTaskNotification.vue @@ -308,4 +308,7 @@ export default { .el-row { margin-bottom: 10px; } +.el-button { + margin-left: 10px; +} diff --git a/frontend/src/business/components/settings/organization/components/TestReviewNotification.vue b/frontend/src/business/components/settings/organization/components/TestReviewNotification.vue index ed89473882..125ccf379f 100644 --- a/frontend/src/business/components/settings/organization/components/TestReviewNotification.vue +++ b/frontend/src/business/components/settings/organization/components/TestReviewNotification.vue @@ -313,4 +313,7 @@ export default { .el-row { margin-bottom: 10px; } +.el-button { + margin-left: 10px; +} diff --git a/frontend/src/business/components/settings/system/Organization.vue b/frontend/src/business/components/settings/system/Organization.vue index 8fc66f3284..888236af0f 100644 --- a/frontend/src/business/components/settings/system/Organization.vue +++ b/frontend/src/business/components/settings/system/Organization.vue @@ -252,9 +252,6 @@ export default { activated() { this.initTableData(); }, - created() { - this.list() - }, methods: { create() { this.dialogOrgAddVisible = true; diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index 3d7b54e1d1..b57556fa94 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -1,5 +1,7 @@ export default { commons: { + cover:'Cover', + not_cover:'Not Cover', import_mode: 'Import mode', import_module: 'Import module', please_fill_in_the_template: 'Please fill in the template', diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index 9c9f5ef10f..01c88a49b7 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -1,5 +1,7 @@ export default { commons: { + cover:'覆盖', + not_cover:'不覆盖', import_mode: '导入模式', import_module: '导入模块', please_fill_in_the_template: '请填写模版内容', diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index ef1230efc6..6d81c01325 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -1,5 +1,7 @@ export default { commons: { + cover:'覆蓋', + not_cover:'不覆蓋', import_mode: '導入模式', import_module: '導入模塊', please_fill_in_the_template: '請填寫模版內容',