mirror of
https://gitee.com/devlive-community/datacap.git
synced 2024-12-03 20:48:44 +08:00
[Core] [Manager] Support some functions (#353)
This commit is contained in:
commit
a0ebb8c084
@ -66,6 +66,10 @@ public class SqlBuilder
|
||||
SelectBuilder.SELECT(applySelectColumns());
|
||||
SelectBuilder.FROM(applyDatabaseAndTable());
|
||||
|
||||
if (StringUtils.isNotEmpty(configure.getWhere())) {
|
||||
SelectBuilder.WHERE(configure.getWhere());
|
||||
}
|
||||
|
||||
if (ObjectUtils.isNotEmpty(configure.getOrders())) {
|
||||
SelectBuilder.ORDER_BY(applyOrderByColumns());
|
||||
}
|
||||
|
@ -19,5 +19,6 @@ public class SqlBody
|
||||
private List<SqlColumn> orders;
|
||||
private int limit = 10;
|
||||
private int offset = 1;
|
||||
private String where;
|
||||
private SqlType type;
|
||||
}
|
||||
|
@ -92,6 +92,8 @@ GROUP BY
|
||||
COLUMN_TYPE', 'Gets the data column classification collection based on the provided database and data table', 'H2',
|
||||
'[{"column":"database","type":"String","expression":"${database:String}"},{"column":"table","type":"String","expression":"${table:String}"}]', TRUE),
|
||||
('FindColumnByDatabaseAndTableAndType', 'SELECT
|
||||
''${database:String}'' AS TABLE_CATALOG,
|
||||
''${table:String}'' AS TABLE_NAME,
|
||||
COLUMN_NAME,
|
||||
COLUMN_TYPE,
|
||||
DATA_TYPE
|
||||
@ -232,6 +234,8 @@ GROUP BY
|
||||
COLUMN_TYPE', 'Gets the data column classification collection based on the provided database and data table', 'MySQL',
|
||||
'[{"column":"database","type":"String","expression":"${database:String}"},{"column":"table","type":"String","expression":"${table:String}"}]', TRUE),
|
||||
('FindColumnByDatabaseAndTableAndType', 'SELECT
|
||||
''${database:String}'' AS TABLE_CATALOG,
|
||||
''${table:String}'' AS TABLE_NAME,
|
||||
COLUMN_NAME,
|
||||
COLUMN_TYPE,
|
||||
DATA_TYPE
|
||||
@ -285,6 +289,8 @@ FROM
|
||||
WHERE
|
||||
COLUMN_TYPE LIKE ''%${type:String}%''
|
||||
GROUP BY
|
||||
TABLE_CATALOG,
|
||||
TABLE_NAME,
|
||||
COLUMN_NAME,
|
||||
COLUMN_TYPE,
|
||||
DATA_TYPE
|
||||
@ -361,6 +367,8 @@ GROUP BY
|
||||
COLUMN_TYPE', 'Gets the data column classification collection based on the provided database and data table', 'ClickHouse',
|
||||
'[{"column":"database","type":"String","expression":"${database:String}"},{"column":"table","type":"String","expression":"${table:String}"}]', TRUE),
|
||||
('FindColumnByDatabaseAndTableAndType', 'SELECT
|
||||
''${database:String}'' AS TABLE_CATALOG,
|
||||
''${table:String}'' AS TABLE_NAME,
|
||||
COLUMN_NAME,
|
||||
COLUMN_TYPE,
|
||||
DATA_TYPE
|
||||
@ -389,6 +397,8 @@ FROM
|
||||
WHERE
|
||||
COLUMN_TYPE LIKE ''%${type:String}%''
|
||||
GROUP BY
|
||||
TABLE_CATALOG,
|
||||
TABLE_NAME,
|
||||
COLUMN_NAME,
|
||||
COLUMN_TYPE,
|
||||
DATA_TYPE
|
||||
|
@ -273,7 +273,7 @@ CREATE TABLE IF NOT EXISTS users
|
||||
TRUNCATE TABLE users;
|
||||
ALTER TABLE users
|
||||
ALTER COLUMN id RESTART WITH 1;
|
||||
INSERT INTO users (username, password, create_time)
|
||||
VALUES ('admin', '$2a$10$ee2yg.Te14GpHppDUROAi.HzYR5Q.q2/5vrZvAr4TFY3J2iT663JG', NULL);
|
||||
INSERT INTO users (username, password, create_time)
|
||||
VALUES ('datacap', '$2a$10$bZ4XBRlYUjKfkBovWT9TuuXlEF7lpRxVrXS8iqyCjCHUqy4RPTL8.', NULL);
|
||||
INSERT INTO users (username, password)
|
||||
VALUES ('admin', '$2a$10$ee2yg.Te14GpHppDUROAi.HzYR5Q.q2/5vrZvAr4TFY3J2iT663JG');
|
||||
INSERT INTO users (username, password)
|
||||
VALUES ('datacap', '$2a$10$bZ4XBRlYUjKfkBovWT9TuuXlEF7lpRxVrXS8iqyCjCHUqy4RPTL8.');
|
||||
|
@ -0,0 +1,405 @@
|
||||
-- --------------------------------
|
||||
-- Update to 1.10.0 --
|
||||
-- --------------------------------
|
||||
/* H2 */
|
||||
INSERT INTO template_sql(name, content, description, plugin, configure, `system`)
|
||||
VALUES ('FindTableTypeByDatabase', 'SELECT
|
||||
CASE
|
||||
INFORMATION_SCHEMA.TABLES.TABLE_TYPE
|
||||
WHEN ''VIEW'' THEN ''view''
|
||||
ELSE ''table''
|
||||
END AS table_type
|
||||
FROM
|
||||
INFORMATION_SCHEMA.TABLES
|
||||
WHERE
|
||||
INFORMATION_SCHEMA.TABLES.TABLE_SCHEMA = ''${database:String}''
|
||||
GROUP BY
|
||||
table_type', 'Finds all table types under the database according to the database', 'H2', '[{"column":"database","type":"String","expression":"${database:String}"}]', TRUE),
|
||||
('FindTableByDatabaseAndType', 'SELECT
|
||||
TABLE_CATALOG,
|
||||
TABLE_NAME
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
TABLE_SCHEMA AS TABLE_CATALOG,
|
||||
TABLE_NAME AS TABLE_NAME
|
||||
FROM
|
||||
INFORMATION_SCHEMA.TABLES
|
||||
WHERE
|
||||
INFORMATION_SCHEMA.TABLES.TABLE_SCHEMA = ''${database:String}''
|
||||
AND CASE
|
||||
INFORMATION_SCHEMA.TABLES.TABLE_TYPE
|
||||
WHEN ''VIEW'' THEN ''view''
|
||||
ELSE ''table''
|
||||
END = ''${type:String}''
|
||||
GROUP BY
|
||||
TABLE_NAME,
|
||||
TABLE_SCHEMA
|
||||
)', 'Gets a collection of related data based on the specified database and data type', 'H2',
|
||||
'[{"column":"database","type":"String","expression":"${database:String}"},{"column":"type","type":"String","expression":"${type:String}"}]', TRUE),
|
||||
('FindColumnTypeByDatabaseAndTable', 'SELECT
|
||||
''${database:String}'' AS TABLE_CATALOG,
|
||||
COLUMN_TYPE
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
CASE
|
||||
WHEN (
|
||||
icl.IS_INDEX = ''Y''
|
||||
AND col.IS_IDENTITY = ''YES''
|
||||
) THEN ''index,primaryKey''
|
||||
WHEN col.IS_IDENTITY = ''YES'' THEN ''primaryKey''
|
||||
WHEN icl.IS_INDEX = ''Y'' THEN ''index''
|
||||
ELSE ''column''
|
||||
END AS COLUMN_TYPE
|
||||
FROM
|
||||
INFORMATION_SCHEMA.COLUMNS col
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
TABLE_SCHEMA,
|
||||
TABLE_NAME,
|
||||
COLUMN_NAME,
|
||||
''Y'' AS IS_KEY
|
||||
FROM
|
||||
INFORMATION_SCHEMA.KEY_COLUMN_USAGE
|
||||
) kcu ON kcu.TABLE_SCHEMA = col.TABLE_SCHEMA
|
||||
AND kcu.TABLE_NAME = col.TABLE_NAME
|
||||
AND kcu.COLUMN_NAME = col.COLUMN_NAME
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ic.TABLE_SCHEMA AS TABLE_SCHEMA,
|
||||
ic.TABLE_NAME AS TABLE_NAME,
|
||||
ic.COLUMN_NAME AS COLUMN_NAME,
|
||||
''Y'' AS IS_INDEX
|
||||
FROM
|
||||
INFORMATION_SCHEMA.INDEXES i,
|
||||
INFORMATION_SCHEMA.INDEX_COLUMNS ic
|
||||
WHERE
|
||||
i.INDEX_NAME = ic.INDEX_NAME
|
||||
) icl ON icl.TABLE_SCHEMA = col.TABLE_SCHEMA
|
||||
AND icl.TABLE_NAME = col.TABLE_NAME
|
||||
AND icl.COLUMN_NAME = col.COLUMN_NAME
|
||||
WHERE
|
||||
col.TABLE_SCHEMA = ''${database:String}''
|
||||
AND col.TABLE_NAME = ''${table:String}''
|
||||
ORDER BY
|
||||
col.COLUMN_NAME
|
||||
)
|
||||
GROUP BY
|
||||
COLUMN_TYPE', 'Gets the data column classification collection based on the provided database and data table', 'H2',
|
||||
'[{"column":"database","type":"String","expression":"${database:String}"},{"column":"table","type":"String","expression":"${table:String}"}]', TRUE),
|
||||
('FindColumnByDatabaseAndTableAndType', 'SELECT
|
||||
''${database:String}'' AS TABLE_CATALOG,
|
||||
''${table:String}'' AS TABLE_NAME,
|
||||
COLUMN_NAME,
|
||||
COLUMN_TYPE,
|
||||
DATA_TYPE
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
col.COLUMN_NAME AS COLUMN_NAME,
|
||||
col.DATA_TYPE AS DATA_TYPE,
|
||||
CASE
|
||||
WHEN (
|
||||
icl.IS_INDEX = ''Y''
|
||||
AND col.IS_IDENTITY = ''YES''
|
||||
) THEN ''index,primaryKey''
|
||||
WHEN col.IS_IDENTITY = ''YES'' THEN ''primaryKey''
|
||||
WHEN icl.IS_INDEX = ''Y'' THEN ''index''
|
||||
ELSE ''column''
|
||||
END AS COLUMN_TYPE
|
||||
FROM
|
||||
INFORMATION_SCHEMA.COLUMNS col
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
TABLE_SCHEMA,
|
||||
TABLE_NAME,
|
||||
COLUMN_NAME,
|
||||
''Y'' AS IS_KEY
|
||||
FROM
|
||||
INFORMATION_SCHEMA.KEY_COLUMN_USAGE
|
||||
) kcu ON kcu.TABLE_SCHEMA = col.TABLE_SCHEMA
|
||||
AND kcu.TABLE_NAME = col.TABLE_NAME
|
||||
AND kcu.COLUMN_NAME = col.COLUMN_NAME
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ic.TABLE_SCHEMA AS TABLE_SCHEMA,
|
||||
ic.TABLE_NAME AS TABLE_NAME,
|
||||
ic.COLUMN_NAME AS COLUMN_NAME,
|
||||
''Y'' AS IS_INDEX
|
||||
FROM
|
||||
INFORMATION_SCHEMA.INDEXES i,
|
||||
INFORMATION_SCHEMA.INDEX_COLUMNS ic
|
||||
WHERE
|
||||
i.INDEX_NAME = ic.INDEX_NAME
|
||||
) icl ON icl.TABLE_SCHEMA = col.TABLE_SCHEMA
|
||||
AND icl.TABLE_NAME = col.TABLE_NAME
|
||||
AND icl.COLUMN_NAME = col.COLUMN_NAME
|
||||
WHERE
|
||||
col.TABLE_SCHEMA = ''${database:String}''
|
||||
AND col.TABLE_NAME = ''${table:String}''
|
||||
ORDER BY
|
||||
col.COLUMN_NAME
|
||||
)
|
||||
WHERE
|
||||
COLUMN_TYPE LIKE ''%${type:String}%''
|
||||
GROUP BY
|
||||
COLUMN_NAME
|
||||
ORDER BY
|
||||
COLUMN_NAME', 'Gets a collection of related data based on the specified database, table, and data type', 'H2',
|
||||
'[{"column":"database","type":"String","expression":"${database:String}"},{"column":"table","type":"String","expression":"${table:String}"},{"column":"type","type":"String","expression":"${type:String}"}]',
|
||||
TRUE);
|
||||
/* MySQL */
|
||||
INSERT INTO template_sql(name, content, description, plugin, configure, `system`)
|
||||
VALUES ('FindTableTypeByDatabase', 'SELECT
|
||||
CASE
|
||||
INFORMATION_SCHEMA.TABLES.TABLE_TYPE
|
||||
WHEN ''VIEW'' THEN ''view''
|
||||
ELSE ''table''
|
||||
END AS table_type
|
||||
FROM
|
||||
INFORMATION_SCHEMA.TABLES
|
||||
WHERE
|
||||
INFORMATION_SCHEMA.TABLES.TABLE_SCHEMA = ''${database:String}''
|
||||
GROUP BY
|
||||
table_type', 'Finds all table types under the database according to the database', 'MySQL', '[{"column":"database","type":"String","expression":"${database:String}"}]', TRUE),
|
||||
('FindTableByDatabaseAndType', 'SELECT
|
||||
TABLE_SCHEMA AS TABLE_CATALOG,
|
||||
TABLE_NAME AS TABLE_NAME
|
||||
FROM
|
||||
INFORMATION_SCHEMA.TABLES
|
||||
WHERE
|
||||
INFORMATION_SCHEMA.TABLES.TABLE_SCHEMA = ''${database:String}''
|
||||
AND CASE
|
||||
INFORMATION_SCHEMA.TABLES.TABLE_TYPE
|
||||
WHEN ''VIEW'' THEN ''view''
|
||||
ELSE ''table''
|
||||
END = ''${type:String}''
|
||||
GROUP BY
|
||||
TABLE_NAME,
|
||||
TABLE_SCHEMA', 'Gets a collection of related data based on the specified database and data type', 'MySQL',
|
||||
'[{"column":"database","type":"String","expression":"${database:String}"},{"column":"type","type":"String","expression":"${type:String}"}]', TRUE),
|
||||
('FindColumnTypeByDatabaseAndTable', 'SELECT
|
||||
''${database:String}'' AS TABLE_CATALOG,
|
||||
COLUMN_TYPE
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
CASE
|
||||
WHEN (
|
||||
icl.IS_INDEX = ''Y''
|
||||
AND col.COLUMN_KEY = ''PRI''
|
||||
) THEN ''index,primaryKey''
|
||||
WHEN col.COLUMN_KEY = ''PRI'' THEN ''primaryKey''
|
||||
WHEN icl.IS_INDEX = ''Y'' THEN ''index''
|
||||
ELSE ''column''
|
||||
END AS COLUMN_TYPE
|
||||
FROM
|
||||
INFORMATION_SCHEMA.COLUMNS col
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
TABLE_SCHEMA,
|
||||
TABLE_NAME,
|
||||
COLUMN_NAME,
|
||||
''Y'' AS IS_KEY
|
||||
FROM
|
||||
INFORMATION_SCHEMA.KEY_COLUMN_USAGE
|
||||
) kcu ON kcu.TABLE_SCHEMA = col.TABLE_SCHEMA
|
||||
AND kcu.TABLE_NAME = col.TABLE_NAME
|
||||
AND kcu.COLUMN_NAME = col.COLUMN_NAME
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
TABLE_SCHEMA AS TABLE_SCHEMA,
|
||||
TABLE_NAME AS TABLE_NAME,
|
||||
COLUMN_NAME AS COLUMN_NAME,
|
||||
''Y'' AS IS_INDEX
|
||||
FROM
|
||||
INFORMATION_SCHEMA.`STATISTICS`
|
||||
WHERE
|
||||
TABLE_CATALOG = ''${database:String}''
|
||||
AND TABLE_NAME = ''${table:String}''
|
||||
) icl ON icl.TABLE_SCHEMA = col.TABLE_SCHEMA
|
||||
AND icl.TABLE_NAME = col.TABLE_NAME
|
||||
AND icl.COLUMN_NAME = col.COLUMN_NAME
|
||||
WHERE
|
||||
col.TABLE_SCHEMA = ''${database:String}''
|
||||
AND col.TABLE_NAME = ''${table:String}''
|
||||
ORDER BY
|
||||
col.COLUMN_NAME
|
||||
) AS tmp
|
||||
GROUP BY
|
||||
COLUMN_TYPE', 'Gets the data column classification collection based on the provided database and data table', 'MySQL',
|
||||
'[{"column":"database","type":"String","expression":"${database:String}"},{"column":"table","type":"String","expression":"${table:String}"}]', TRUE),
|
||||
('FindColumnByDatabaseAndTableAndType', 'SELECT
|
||||
''${database:String}'' AS TABLE_CATALOG,
|
||||
''${table:String}'' AS TABLE_NAME,
|
||||
COLUMN_NAME,
|
||||
COLUMN_TYPE,
|
||||
DATA_TYPE
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
col.COLUMN_NAME AS COLUMN_NAME,
|
||||
col.DATA_TYPE AS DATA_TYPE,
|
||||
CASE
|
||||
WHEN (
|
||||
icl.IS_INDEX = ''Y''
|
||||
AND col.COLUMN_KEY = ''PRI''
|
||||
) THEN ''index,primaryKey''
|
||||
WHEN col.COLUMN_KEY = ''PRI'' THEN ''primaryKey''
|
||||
WHEN icl.IS_INDEX = ''Y'' THEN ''index''
|
||||
ELSE ''column''
|
||||
END AS COLUMN_TYPE
|
||||
FROM
|
||||
INFORMATION_SCHEMA.COLUMNS col
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
TABLE_SCHEMA,
|
||||
TABLE_NAME,
|
||||
COLUMN_NAME,
|
||||
''Y'' AS IS_KEY
|
||||
FROM
|
||||
INFORMATION_SCHEMA.KEY_COLUMN_USAGE
|
||||
) kcu ON kcu.TABLE_SCHEMA = col.TABLE_SCHEMA
|
||||
AND kcu.TABLE_NAME = col.TABLE_NAME
|
||||
AND kcu.COLUMN_NAME = col.COLUMN_NAME
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
TABLE_SCHEMA AS TABLE_SCHEMA,
|
||||
TABLE_NAME AS TABLE_NAME,
|
||||
COLUMN_NAME AS COLUMN_NAME,
|
||||
''Y'' AS IS_INDEX
|
||||
FROM
|
||||
INFORMATION_SCHEMA.`STATISTICS`
|
||||
WHERE
|
||||
TABLE_CATALOG = ''${database:String}''
|
||||
AND TABLE_NAME = ''${table:String}''
|
||||
) icl ON icl.TABLE_SCHEMA = col.TABLE_SCHEMA
|
||||
AND icl.TABLE_NAME = col.TABLE_NAME
|
||||
AND icl.COLUMN_NAME = col.COLUMN_NAME
|
||||
WHERE
|
||||
col.TABLE_SCHEMA = ''${database:String}''
|
||||
AND col.TABLE_NAME = ''${table:String}''
|
||||
ORDER BY
|
||||
col.COLUMN_NAME
|
||||
) AS tmp
|
||||
WHERE
|
||||
COLUMN_TYPE LIKE ''%${type:String}%''
|
||||
GROUP BY
|
||||
TABLE_CATALOG,
|
||||
TABLE_NAME,
|
||||
COLUMN_NAME,
|
||||
COLUMN_TYPE,
|
||||
DATA_TYPE
|
||||
ORDER BY
|
||||
COLUMN_NAME', 'Gets a collection of related data based on the specified database, table, and data type', 'MySQL',
|
||||
'[{"column":"database","type":"String","expression":"${database:String}"},{"column":"table","type":"String","expression":"${table:String}"},{"column":"type","type":"String","expression":"${type:String}"}]',
|
||||
TRUE);
|
||||
/* ClickHouse */
|
||||
INSERT INTO template_sql(name, content, description, plugin, configure, `system`)
|
||||
VALUES ('FindTableTypeByDatabase', 'SELECT
|
||||
multiIf(
|
||||
startsWith(engine, ''System''),
|
||||
''system'',
|
||||
endsWith(engine, ''View''),
|
||||
''view'',
|
||||
startsWith(engine, ''Kafka''),
|
||||
''kafka'',
|
||||
endsWith(engine, ''Log''),
|
||||
''log'',
|
||||
''table''
|
||||
) AS TABLE_TYPE
|
||||
FROM
|
||||
system.tables
|
||||
WHERE
|
||||
database = ''${database:String}''
|
||||
GROUP BY
|
||||
TABLE_TYPE', 'Finds all table types under the database according to the database', 'ClickHouse', '[{"column":"database","type":"String","expression":"${database:String}"}]', TRUE),
|
||||
('FindTableByDatabaseAndType', 'SELECT
|
||||
`database` AS TABLE_CATALOG,
|
||||
name AS TABLE_NAME
|
||||
FROM
|
||||
system.tables
|
||||
WHERE
|
||||
`database` = ''${database:String}''
|
||||
AND multiIf(
|
||||
startsWith(engine, ''System''),
|
||||
''system'',
|
||||
endsWith(engine, ''View''),
|
||||
''view'',
|
||||
startsWith(engine, ''Kafka''),
|
||||
''kafka'',
|
||||
endsWith(engine, ''Log''),
|
||||
''log'',
|
||||
''table''
|
||||
) = ''${type:String}''
|
||||
GROUP BY
|
||||
TABLE_NAME,
|
||||
`database`', 'Gets a collection of related data based on the specified database and data type', 'ClickHouse',
|
||||
'[{"column":"database","type":"String","expression":"${database:String}"},{"column":"type","type":"String","expression":"${type:String}"}]', TRUE),
|
||||
('FindColumnTypeByDatabaseAndTable', 'SELECT
|
||||
''${database:String}'' AS TABLE_CATALOG,
|
||||
COLUMN_TYPE
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
CASE
|
||||
WHEN (
|
||||
is_in_primary_key = ''1''
|
||||
AND is_in_partition_key = ''1''
|
||||
) THEN ''index,primaryKey''
|
||||
WHEN is_in_primary_key = ''1'' THEN ''primaryKey''
|
||||
WHEN is_in_primary_key = ''1'' THEN ''index''
|
||||
ELSE ''column''
|
||||
END AS COLUMN_TYPE
|
||||
FROM
|
||||
system.columns col
|
||||
WHERE
|
||||
`database` = ''${database:String}''
|
||||
AND `table` = ''${table:String}''
|
||||
ORDER BY
|
||||
`name`
|
||||
) AS tmp
|
||||
GROUP BY
|
||||
COLUMN_TYPE', 'Gets the data column classification collection based on the provided database and data table', 'ClickHouse',
|
||||
'[{"column":"database","type":"String","expression":"${database:String}"},{"column":"table","type":"String","expression":"${table:String}"}]', TRUE),
|
||||
('FindColumnByDatabaseAndTableAndType', 'SELECT
|
||||
''${database:String}'' AS TABLE_CATALOG,
|
||||
''${table:String}'' AS TABLE_NAME,
|
||||
COLUMN_NAME,
|
||||
COLUMN_TYPE,
|
||||
DATA_TYPE
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
`name` AS COLUMN_NAME,
|
||||
`type` AS DATA_TYPE,
|
||||
CASE
|
||||
WHEN (
|
||||
is_in_primary_key = ''1''
|
||||
AND is_in_partition_key = ''1''
|
||||
) THEN ''index,primaryKey''
|
||||
WHEN is_in_primary_key = ''1'' THEN ''primaryKey''
|
||||
WHEN is_in_primary_key = ''1'' THEN ''index''
|
||||
ELSE ''column''
|
||||
END AS COLUMN_TYPE
|
||||
FROM
|
||||
system.columns col
|
||||
WHERE
|
||||
`database` = ''${database:String}''
|
||||
AND `table` = ''${table:String}''
|
||||
ORDER BY
|
||||
`name`
|
||||
) AS tmp
|
||||
WHERE
|
||||
COLUMN_TYPE LIKE ''%${type:String}%''
|
||||
GROUP BY
|
||||
TABLE_CATALOG,
|
||||
TABLE_NAME,
|
||||
COLUMN_NAME,
|
||||
COLUMN_TYPE,
|
||||
DATA_TYPE
|
||||
ORDER BY
|
||||
COLUMN_NAME', 'Gets a collection of related data based on the specified database, table, and data type', 'ClickHouse',
|
||||
'[{"column":"database","type":"String","expression":"${database:String}"},{"column":"table","type":"String","expression":"${table:String}"},{"column":"type","type":"String","expression":"${type:String}"}]',
|
||||
TRUE);
|
@ -280,11 +280,11 @@ create table datacap.users
|
||||
third_configure text null
|
||||
);
|
||||
|
||||
INSERT INTO datacap.users (username, password, create_time)
|
||||
VALUES ('admin', '$2a$10$ee2yg.Te14GpHppDUROAi.HzYR5Q.q2/5vrZvAr4TFY3J2iT663JG', null);
|
||||
INSERT INTO datacap.users (username, password)
|
||||
VALUES ('admin', '$2a$10$ee2yg.Te14GpHppDUROAi.HzYR5Q.q2/5vrZvAr4TFY3J2iT663JG');
|
||||
|
||||
INSERT INTO datacap.users (username, password, create_time)
|
||||
VALUES ('datacap', '$2a$10$bZ4XBRlYUjKfkBovWT9TuuXlEF7lpRxVrXS8iqyCjCHUqy4RPTL8.', null);
|
||||
INSERT INTO datacap.users (username, password)
|
||||
VALUES ('datacap', '$2a$10$bZ4XBRlYUjKfkBovWT9TuuXlEF7lpRxVrXS8iqyCjCHUqy4RPTL8.');
|
||||
|
||||
-- --------------------------------
|
||||
-- Update to 1.10.0 --
|
||||
@ -377,6 +377,8 @@ GROUP BY
|
||||
COLUMN_TYPE', 'Gets the data column classification collection based on the provided database and data table', 'H2',
|
||||
'[{"column":"database","type":"String","expression":"${database:String}"},{"column":"table","type":"String","expression":"${table:String}"}]', TRUE),
|
||||
('FindColumnByDatabaseAndTableAndType', 'SELECT
|
||||
''${database:String}'' AS TABLE_CATALOG,
|
||||
''${table:String}'' AS TABLE_NAME,
|
||||
COLUMN_NAME,
|
||||
COLUMN_TYPE,
|
||||
DATA_TYPE
|
||||
@ -517,6 +519,8 @@ GROUP BY
|
||||
COLUMN_TYPE', 'Gets the data column classification collection based on the provided database and data table', 'MySQL',
|
||||
'[{"column":"database","type":"String","expression":"${database:String}"},{"column":"table","type":"String","expression":"${table:String}"}]', TRUE),
|
||||
('FindColumnByDatabaseAndTableAndType', 'SELECT
|
||||
''${database:String}'' AS TABLE_CATALOG,
|
||||
''${table:String}'' AS TABLE_NAME,
|
||||
COLUMN_NAME,
|
||||
COLUMN_TYPE,
|
||||
DATA_TYPE
|
||||
@ -570,6 +574,8 @@ FROM
|
||||
WHERE
|
||||
COLUMN_TYPE LIKE ''%${type:String}%''
|
||||
GROUP BY
|
||||
TABLE_CATALOG,
|
||||
TABLE_NAME,
|
||||
COLUMN_NAME,
|
||||
COLUMN_TYPE,
|
||||
DATA_TYPE
|
||||
@ -646,6 +652,8 @@ GROUP BY
|
||||
COLUMN_TYPE', 'Gets the data column classification collection based on the provided database and data table', 'ClickHouse',
|
||||
'[{"column":"database","type":"String","expression":"${database:String}"},{"column":"table","type":"String","expression":"${table:String}"}]', TRUE),
|
||||
('FindColumnByDatabaseAndTableAndType', 'SELECT
|
||||
''${database:String}'' AS TABLE_CATALOG,
|
||||
''${table:String}'' AS TABLE_NAME,
|
||||
COLUMN_NAME,
|
||||
COLUMN_TYPE,
|
||||
DATA_TYPE
|
||||
@ -674,6 +682,8 @@ FROM
|
||||
WHERE
|
||||
COLUMN_TYPE LIKE ''%${type:String}%''
|
||||
GROUP BY
|
||||
TABLE_CATALOG,
|
||||
TABLE_NAME,
|
||||
COLUMN_NAME,
|
||||
COLUMN_TYPE,
|
||||
DATA_TYPE
|
||||
|
@ -10,6 +10,9 @@
|
||||
"lint": "vue-cli-service lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fortawesome/fontawesome-svg-core": "^6.4.0",
|
||||
"@fortawesome/free-solid-svg-icons": "^6.4.0",
|
||||
"@fortawesome/vue-fontawesome": "^3.0.0-5",
|
||||
"@types/nprogress": "^0.2.0",
|
||||
"@types/watermark-dom": "^2.3.1",
|
||||
"ag-grid-community": "^29.3.5",
|
||||
|
@ -1,3 +1,4 @@
|
||||
export default {
|
||||
copyWithHeaders: 'Copy with headers',
|
||||
copyWithHeadersRow: 'Copy with headers (Row)',
|
||||
copyDataOnlyRow: 'Copy data (Row)',
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
export default {
|
||||
copyWithHeaders: '带标题复制',
|
||||
copyWithHeadersRow: '带标题复制 (行)',
|
||||
copyDataOnlyRow: '复制数据 (行)',
|
||||
}
|
||||
|
@ -5,8 +5,13 @@ import router from "./router";
|
||||
import ViewUIPlus from 'view-ui-plus';
|
||||
import 'view-ui-plus/dist/styles/viewuiplus.css';
|
||||
|
||||
import {library} from '@fortawesome/fontawesome-svg-core';
|
||||
import {faFilter} from '@fortawesome/free-solid-svg-icons';
|
||||
import {FontAwesomeIcon} from '@fortawesome/vue-fontawesome';
|
||||
import i18n from "@/i18n/I18n";
|
||||
|
||||
library.add(faFilter);
|
||||
|
||||
const app = createApp(App);
|
||||
|
||||
// Disable warnings
|
||||
@ -14,4 +19,5 @@ app.config.warnHandler = () => null;
|
||||
app.use(router);
|
||||
app.use(ViewUIPlus);
|
||||
app.use(i18n);
|
||||
app.component("FontAwesomeIcon", FontAwesomeIcon);
|
||||
app.mount("#app");
|
||||
|
@ -10,6 +10,7 @@ export class SqlBody
|
||||
limit = 10;
|
||||
offset = 1;
|
||||
type: SqlType = SqlType.SELECT;
|
||||
where: string;
|
||||
|
||||
constructor(builder: SqlBodyBuilder)
|
||||
{
|
||||
@ -20,6 +21,7 @@ export class SqlBody
|
||||
this.limit = builder.limit;
|
||||
this.offset = builder.offset;
|
||||
this.type = builder.type;
|
||||
this.where = builder.where;
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,6 +34,7 @@ export class SqlBodyBuilder
|
||||
private _limit = 10;
|
||||
private _offset = 1;
|
||||
private _type: SqlType = SqlType.SELECT;
|
||||
private _where: string;
|
||||
|
||||
constructor(database: string, table: string)
|
||||
{
|
||||
@ -69,6 +72,12 @@ export class SqlBodyBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
setWhere(where: string)
|
||||
{
|
||||
this._where = where;
|
||||
return this;
|
||||
}
|
||||
|
||||
get database()
|
||||
{
|
||||
return this._database;
|
||||
@ -104,6 +113,11 @@ export class SqlBodyBuilder
|
||||
return this._type;
|
||||
}
|
||||
|
||||
get where()
|
||||
{
|
||||
return this._where;
|
||||
}
|
||||
|
||||
build()
|
||||
{
|
||||
return new SqlBody(this);
|
||||
|
@ -4,7 +4,9 @@ export class Sql
|
||||
{
|
||||
database: string;
|
||||
table: string;
|
||||
columns: Array<string> = [];
|
||||
limit = 15;
|
||||
offset = 1;
|
||||
sort: Array<Sort>;
|
||||
where: string;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ const routes: Array<RouteRecordRaw> = [
|
||||
meta: {
|
||||
roles: ['Admin', 'User']
|
||||
},
|
||||
component: () => import("../views/pages/dashboard/DashboardConsole.vue")
|
||||
component: () => import("@/views/user/dashboard/DashboardConsole.vue")
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -11,158 +11,164 @@ import {SqlOrder} from "@/model/builder/SqlOrder";
|
||||
|
||||
class ManagerService
|
||||
{
|
||||
getDatabases(id: number): Promise<ResponseModel>
|
||||
{
|
||||
const configure: SqlBody = {
|
||||
configure: undefined,
|
||||
sourceId: id,
|
||||
templateName: 'getAllDatabase'
|
||||
};
|
||||
return TemplateSqlService.execute(configure);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds all table types under the database according to the database
|
||||
* Template: FindTableTypeByDatabase
|
||||
* @param id The selected data source tag, which is stored in the database
|
||||
* @param database The query database name
|
||||
*/
|
||||
findTableTypeByDatabase(id: number, database: string): Promise<ResponseModel>
|
||||
{
|
||||
const configure: SqlBody = {
|
||||
configure: {
|
||||
database: database
|
||||
},
|
||||
sourceId: id,
|
||||
templateName: 'FindTableTypeByDatabase'
|
||||
};
|
||||
return TemplateSqlService.execute(configure);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a collection of related data based on the specified database and data type
|
||||
* Template: FindTableByDatabaseAndType
|
||||
* @param id The selected data source tag, which is stored in the database
|
||||
* @param database The query database name
|
||||
* @param type The query table type
|
||||
*/
|
||||
getTableDataByDatabaseAndType(id: number, database: string, type: string): Promise<ResponseModel>
|
||||
{
|
||||
const configure: SqlBody = {
|
||||
configure: {
|
||||
database: database,
|
||||
type: type
|
||||
},
|
||||
sourceId: id,
|
||||
templateName: 'FindTableByDatabaseAndType'
|
||||
};
|
||||
return TemplateSqlService.execute(configure);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data column classification collection based on the provided database and data table
|
||||
* Template: FindColumnTypeByDatabaseAndTable
|
||||
* @param id The selected data source tag, which is stored in the database
|
||||
* @param database The query database name
|
||||
* @param table The query table name
|
||||
*/
|
||||
findColumnTypeByDatabaseAndTable(id: number, database: string, table: string): Promise<ResponseModel>
|
||||
{
|
||||
const configure: SqlBody = {
|
||||
configure: {
|
||||
database: database,
|
||||
table: table
|
||||
},
|
||||
sourceId: id,
|
||||
templateName: 'FindColumnTypeByDatabaseAndTable'
|
||||
};
|
||||
return TemplateSqlService.execute(configure);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a collection of related data based on the specified database, table, and data type
|
||||
* Template: FindColumnByDatabaseAndTableAndType
|
||||
* @param id The selected data source tag, which is stored in the database
|
||||
* @param database The query database name
|
||||
* @param table The query table name
|
||||
* @param type The query table type
|
||||
*/
|
||||
getColumnDataByDatabaseAndTableAndType(id: number, database: string, table: string, type: string): Promise<ResponseModel>
|
||||
{
|
||||
const configure: SqlBody = {
|
||||
configure: {
|
||||
database: database,
|
||||
table: table,
|
||||
type: type
|
||||
},
|
||||
sourceId: id,
|
||||
templateName: 'FindColumnByDatabaseAndTableAndType'
|
||||
};
|
||||
return TemplateSqlService.execute(configure);
|
||||
}
|
||||
|
||||
getTables(id: number, database: string): Promise<ResponseModel>
|
||||
{
|
||||
const configure: SqlBody = {
|
||||
configure: {
|
||||
database: database
|
||||
},
|
||||
sourceId: id,
|
||||
templateName: 'getAllTablesFromDatabase'
|
||||
};
|
||||
return TemplateSqlService.execute(configure);
|
||||
}
|
||||
|
||||
getColumns(id: number, database: string, table): Promise<ResponseModel>
|
||||
{
|
||||
const configure: SqlBody = {
|
||||
configure: {
|
||||
table: database + '.' + table
|
||||
},
|
||||
sourceId: id,
|
||||
templateName: 'getAllColumnsFromDatabaseAndTable'
|
||||
};
|
||||
return TemplateSqlService.execute(configure);
|
||||
}
|
||||
|
||||
getData(id: number, database: string, table: string, page: number, size: number): Promise<ResponseModel>
|
||||
{
|
||||
const configure: SqlBody = {
|
||||
configure: {
|
||||
table: database + '.' + table,
|
||||
page: page,
|
||||
size: size
|
||||
},
|
||||
sourceId: id,
|
||||
templateName: 'getDataFromDatabaseAndTableLimited'
|
||||
};
|
||||
return TemplateSqlService.execute(configure);
|
||||
}
|
||||
|
||||
getDataByConfigure(id: string, sql: Sql): Promise<ResponseModel>
|
||||
{
|
||||
const columns: SqlColumn[] = new Array<SqlColumn>();
|
||||
columns.push(new SqlColumnBuilder('*').build());
|
||||
// The default offset is 1, and the database index defaults to 0, which needs to be subtracted by 1
|
||||
const orders: SqlColumn[] = new Array();
|
||||
if (sql.sort) {
|
||||
sql.sort.forEach(order => {
|
||||
orders.push(new SqlColumnBuilder(order.column).setOrder(SqlOrder[order.sort.toUpperCase()]).build());
|
||||
});
|
||||
getDatabases(id: number): Promise<ResponseModel>
|
||||
{
|
||||
const configure: SqlBody = {
|
||||
configure: undefined,
|
||||
sourceId: id,
|
||||
templateName: 'getAllDatabase'
|
||||
};
|
||||
return TemplateSqlService.execute(configure);
|
||||
}
|
||||
|
||||
const sqlBody = new SqlBodyBuilder(sql.database, sql.table)
|
||||
.setColumns(columns)
|
||||
.setOrders(orders)
|
||||
.setType(SqlType.SELECT)
|
||||
.setLimit(sql.limit)
|
||||
.setOffset(sql.offset - 1)
|
||||
.build();
|
||||
const configure = new ExecuteDslBodyBuilder(id, 'JSON')
|
||||
.setConfigure(sqlBody)
|
||||
.build();
|
||||
return new ExecuteService().executeDsl(configure);
|
||||
}
|
||||
/**
|
||||
* Finds all table types under the database according to the database
|
||||
* Template: FindTableTypeByDatabase
|
||||
* @param id The selected data source tag, which is stored in the database
|
||||
* @param database The query database name
|
||||
*/
|
||||
findTableTypeByDatabase(id: number, database: string): Promise<ResponseModel>
|
||||
{
|
||||
const configure: SqlBody = {
|
||||
configure: {
|
||||
database: database
|
||||
},
|
||||
sourceId: id,
|
||||
templateName: 'FindTableTypeByDatabase'
|
||||
};
|
||||
return TemplateSqlService.execute(configure);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a collection of related data based on the specified database and data type
|
||||
* Template: FindTableByDatabaseAndType
|
||||
* @param id The selected data source tag, which is stored in the database
|
||||
* @param database The query database name
|
||||
* @param type The query table type
|
||||
*/
|
||||
getTableDataByDatabaseAndType(id: number, database: string, type: string): Promise<ResponseModel>
|
||||
{
|
||||
const configure: SqlBody = {
|
||||
configure: {
|
||||
database: database,
|
||||
type: type
|
||||
},
|
||||
sourceId: id,
|
||||
templateName: 'FindTableByDatabaseAndType'
|
||||
};
|
||||
return TemplateSqlService.execute(configure);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data column classification collection based on the provided database and data table
|
||||
* Template: FindColumnTypeByDatabaseAndTable
|
||||
* @param id The selected data source tag, which is stored in the database
|
||||
* @param database The query database name
|
||||
* @param table The query table name
|
||||
*/
|
||||
findColumnTypeByDatabaseAndTable(id: number, database: string, table: string): Promise<ResponseModel>
|
||||
{
|
||||
const configure: SqlBody = {
|
||||
configure: {
|
||||
database: database,
|
||||
table: table
|
||||
},
|
||||
sourceId: id,
|
||||
templateName: 'FindColumnTypeByDatabaseAndTable'
|
||||
};
|
||||
return TemplateSqlService.execute(configure);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a collection of related data based on the specified database, table, and data type
|
||||
* Template: FindColumnByDatabaseAndTableAndType
|
||||
* @param id The selected data source tag, which is stored in the database
|
||||
* @param database The query database name
|
||||
* @param table The query table name
|
||||
* @param type The query table type
|
||||
*/
|
||||
getColumnDataByDatabaseAndTableAndType(id: number, database: string, table: string, type: string): Promise<ResponseModel>
|
||||
{
|
||||
const configure: SqlBody = {
|
||||
configure: {
|
||||
database: database,
|
||||
table: table,
|
||||
type: type
|
||||
},
|
||||
sourceId: id,
|
||||
templateName: 'FindColumnByDatabaseAndTableAndType'
|
||||
};
|
||||
return TemplateSqlService.execute(configure);
|
||||
}
|
||||
|
||||
getTables(id: number, database: string): Promise<ResponseModel>
|
||||
{
|
||||
const configure: SqlBody = {
|
||||
configure: {
|
||||
database: database
|
||||
},
|
||||
sourceId: id,
|
||||
templateName: 'getAllTablesFromDatabase'
|
||||
};
|
||||
return TemplateSqlService.execute(configure);
|
||||
}
|
||||
|
||||
getColumns(id: number, database: string, table): Promise<ResponseModel>
|
||||
{
|
||||
const configure: SqlBody = {
|
||||
configure: {
|
||||
table: database + '.' + table
|
||||
},
|
||||
sourceId: id,
|
||||
templateName: 'getAllColumnsFromDatabaseAndTable'
|
||||
};
|
||||
return TemplateSqlService.execute(configure);
|
||||
}
|
||||
|
||||
getData(id: number, database: string, table: string, page: number, size: number): Promise<ResponseModel>
|
||||
{
|
||||
const configure: SqlBody = {
|
||||
configure: {
|
||||
table: database + '.' + table,
|
||||
page: page,
|
||||
size: size
|
||||
},
|
||||
sourceId: id,
|
||||
templateName: 'getDataFromDatabaseAndTableLimited'
|
||||
};
|
||||
return TemplateSqlService.execute(configure);
|
||||
}
|
||||
|
||||
getDataByConfigure(id: string, sql: Sql): Promise<ResponseModel>
|
||||
{
|
||||
const columns: SqlColumn[] = new Array<SqlColumn>();
|
||||
if (sql.columns.length > 0) {
|
||||
sql.columns.forEach(column => columns.push(new SqlColumnBuilder(column).build()));
|
||||
}
|
||||
else {
|
||||
columns.push(new SqlColumnBuilder('*').build());
|
||||
}
|
||||
// The default offset is 1, and the database index defaults to 0, which needs to be subtracted by 1
|
||||
const orders: SqlColumn[] = new Array();
|
||||
if (sql.sort) {
|
||||
sql.sort.forEach(order => {
|
||||
orders.push(new SqlColumnBuilder(order.column).setOrder(SqlOrder[order.sort.toUpperCase()]).build());
|
||||
});
|
||||
}
|
||||
|
||||
const sqlBody = new SqlBodyBuilder(sql.database, sql.table)
|
||||
.setColumns(columns)
|
||||
.setOrders(orders)
|
||||
.setType(SqlType.SELECT)
|
||||
.setLimit(sql.limit)
|
||||
.setOffset(sql.offset - 1)
|
||||
.setWhere(sql.where)
|
||||
.build();
|
||||
const configure = new ExecuteDslBodyBuilder(id, 'JSON')
|
||||
.setConfigure(sqlBody)
|
||||
.build();
|
||||
return new ExecuteService().executeDsl(configure);
|
||||
}
|
||||
}
|
||||
|
||||
export default new ManagerService();
|
||||
|
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div style="padding: 0">
|
||||
<SourceNotSupported v-if="!isSupported" :templateName="templateArray" style="margin-top: 50px;"></SourceNotSupported>
|
||||
<div ref="splitContainer" class="split-container">
|
||||
<div v-else ref="splitContainer" class="split-container">
|
||||
<Split v-model="splitModel" :min="0.15">
|
||||
<template #left>
|
||||
<div ref="splitContainerLeftPane" class="split-container-pane">
|
||||
@ -39,7 +39,7 @@
|
||||
</template>
|
||||
</Result>
|
||||
</Card>
|
||||
<div v-if="isShowData && !dataLoading">
|
||||
<div v-if="isShowData && !dataLoading && tableConfigure">
|
||||
<!-- Paging related components -->
|
||||
<div style="margin: 3px 0px 3px 10px;">
|
||||
<Space>
|
||||
@ -57,15 +57,19 @@
|
||||
<Tooltip content="DDL">
|
||||
<Button size="small" icon="md-eye" type="text" shape="circle" @click="handlerControlModal(false)"></Button>
|
||||
</Tooltip>
|
||||
<Dropdown v-if="selectedRows.length > 0">
|
||||
<Dropdown v-if="selectedRows.length > 0" placement="bottom-start">
|
||||
<Button style="margin-top: -8px;" size="small" type="text" icon="ios-download">
|
||||
[<span style="font-size: 12px; color: #19BE6B; font-weight: bold;">{{ selectedRows.length }}</span>]
|
||||
</Button>
|
||||
<template #list>
|
||||
<DropdownMenu>
|
||||
<DropdownItem @click="handlerCopyWithHeaders">
|
||||
<DropdownItem @click="handlerCopyWith(true)">
|
||||
<Icon type="md-copy"/>
|
||||
{{ $t('copy.copyWithHeaders') }}
|
||||
{{ $t('copy.copyWithHeadersRow') }}
|
||||
</DropdownItem>
|
||||
<DropdownItem @click="handlerCopyWith(false)">
|
||||
<Icon type="md-copy"/>
|
||||
{{ $t('copy.copyDataOnlyRow') }}
|
||||
</DropdownItem>
|
||||
</DropdownMenu>
|
||||
</template>
|
||||
@ -81,6 +85,12 @@
|
||||
ORDER BY
|
||||
</template>
|
||||
</Input>
|
||||
<Input v-model="currentWhere" size="small" clearable style="width: auto;" @on-enter="handlerGetValue">
|
||||
<template #prepend>
|
||||
<FontAwesomeIcon icon="filter" />
|
||||
WHERE
|
||||
</template>
|
||||
</Input>
|
||||
</Space>
|
||||
</div>
|
||||
</div>
|
||||
@ -147,6 +157,7 @@ export default defineComponent({
|
||||
currentOrder: {
|
||||
inputValue: null
|
||||
},
|
||||
currentWhere: null,
|
||||
databaseArray: [],
|
||||
dataTreeArray: [],
|
||||
configure: null as Sql,
|
||||
@ -296,9 +307,12 @@ export default defineComponent({
|
||||
item.title = item.title + ' [' + response.data.columns.length + ']';
|
||||
response.data.columns.forEach(column => {
|
||||
dataTreeColumnArray.push({
|
||||
title: column['COLUMN_NAME'] + ' [' + column['DATA_TYPE'] + ']',
|
||||
level: 'FindColumnType',
|
||||
catalog: column['TABLE_CATALOG'],
|
||||
database: this.currentDatabase,
|
||||
table: column['TABLE_NAME'],
|
||||
column: column['COLUMN_NAME'],
|
||||
title: column['COLUMN_NAME'] + ' [' + column['DATA_TYPE'] + ']',
|
||||
level: 'GetColumnDataForTable',
|
||||
type: 'data',
|
||||
dataType: column['DATA_TYPE'],
|
||||
children: []
|
||||
@ -327,17 +341,23 @@ export default defineComponent({
|
||||
this.columns = [];
|
||||
this.isShowData = true;
|
||||
this.dataLoading = true;
|
||||
this.selectedRows = [];
|
||||
// Reinitialize when switching to a new table
|
||||
if (this.currentTable !== data.title) {
|
||||
this.configure = new Sql();
|
||||
this.currentPageNumber = 1;
|
||||
this.currentOrder.inputValue = null;
|
||||
this.currentWhere = null;
|
||||
this.configure.offset = this.currentPageNumber;
|
||||
this.tableSortColumns = null;
|
||||
}
|
||||
this.currentTable = data.title;
|
||||
this.configure.database = data.catalog;
|
||||
this.configure.table = this.currentTable;
|
||||
if (data.level === 'GetColumnDataForTable') {
|
||||
this.configure.table = data.table;
|
||||
this.configure.columns = [data.column];
|
||||
}
|
||||
this.handlerExecute();
|
||||
}
|
||||
},
|
||||
@ -396,28 +416,34 @@ export default defineComponent({
|
||||
},
|
||||
handlerGetValue()
|
||||
{
|
||||
const value = this.currentOrder.inputValue;
|
||||
if (value) {
|
||||
const sort: Array<Sort> = new Array<Sort>();
|
||||
value.split(',').forEach(item => {
|
||||
const array = item.trim().split(' ')
|
||||
if (this.currentOrder.inputValue) {
|
||||
const value = this.currentOrder.inputValue;
|
||||
if (value) {
|
||||
const sort: Array<Sort> = new Array<Sort>();
|
||||
value.split(',').forEach(item => {
|
||||
const array = item.trim().split(' ')
|
||||
sort.push({
|
||||
column: array[0],
|
||||
sort: array[1]
|
||||
})
|
||||
})
|
||||
this.configure.sort = sort;
|
||||
}
|
||||
else {
|
||||
const sort: Array<Sort> = new Array<Sort>();
|
||||
const array = value.trim().split(' ')
|
||||
sort.push({
|
||||
column: array[0],
|
||||
sort: array[1]
|
||||
})
|
||||
})
|
||||
this.configure.sort = sort;
|
||||
this.configure.sort = sort;
|
||||
}
|
||||
this.tableSortColumns = this.configure.sort;
|
||||
}
|
||||
else {
|
||||
const sort: Array<Sort> = new Array<Sort>();
|
||||
const array = value.trim().split(' ')
|
||||
sort.push({
|
||||
column: array[0],
|
||||
sort: array[1]
|
||||
})
|
||||
this.configure.sort = sort;
|
||||
|
||||
if (this.currentWhere) {
|
||||
this.configure.where = this.currentWhere;
|
||||
}
|
||||
this.tableSortColumns = this.configure.sort;
|
||||
this.handlerExecute();
|
||||
},
|
||||
handlerOnSorted(sort: Array<Sort>)
|
||||
@ -435,7 +461,7 @@ export default defineComponent({
|
||||
{
|
||||
this.selectedRows = nodes;
|
||||
},
|
||||
handlerCopyWithHeaders()
|
||||
handlerCopyWith(withHeaders: boolean)
|
||||
{
|
||||
const headers = [];
|
||||
const copyRows = [];
|
||||
@ -448,10 +474,12 @@ export default defineComponent({
|
||||
});
|
||||
copyRows.push(join(values, ','));
|
||||
});
|
||||
copyRows.unshift(join(headers, ','));
|
||||
if (withHeaders) {
|
||||
copyRows.unshift(join(headers, ','));
|
||||
}
|
||||
useClipboard()
|
||||
.toClipboard(join(copyRows, '\n'))
|
||||
.then(() => this.$Message.info('Copy'));
|
||||
.then(() => this.$Message.info('Copy Successfully'));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="home">
|
||||
<Row :gutter="16">
|
||||
<Row style="margin: 10px 5px;" :gutter="16">
|
||||
<Col span="6">
|
||||
<Card class="content-center">
|
||||
<NumberInfo>
|
@ -43,7 +43,7 @@ public class ClickHousePlugin
|
||||
this.response = new Response();
|
||||
this.jdbcConfigure = new JdbcConfigure();
|
||||
BeanUtils.copyProperties(this.jdbcConfigure, configure);
|
||||
this.jdbcConfigure.setJdbcDriver("ru.yandex.clickhouse.ClickHouseDriver");
|
||||
this.jdbcConfigure.setJdbcDriver("com.clickhouse.jdbc.ClickHouseDriver");
|
||||
this.jdbcConfigure.setJdbcType("clickhouse");
|
||||
this.clickHouseConnection = new ClickHouseConnection(this.jdbcConfigure, this.response);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user