From ca0d49281cc41f94829ac80ece67d0d1b00db178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=B6=E5=90=AF=E9=BE=99?= Date: Fri, 6 Sep 2024 10:50:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20mysql/pgsql=20=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../page/database/{rds => components}/add.vue | 76 +- .../database/{rds => mysql}/ModifyRole.vue | 0 .../database/{rds => mysql}/RegionItem.vue | 0 .../page/database/{rds => mysql}/auth.vue | 0 .../page/database/{rds => mysql}/index.vue | 4 +- .../page/database/{rds => mysql}/validate.js | 0 .../page/database/postgresql/ModifyRole.vue | 135 +++ .../page/database/postgresql/RegionItem.vue | 76 ++ .../ctstack/page/database/postgresql/auth.vue | 225 +++++ .../page/database/postgresql/index.vue | 865 ++++++++++++++++++ .../page/database/postgresql/validate.js | 439 +++++++++ .../src/views/resource/ctstack/router.js | 4 +- .../ctstack/services/database/mockData.js | 39 + .../resource/ctstack/services/database/rds.js | 7 +- 14 files changed, 1819 insertions(+), 51 deletions(-) rename webs/cmp-web/src/views/resource/ctstack/page/database/{rds => components}/add.vue (90%) rename webs/cmp-web/src/views/resource/ctstack/page/database/{rds => mysql}/ModifyRole.vue (100%) rename webs/cmp-web/src/views/resource/ctstack/page/database/{rds => mysql}/RegionItem.vue (100%) rename webs/cmp-web/src/views/resource/ctstack/page/database/{rds => mysql}/auth.vue (100%) rename webs/cmp-web/src/views/resource/ctstack/page/database/{rds => mysql}/index.vue (99%) rename webs/cmp-web/src/views/resource/ctstack/page/database/{rds => mysql}/validate.js (100%) create mode 100644 webs/cmp-web/src/views/resource/ctstack/page/database/postgresql/ModifyRole.vue create mode 100644 webs/cmp-web/src/views/resource/ctstack/page/database/postgresql/RegionItem.vue create mode 100644 webs/cmp-web/src/views/resource/ctstack/page/database/postgresql/auth.vue create mode 100644 webs/cmp-web/src/views/resource/ctstack/page/database/postgresql/index.vue create mode 100644 webs/cmp-web/src/views/resource/ctstack/page/database/postgresql/validate.js diff --git a/webs/cmp-web/src/views/resource/ctstack/page/database/rds/add.vue b/webs/cmp-web/src/views/resource/ctstack/page/database/components/add.vue similarity index 90% rename from webs/cmp-web/src/views/resource/ctstack/page/database/rds/add.vue rename to webs/cmp-web/src/views/resource/ctstack/page/database/components/add.vue index 774eb94..eb0f526 100644 --- a/webs/cmp-web/src/views/resource/ctstack/page/database/rds/add.vue +++ b/webs/cmp-web/src/views/resource/ctstack/page/database/components/add.vue @@ -13,47 +13,48 @@ - + - + - - - - + + + MySQL + PostgreSQL + - + - + - + {{ item.displayName }} - + {{ item.displayName }} - + {{ item.displayName }} - + {{ item.name }} @@ -69,7 +70,7 @@ - + @@ -79,7 +80,7 @@ - + @@ -89,17 +90,17 @@ - + - + - + @@ -127,7 +128,7 @@ import validate from '@/validate' import { getRegion } from 'services/platform/index' import { getSubnet } from 'views/resource/ctstack/services/subnet.js' import { getGroup } from 'views/resource/ctstack/services/group.js' -import { getFlavor, createRds, getRdsProject, getRdsZone } from 'views/resource/ctstack/services/database/rds.js' +import { getFlavor, createRds, getRdsProject, getRdsZone, getStorageType } from 'views/resource/ctstack/services/database/rds.js' import { getVpc } from 'views/resource/ctstack/services/vpcs.js' import { encrypt, handleSearchParam } from '@cmp/cmp-element' import { uniqBy, cloneDeep } from 'lodash-es' @@ -204,32 +205,8 @@ export default { }, projectList: [], regionData: [], - sqlTypeMap: { - MySQL: ['5.7', '8.0'] - }, prodSpecNameList: [], - storageTypeList: [ - { - name: '极速型SSD', - value: 'FAST-SSD' - }, - { - name: '通用型SSD', - value: 'SSD-genric' - }, - { - name: '高IO', - value: 'SAS' - }, - { - name: '普通IO', - value: 'SATA' - }, - { - name: '超高IO', - value: 'SSD' - } - ], + storageTypeList: [], periodList: [ { name: '1个月', value: '1' }, { name: '2个月', value: '2' }, @@ -256,9 +233,19 @@ export default { }, created() { this.getRegionList() + this.getStorageTypeList() }, mounted() {}, methods: { + getStorageTypeList() { + getStorageType({ + type: this.addData.type + }).then(data => { + if (data.success) { + this.storageTypeList = data.data + } + }) + }, getRegionList() { const { vendorId, type } = this.formData if (type) { @@ -499,5 +486,4 @@ export default { } - -// 创建待调试 \ No newline at end of file +// 创建待调试 diff --git a/webs/cmp-web/src/views/resource/ctstack/page/database/rds/ModifyRole.vue b/webs/cmp-web/src/views/resource/ctstack/page/database/mysql/ModifyRole.vue similarity index 100% rename from webs/cmp-web/src/views/resource/ctstack/page/database/rds/ModifyRole.vue rename to webs/cmp-web/src/views/resource/ctstack/page/database/mysql/ModifyRole.vue diff --git a/webs/cmp-web/src/views/resource/ctstack/page/database/rds/RegionItem.vue b/webs/cmp-web/src/views/resource/ctstack/page/database/mysql/RegionItem.vue similarity index 100% rename from webs/cmp-web/src/views/resource/ctstack/page/database/rds/RegionItem.vue rename to webs/cmp-web/src/views/resource/ctstack/page/database/mysql/RegionItem.vue diff --git a/webs/cmp-web/src/views/resource/ctstack/page/database/rds/auth.vue b/webs/cmp-web/src/views/resource/ctstack/page/database/mysql/auth.vue similarity index 100% rename from webs/cmp-web/src/views/resource/ctstack/page/database/rds/auth.vue rename to webs/cmp-web/src/views/resource/ctstack/page/database/mysql/auth.vue diff --git a/webs/cmp-web/src/views/resource/ctstack/page/database/rds/index.vue b/webs/cmp-web/src/views/resource/ctstack/page/database/mysql/index.vue similarity index 99% rename from webs/cmp-web/src/views/resource/ctstack/page/database/rds/index.vue rename to webs/cmp-web/src/views/resource/ctstack/page/database/mysql/index.vue index e053316..426d9b6 100644 --- a/webs/cmp-web/src/views/resource/ctstack/page/database/rds/index.vue +++ b/webs/cmp-web/src/views/resource/ctstack/page/database/mysql/index.vue @@ -263,7 +263,7 @@ + diff --git a/webs/cmp-web/src/views/resource/ctstack/page/database/postgresql/RegionItem.vue b/webs/cmp-web/src/views/resource/ctstack/page/database/postgresql/RegionItem.vue new file mode 100644 index 0000000..19deed9 --- /dev/null +++ b/webs/cmp-web/src/views/resource/ctstack/page/database/postgresql/RegionItem.vue @@ -0,0 +1,76 @@ +/** * Created by HaijunZhang on 2019/4/28. */ + + + + diff --git a/webs/cmp-web/src/views/resource/ctstack/page/database/postgresql/auth.vue b/webs/cmp-web/src/views/resource/ctstack/page/database/postgresql/auth.vue new file mode 100644 index 0000000..c3dea62 --- /dev/null +++ b/webs/cmp-web/src/views/resource/ctstack/page/database/postgresql/auth.vue @@ -0,0 +1,225 @@ + + + diff --git a/webs/cmp-web/src/views/resource/ctstack/page/database/postgresql/index.vue b/webs/cmp-web/src/views/resource/ctstack/page/database/postgresql/index.vue new file mode 100644 index 0000000..b1fc621 --- /dev/null +++ b/webs/cmp-web/src/views/resource/ctstack/page/database/postgresql/index.vue @@ -0,0 +1,865 @@ + + + + + diff --git a/webs/cmp-web/src/views/resource/ctstack/page/database/postgresql/validate.js b/webs/cmp-web/src/views/resource/ctstack/page/database/postgresql/validate.js new file mode 100644 index 0000000..4f58511 --- /dev/null +++ b/webs/cmp-web/src/views/resource/ctstack/page/database/postgresql/validate.js @@ -0,0 +1,439 @@ +export const keywords = [ + // RDS MySQL + 'ACTION', + 'ADD', + 'ADMIN', + 'ALL', + 'ALTER', + 'ANALYZE', + 'AND', + 'AS', + 'ASC', + 'ASENSITIVE', + 'BEFORE', + 'BETWEEN', + 'BIGINT', + 'BINARY', + 'BLOB', + 'BOTH', + 'BY', + 'CALL', + 'CASCADE', + 'CASE', + 'CHANGE', + 'CHAR', + 'CHARACTER', + 'CHECK', + 'COLLATE', + 'COLUMN', + 'CONDITION', + 'CONNECTION', + 'CONSTRAINT', + 'CONTINUE', + 'CONVERT', + 'CREATE', + 'CROSS', + 'CURRENT_DATE', + 'CURRENT_TIME', + 'CURRENT_TIMESTAMP', + 'CURRENT_USER', + 'CURSOR', + 'DATABASE', + 'DATABASES', + 'DAY_HOUR', + 'DAY_MICROSECOND', + 'DAY_MINUTE', + 'DAY_SECOND', + 'DEC', + 'DECIMAL', + 'DECLARE', + 'DEFAULT', + 'DELAYED', + 'DELETE', + 'DESC', + 'DESCRIBE', + 'DETERMINISTIC', + 'DISTINCT', + 'DISTINCTROW', + 'DIV', + 'DOUBLE', + 'DROP', + 'DUAL', + 'EACH', + 'EAGLEYE', + 'ELSE', + 'ELSEIF', + 'ENCLOSED', + 'ESCAPED', + 'EXISTS', + 'EXIT', + 'EXPLAIN', + 'FALSE', + 'FETCH', + 'FLOAT', + 'FLOAT4', + 'FLOAT8', + 'FOR', + 'FORCE', + 'FOREIGN', + 'FROM', + 'FULLTEXT', + 'GOTO', + 'GRANT', + 'GROUP', + 'GUEST', + 'HAVING', + 'HIGH_PRIORITY', + 'HOUR_MICROSECOND', + 'HOUR_MINUTE', + 'HOUR_SECOND', + 'IF', + 'IGNORE', + 'IN', + 'INDEX', + 'INFILE', + 'INFORMATION_SCHEMA', + 'INNER', + 'INOUT', + 'INSENSITIVE', + 'INSERT', + 'INT', + 'INT1', + 'INT2', + 'INT3', + 'INT4', + 'INT8', + 'INTEGER', + 'INTERVAL', + 'INTO', + 'IS', + 'ITERATE', + 'JOIN', + 'KEY', + 'KEYS', + 'KILL', + 'LABEL', + 'LEADING', + 'LEAVE', + 'LEFT', + 'LIKE', + 'LIMIT', + 'LINEAR', + 'LINES', + 'LOAD', + 'LOCALTIME', + 'LOCALTIMESTAMP', + 'LOCK', + 'LONG', + 'LONGBLOB', + 'LONGTEXT', + 'LOOP', + 'LOW_PRIORITY', + 'MATCH', + 'MEDIUMBLOB', + 'MEDIUMINT', + 'MEDIUMTEXT', + 'MIDDLEINT', + 'MINUTE_MICROSECOND', + 'MINUTE_SECOND', + 'MOD', + 'MODIFIES', + 'MYSQL', + 'NATURAL', + 'NO_WRITE_TO_BINLOG', + 'NOT', + 'NULL', + 'NUMERIC', + 'ON', + 'OPTIMIZE', + 'OPTION', + 'OPTIONALLY', + 'OR', + 'ORDER', + 'OUT', + 'OUTER', + 'OUTFILE', + 'PERFORMANCE_SCHEMA', + 'PRECISION', + 'PRIMARY', + 'PROCEDURE', + 'PURGE', + 'RAID0', + 'RANGE', + 'READ', + 'READS', + 'REAL', + 'REFERENCES', + 'REGEXP', + 'RELEASE', + 'RENAME', + 'REPEAT', + 'REPLACE', + 'REPLICATOR', + 'REQUIRE', + 'RESTRICT', + 'RETURN', + 'REVOKE', + 'RIGHT', + 'RLIKE', + 'ROOT', + 'SCHEMA', + 'SCHEMAS', + 'SECOND_MICROSECOND', + 'SELECT', + 'SENSITIVE', + 'SEPARATOR', + 'SET', + 'SHOW', + 'SMALLINT', + 'SPATIAL', + 'SPECIFIC', + 'SQL', + 'SQL_BIG_RESULT', + 'SQL_CALC_FOUND_ROWS', + 'SQL_SMALL_RESULT', + 'SQLEXCEPTION', + 'SQLSTATE', + 'SQLWARNING', + 'SSL', + 'STARTING', + 'STRAIGHT_JOIN', + 'TABLE', + 'TERMINATED', + 'TEST', + 'THEN', + 'TINYBLOB', + 'TINYINT', + 'TINYTEXT', + 'TO', + 'TRAILING', + 'TRIGGER', + 'TRUE', + 'UNDO', + 'UNION', + 'UNIQUE', + 'UNLOCK', + 'UNSIGNED', + 'UPDATE', + 'USAGE', + 'USE', + 'USING', + 'UTC_DATE', + 'UTC_TIME', + 'UTC_TIMESTAMP', + 'VALUES', + 'VARBINARY', + 'VARCHAR', + 'VARCHARACTER', + 'VARYING', + 'WHEN', + 'WHERE', + 'WHILE', + 'WITH', + 'WRITE', + 'X509', + 'XOR', + 'XTRABAK', + 'YEAR_MONTH', + 'ZEROFILL', + + // RDS SQL Server + 'ADD', + 'ADMIN', + 'ADMINISTRATOR', + 'ALL', + 'ALTER', + 'AND', + 'ANY', + 'AS', + 'ASC', + 'AURORA', + 'AUTHORIZATION', + 'BACKUP', + 'BEGIN', + 'BETWEEN', + 'BREAK', + 'BROWSE', + 'BULK', + 'BULKADMIN', + 'BY', + 'CASCADE', + 'CASE', + 'CHECK', + 'CHECKPOINT', + 'CLOSE', + 'CLUSTERED', + 'COALESCE', + 'COLLATE', + 'COLUMN', + 'COMMIT', + 'COMPUTE', + 'CONSTRAINT', + 'CONTAINS', + 'CONTAINSTABLE', + 'CONTINUE', + 'CONVERT', + 'CREATE', + 'CROSS', + 'CURRENT', + 'CURRENT_DATE', + 'CURRENT_TIME', + 'CURRENT_TIMESTAMP', + 'CURRENT_USER', + 'CURSOR', + 'DATABASE', + 'DBCC', + 'DBCREATOR', + 'DEALLOCATE', + 'DECLARE', + 'DEFAULT', + 'DELETE', + 'DENY', + 'DESC', + 'DISK', + 'DISKADMIN', + 'DISTINCT', + 'DISTRIBUTED', + 'DISTRIBUTION', + 'DOUBLE', + 'DROP', + 'DUMMY', + 'DUMP', + 'EAGLEYE', + 'ELSE', + 'END', + 'ERRLVL', + 'ESCAPE', + 'EXCEPT', + 'EXEC', + 'EXECUTE', + 'EXISTS', + 'EXIT', + 'FETCH', + 'FILE', + 'FILLFACTOR', + 'FOR', + 'FOREIGN', + 'FREETEXT', + 'FREETEXTTABLE', + 'FROM', + 'FULL', + 'FUNCTION', + 'GALAXY', + 'GOTO', + 'GRANT', + 'GROUP', + 'GUEST', + 'HAVING', + 'HOLDLOCK', + 'IDENTITY', + 'IDENTITY_INSERT', + 'IDENTITYCOL', + 'IF', + 'IN', + 'INDEX', + 'INNER', + 'INSERT', + 'INTERSECT', + 'INTO', + 'IS', + 'JOIN', + 'KEY', + 'KILL', + 'LEFT', + 'LIKE', + 'LINENO', + 'LOAD', + 'MASTER', + 'MODEL', + 'MSDB', + 'MSSQLD', + 'MSSQLSYSTEMRESOURCE', + 'NATIONAL', + 'NOCHECK', + 'NONCLUSTERED', + 'NOT', + 'NULL', + 'NULLIF', + 'OF', + 'OFF', + 'OFFSETS', + 'ON', + 'OPEN', + 'OPENDATASOURCE', + 'OPENQUERY', + 'OPENROWSET', + 'OPENXML', + 'OPTION', + 'OR', + 'ORDER', + 'OUTER', + 'OVER', + 'PERCENT', + 'PLAN', + 'PRECISION', + 'PRIMARY', + 'PRINT', + 'PROC', + 'PROCEDURE', + 'PROCESSADMIN', + 'PUBLIC', + 'PUBLIC', + 'RAISERROR', + 'READ', + 'READTEXT', + 'RECONFIGURE', + 'REFERENCES', + 'REPLICATION', + 'RESTORE', + 'RESTRICT', + 'RETURN', + 'REVOKE', + 'RIGHT', + 'ROLLBACK', + 'ROOT', + 'ROWCOUNT', + 'ROWGUIDCOL', + 'RULE', + 'SA', + 'SAVE', + 'SCHEMA', + 'SECURITYADMIN', + 'SELECT', + 'SERVERADMIN', + 'SESSION_USER', + 'SET', + 'SETUPADMIN', + 'SETUSER', + 'SHUTDOWN', + 'SOME', + 'STATISTICS', + 'SYSADMIN', + 'SYSTEM_USER', + 'TABLE', + 'TEMPDB', + 'TEXTSIZE', + 'THEN', + 'TO', + 'TOP', + 'TRAN', + 'TRANSACTION', + 'TRIGGER', + 'TRUNCATE', + 'TSEQUAL', + 'UNION', + 'UNIQUE', + 'UPDATE', + 'UPDATETEXT', + 'USE', + 'USER', + 'VALUES', + 'VARYING', + 'VIEW', + 'WAITFOR', + 'WHEN', + 'WHERE', + 'WHILE', + 'WITH', + 'WRITETEXT' +] diff --git a/webs/cmp-web/src/views/resource/ctstack/router.js b/webs/cmp-web/src/views/resource/ctstack/router.js index c53e1d2..5d58887 100644 --- a/webs/cmp-web/src/views/resource/ctstack/router.js +++ b/webs/cmp-web/src/views/resource/ctstack/router.js @@ -19,6 +19,6 @@ export default { ctstackAddBareMetal: () => import('views/resource/ctstack/page/bareMetal/addBareMetal.vue'), ctstackBareMetal: () => import('views/resource/ctstack/page/bareMetal/index.vue'), // 数据库 - ctstackRds: () => import('views/resource/ctstack/page/database/rds/index.vue') - // ctstackPgSQL: () => import('views/resource/ctstack/page/database/pgsql/cluster/index.vue') + ctstackMysql: () => import('views/resource/ctstack/page/database/mysql/index.vue'), + ctstackPgSQL: () => import('views/resource/ctstack/page/database/postgresql/index.vue') } diff --git a/webs/cmp-web/src/views/resource/ctstack/services/database/mockData.js b/webs/cmp-web/src/views/resource/ctstack/services/database/mockData.js index a07b0e7..e03e074 100644 --- a/webs/cmp-web/src/views/resource/ctstack/services/database/mockData.js +++ b/webs/cmp-web/src/views/resource/ctstack/services/database/mockData.js @@ -4839,3 +4839,42 @@ export const flavorList = [ lvsSpec: null } ] + +export const storageTypeMap = { + MYSQL: [ + { + name: '高IO', + value: 'SAS' + }, + { + name: '普通IO', + value: 'SATA' + }, + { + name: '超高IO', + value: 'SSD' + } + ], + POSTGRESQL: [ + { + name: '极速型SSD', + value: 'FAST-SSD' + }, + { + name: '通用型SSD', + value: 'SSD-genric' + }, + { + name: '高IO', + value: 'SAS' + }, + { + name: '普通IO', + value: 'SATA' + }, + { + name: '超高IO', + value: 'SSD' + } + ] +} diff --git a/webs/cmp-web/src/views/resource/ctstack/services/database/rds.js b/webs/cmp-web/src/views/resource/ctstack/services/database/rds.js index cde5dbd..ec83f3a 100644 --- a/webs/cmp-web/src/views/resource/ctstack/services/database/rds.js +++ b/webs/cmp-web/src/views/resource/ctstack/services/database/rds.js @@ -1,6 +1,6 @@ import { request } from '@cmp/cmp-element' import { wrapperParams, downloadFile } from 'utils' -import { projectList, zoneList, flavorList } from './mockData' +import { projectList, zoneList, flavorList, storageTypeMap } from './mockData' const url = '/cmp/plugins/ctstack/v1/cloudrds' // 是否开发环境 const isDev = process.env.NODE_ENV === 'development' @@ -23,7 +23,10 @@ export function getRdsZone(params) { if (isDev) return mockRequest(zoneList) return request.get(`${url}/zones`, { params }) } - +export function getStorageType(params) { + const data = storageTypeMap[params.type] + return mockRequest(data) +} export function getFlavor(params) { if (isDev) return mockRequest(flavorList) return request.get(`${url}/flavors`, { params })