From 1eb9b3c45f4f9916256779029071c6742dc816bc Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Mon, 14 Sep 2020 15:55:01 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E6=95=B0=E6=8D=AE=E5=BA=93=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/test/components/ApiScenarioForm.vue | 5 + .../request/database/DatabaseConfig.vue | 59 +++++++++ .../request/database/DatabaseConfigDialog.vue | 58 +++++++++ .../request/database/DatabaseConfigList.vue | 92 +++++++++++++ .../request/database/DatabaseFrom.vue | 121 ++++++++++++++++++ .../api/test/model/ScenarioModel.js | 49 ++++++- 6 files changed, 383 insertions(+), 1 deletion(-) create mode 100644 frontend/src/business/components/api/test/components/request/database/DatabaseConfig.vue create mode 100644 frontend/src/business/components/api/test/components/request/database/DatabaseConfigDialog.vue create mode 100644 frontend/src/business/components/api/test/components/request/database/DatabaseConfigList.vue create mode 100644 frontend/src/business/components/api/test/components/request/database/DatabaseFrom.vue diff --git a/frontend/src/business/components/api/test/components/ApiScenarioForm.vue b/frontend/src/business/components/api/test/components/ApiScenarioForm.vue index b71a0aacc6..afe9aaedb5 100644 --- a/frontend/src/business/components/api/test/components/ApiScenarioForm.vue +++ b/frontend/src/business/components/api/test/components/ApiScenarioForm.vue @@ -37,6 +37,9 @@ :environment="scenario.environment" :description="$t('api_test.scenario.kv_description')"/> + + +
Config Center
@@ -62,10 +65,12 @@ import {REQUEST_HEADERS} from "@/common/js/constants"; import MsDubboRegistryCenter from "@/business/components/api/test/components/request/dubbo/RegistryCenter"; import MsDubboConfigCenter from "@/business/components/api/test/components/request/dubbo/ConfigCenter"; import MsDubboConsumerService from "@/business/components/api/test/components/request/dubbo/ConsumerAndService"; +import MsDatabaseConfig from "./request/database/DatabaseConfig"; export default { name: "MsApiScenarioForm", components: { + MsDatabaseConfig, MsDubboConsumerService, MsDubboConfigCenter, MsDubboRegistryCenter, ApiEnvironmentConfig, MsApiScenarioVariables, MsApiKeyValue }, diff --git a/frontend/src/business/components/api/test/components/request/database/DatabaseConfig.vue b/frontend/src/business/components/api/test/components/request/database/DatabaseConfig.vue new file mode 100644 index 0000000000..cbd209758a --- /dev/null +++ b/frontend/src/business/components/api/test/components/request/database/DatabaseConfig.vue @@ -0,0 +1,59 @@ + + + + + diff --git a/frontend/src/business/components/api/test/components/request/database/DatabaseConfigDialog.vue b/frontend/src/business/components/api/test/components/request/database/DatabaseConfigDialog.vue new file mode 100644 index 0000000000..e6e81b0b13 --- /dev/null +++ b/frontend/src/business/components/api/test/components/request/database/DatabaseConfigDialog.vue @@ -0,0 +1,58 @@ + + + + + diff --git a/frontend/src/business/components/api/test/components/request/database/DatabaseConfigList.vue b/frontend/src/business/components/api/test/components/request/database/DatabaseConfigList.vue new file mode 100644 index 0000000000..ee76b5242a --- /dev/null +++ b/frontend/src/business/components/api/test/components/request/database/DatabaseConfigList.vue @@ -0,0 +1,92 @@ + + + + + diff --git a/frontend/src/business/components/api/test/components/request/database/DatabaseFrom.vue b/frontend/src/business/components/api/test/components/request/database/DatabaseFrom.vue new file mode 100644 index 0000000000..f9adfa69f7 --- /dev/null +++ b/frontend/src/business/components/api/test/components/request/database/DatabaseFrom.vue @@ -0,0 +1,121 @@ + + + + + diff --git a/frontend/src/business/components/api/test/model/ScenarioModel.js b/frontend/src/business/components/api/test/model/ScenarioModel.js index 3ab228bf13..d632da62d5 100644 --- a/frontend/src/business/components/api/test/model/ScenarioModel.js +++ b/frontend/src/business/components/api/test/model/ScenarioModel.js @@ -211,14 +211,16 @@ export class Scenario extends BaseConfig { this.environment = undefined; this.enableCookieShare = false; this.enable = true; + this.databaseConfigs = undefined; this.set(options); - this.sets({variables: KeyValue, headers: KeyValue, requests: RequestFactory}, options); + this.sets({variables: KeyValue, headers: KeyValue, requests: RequestFactory, databaseConfigs: DatabaseConfig}, options); } initOptions(options = {}) { options.id = options.id || uuid(); options.requests = options.requests || [new RequestFactory()]; + options.databaseConfigs = options.databaseConfigs || []; options.dubboConfig = new DubboConfig(options.dubboConfig); return options; } @@ -479,6 +481,51 @@ export class ConfigCenter extends BaseConfig { } } +export class DatabaseConfig extends BaseConfig { + static DRIVER_CLASS = ["com.mysql.jdbc.Driver"]; + + constructor(options) { + super(); + this.id = undefined; + this.name = undefined; + this.poolMax = undefined; + this.timeout = undefined; + this.driver = undefined; + this.dbUrl = undefined; + this.username = undefined; + this.password = undefined; + + this.set(options); + } + + initOptions(options = {}) { + // options.id = options.id || uuid(); + return options; + } +// +// true +// +// 5000 +// +// test +// jdbc:mysql://localhost:3306/metersphere?autoReconnect=false&useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true +// com.mysql.jdbc.Driver +// +// true +// root +// 10 +// false +// 10000 +// DEFAULT +// 60000 +// root +// + + isValid() { + return !!this.name || !!this.poolMax || !!this.timeout || !!this.driver || !!this.dbUrl || !!this.username || !!this.password; + } +} + export class RegistryCenter extends BaseConfig { static PROTOCOLS = ["none", "zookeeper", "nacos", "apollo", "multicast", "redis", "simple"];