Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangpeng
dinky
Commits
76234b0b
Unverified
Commit
76234b0b
authored
Nov 23, 2022
by
zhu-mingye
Committed by
GitHub
Nov 23, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Feature][admin,web] add database copying (#1298)
* fix check i18n may be null error to use umi_language * [feature][admin,web] add database copying
parent
3c21f3a2
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
64 additions
and
15 deletions
+64
-15
DataBaseController.java
...rc/main/java/com/dlink/controller/DataBaseController.java
+20
-5
DataBaseService.java
...dmin/src/main/java/com/dlink/service/DataBaseService.java
+2
-0
DataBaseServiceImpl.java
...main/java/com/dlink/service/impl/DataBaseServiceImpl.java
+11
-0
pages.ts
dlink-web/src/locales/en-US/pages.ts
+1
-0
pages.ts
dlink-web/src/locales/zh-CN/pages.ts
+1
-0
index.tsx
dlink-web/src/pages/DataBase/index.tsx
+16
-10
service.ts
dlink-web/src/pages/DataBase/service.ts
+13
-0
No files found.
dlink-admin/src/main/java/com/dlink/controller/DataBaseController.java
View file @
76234b0b
...
@@ -60,6 +60,7 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -60,6 +60,7 @@ import lombok.extern.slf4j.Slf4j;
@RestController
@RestController
@RequestMapping
(
"/api/database"
)
@RequestMapping
(
"/api/database"
)
public
class
DataBaseController
{
public
class
DataBaseController
{
@Autowired
@Autowired
private
DataBaseService
databaseService
;
private
DataBaseService
databaseService
;
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
DataBaseController
.
class
);
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
DataBaseController
.
class
);
...
@@ -169,7 +170,7 @@ public class DataBaseController {
...
@@ -169,7 +170,7 @@ public class DataBaseController {
/**
/**
* 获取元数据的表
* 获取元数据的表
*/
*/
@Cacheable
(
cacheNames
=
"metadata_schema"
,
key
=
"#id"
)
@Cacheable
(
cacheNames
=
"metadata_schema"
,
key
=
"#id"
)
@GetMapping
(
"/getSchemasAndTables"
)
@GetMapping
(
"/getSchemasAndTables"
)
public
Result
getSchemasAndTables
(
@RequestParam
Integer
id
)
{
public
Result
getSchemasAndTables
(
@RequestParam
Integer
id
)
{
return
Result
.
succeed
(
databaseService
.
getSchemasAndTables
(
id
),
"获取成功"
);
return
Result
.
succeed
(
databaseService
.
getSchemasAndTables
(
id
),
"获取成功"
);
...
@@ -178,7 +179,7 @@ public class DataBaseController {
...
@@ -178,7 +179,7 @@ public class DataBaseController {
/**
/**
* 清除元数据表的缓存
* 清除元数据表的缓存
*/
*/
@CacheEvict
(
cacheNames
=
"metadata_schema"
,
key
=
"#id"
)
@CacheEvict
(
cacheNames
=
"metadata_schema"
,
key
=
"#id"
)
@GetMapping
(
"/unCacheSchemasAndTables"
)
@GetMapping
(
"/unCacheSchemasAndTables"
)
public
Result
unCacheSchemasAndTables
(
@RequestParam
Integer
id
)
{
public
Result
unCacheSchemasAndTables
(
@RequestParam
Integer
id
)
{
return
Result
.
succeed
(
"clear cache"
,
"success"
);
return
Result
.
succeed
(
"clear cache"
,
"success"
);
...
@@ -188,7 +189,8 @@ public class DataBaseController {
...
@@ -188,7 +189,8 @@ public class DataBaseController {
* 获取元数据的指定表的列
* 获取元数据的指定表的列
*/
*/
@GetMapping
(
"/listColumns"
)
@GetMapping
(
"/listColumns"
)
public
Result
listColumns
(
@RequestParam
Integer
id
,
@RequestParam
String
schemaName
,
@RequestParam
String
tableName
)
{
public
Result
listColumns
(
@RequestParam
Integer
id
,
@RequestParam
String
schemaName
,
@RequestParam
String
tableName
)
{
return
Result
.
succeed
(
databaseService
.
listColumns
(
id
,
schemaName
,
tableName
),
"获取成功"
);
return
Result
.
succeed
(
databaseService
.
listColumns
(
id
,
schemaName
,
tableName
),
"获取成功"
);
}
}
...
@@ -201,7 +203,7 @@ public class DataBaseController {
...
@@ -201,7 +203,7 @@ public class DataBaseController {
if
(
jdbcSelectResult
.
isSuccess
())
{
if
(
jdbcSelectResult
.
isSuccess
())
{
return
Result
.
succeed
(
jdbcSelectResult
,
"获取成功"
);
return
Result
.
succeed
(
jdbcSelectResult
,
"获取成功"
);
}
else
{
}
else
{
return
Result
.
failed
(
jdbcSelectResult
,
"查询失败"
);
return
Result
.
failed
(
jdbcSelectResult
,
"查询失败"
);
}
}
}
}
...
@@ -209,7 +211,20 @@ public class DataBaseController {
...
@@ -209,7 +211,20 @@ public class DataBaseController {
* 获取 SqlGeneration
* 获取 SqlGeneration
*/
*/
@GetMapping
(
"/getSqlGeneration"
)
@GetMapping
(
"/getSqlGeneration"
)
public
Result
getSqlGeneration
(
@RequestParam
Integer
id
,
@RequestParam
String
schemaName
,
@RequestParam
String
tableName
)
{
public
Result
getSqlGeneration
(
@RequestParam
Integer
id
,
@RequestParam
String
schemaName
,
@RequestParam
String
tableName
)
{
return
Result
.
succeed
(
databaseService
.
getSqlGeneration
(
id
,
schemaName
,
tableName
),
"获取成功"
);
return
Result
.
succeed
(
databaseService
.
getSqlGeneration
(
id
,
schemaName
,
tableName
),
"获取成功"
);
}
}
/**
* copyDatabase
*/
@PostMapping
(
"/copyDatabase"
)
public
Result
copyDatabase
(
@RequestBody
DataBase
database
)
{
if
(
databaseService
.
copyDatabase
(
database
))
{
return
Result
.
succeed
(
"复制成功!"
);
}
else
{
return
Result
.
failed
(
"复制失败!"
);
}
}
}
}
dlink-admin/src/main/java/com/dlink/service/DataBaseService.java
View file @
76234b0b
...
@@ -62,4 +62,6 @@ public interface DataBaseService extends ISuperService<DataBase> {
...
@@ -62,4 +62,6 @@ public interface DataBaseService extends ISuperService<DataBase> {
List
<
String
>
listEnabledFlinkWith
();
List
<
String
>
listEnabledFlinkWith
();
String
getEnabledFlinkWithSql
();
String
getEnabledFlinkWithSql
();
boolean
copyDatabase
(
DataBase
database
);
}
}
dlink-admin/src/main/java/com/dlink/service/impl/DataBaseServiceImpl.java
View file @
76234b0b
...
@@ -38,6 +38,7 @@ import org.apache.commons.lang3.StringUtils;
...
@@ -38,6 +38,7 @@ import org.apache.commons.lang3.StringUtils;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.UUID
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -51,6 +52,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
...
@@ -51,6 +52,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
*/
*/
@Service
@Service
public
class
DataBaseServiceImpl
extends
SuperServiceImpl
<
DataBaseMapper
,
DataBase
>
implements
DataBaseService
{
public
class
DataBaseServiceImpl
extends
SuperServiceImpl
<
DataBaseMapper
,
DataBase
>
implements
DataBaseService
{
@Override
@Override
public
String
testConnect
(
DataBase
dataBase
)
{
public
String
testConnect
(
DataBase
dataBase
)
{
return
Driver
.
build
(
dataBase
.
getDriverConfig
()).
test
();
return
Driver
.
build
(
dataBase
.
getDriverConfig
()).
test
();
...
@@ -185,4 +187,13 @@ public class DataBaseServiceImpl extends SuperServiceImpl<DataBaseMapper, DataBa
...
@@ -185,4 +187,13 @@ public class DataBaseServiceImpl extends SuperServiceImpl<DataBaseMapper, DataBa
List
<
String
>
list
=
listEnabledFlinkWith
();
List
<
String
>
list
=
listEnabledFlinkWith
();
return
StringUtils
.
join
(
list
,
""
);
return
StringUtils
.
join
(
list
,
""
);
}
}
@Override
public
boolean
copyDatabase
(
DataBase
database
)
{
String
name
=
UUID
.
randomUUID
().
toString
().
replaceAll
(
"-"
,
""
).
substring
(
0
,
10
);
database
.
setId
(
null
);
database
.
setName
(
database
.
getName
().
substring
(
0
,
10
)
+
"_"
+
name
);
database
.
setCreateTime
(
null
);
return
this
.
save
(
database
);
}
}
}
dlink-web/src/locales/en-US/pages.ts
View file @
76234b0b
...
@@ -489,6 +489,7 @@ export default {
...
@@ -489,6 +489,7 @@ export default {
'pages.registerCenter.db.urlPlaceholder'
:
'Please enter a properly formatted url connection!'
,
'pages.registerCenter.db.urlPlaceholder'
:
'Please enter a properly formatted url connection!'
,
'pages.registerCenter.db.flinkConfigPlaceholder'
:
'Please specify the default configuration of Flink With!'
,
'pages.registerCenter.db.flinkConfigPlaceholder'
:
'Please specify the default configuration of Flink With!'
,
'pages.registerCenter.db.flinkTemplatePlaceholder'
:
'Please specify the generated template of Flink With!'
,
'pages.registerCenter.db.flinkTemplatePlaceholder'
:
'Please specify the generated template of Flink With!'
,
'pages.registerCenter.db.copyDatabase'
:
'Copying!'
,
'pages.registerCenter.db.source'
:
'Source'
,
'pages.registerCenter.db.source'
:
'Source'
,
'pages.registerCenter.db.warehouse'
:
'Data WareHouse'
,
'pages.registerCenter.db.warehouse'
:
'Data WareHouse'
,
'pages.registerCenter.db.application'
:
'Application'
,
'pages.registerCenter.db.application'
:
'Application'
,
...
...
dlink-web/src/locales/zh-CN/pages.ts
View file @
76234b0b
...
@@ -488,6 +488,7 @@ export default {
...
@@ -488,6 +488,7 @@ export default {
'pages.registerCenter.db.urlPlaceholder'
:
'请输入格式正确的 url 连接!'
,
'pages.registerCenter.db.urlPlaceholder'
:
'请输入格式正确的 url 连接!'
,
'pages.registerCenter.db.flinkConfigPlaceholder'
:
'请指定 Flink With 的默认配置!'
,
'pages.registerCenter.db.flinkConfigPlaceholder'
:
'请指定 Flink With 的默认配置!'
,
'pages.registerCenter.db.flinkTemplatePlaceholder'
:
'请指定 Flink With 的生成模板!'
,
'pages.registerCenter.db.flinkTemplatePlaceholder'
:
'请指定 Flink With 的生成模板!'
,
'pages.registerCenter.db.copyDatabase'
:
'正在复制!'
,
'pages.registerCenter.db.source'
:
'来源'
,
'pages.registerCenter.db.source'
:
'来源'
,
'pages.registerCenter.db.warehouse'
:
'数仓'
,
'pages.registerCenter.db.warehouse'
:
'数仓'
,
'pages.registerCenter.db.application'
:
'应用'
,
'pages.registerCenter.db.application'
:
'应用'
,
...
...
dlink-web/src/pages/DataBase/index.tsx
View file @
76234b0b
...
@@ -22,9 +22,9 @@ import React, {useRef, useState} from "react";
...
@@ -22,9 +22,9 @@ import React, {useRef, useState} from "react";
import
{
PageContainer
}
from
'@ant-design/pro-layout'
;
import
{
PageContainer
}
from
'@ant-design/pro-layout'
;
import
{
import
{
CheckCircleOutlined
,
CheckCircleOutlined
,
CopyOutlined
,
DeleteOutlined
,
DeleteOutlined
,
EditOutlined
,
EditOutlined
,
EllipsisOutlined
,
ExclamationCircleOutlined
,
ExclamationCircleOutlined
,
HeartOutlined
,
HeartOutlined
,
PlusOutlined
PlusOutlined
...
@@ -38,7 +38,7 @@ import {ActionType} from "@ant-design/pro-table";
...
@@ -38,7 +38,7 @@ import {ActionType} from "@ant-design/pro-table";
import
styles
from
'./index.less'
;
import
styles
from
'./index.less'
;
import
{
DataBaseItem
}
from
"@/pages/DataBase/data"
;
import
{
DataBaseItem
}
from
"@/pages/DataBase/data"
;
import
{
checkHeartBeat
}
from
"@/pages/DataBase/service"
;
import
{
checkHeartBeat
,
copyDatabase
}
from
"@/pages/DataBase/service"
;
import
{
showDataBase
}
from
"@/components/Studio/StudioEvent/DDL"
;
import
{
showDataBase
}
from
"@/components/Studio/StudioEvent/DDL"
;
import
{
l
}
from
"@/utils/intl"
;
import
{
l
}
from
"@/utils/intl"
;
...
@@ -85,7 +85,11 @@ const DataBaseTableList: React.FC<{}> = (props: any) => {
...
@@ -85,7 +85,11 @@ const DataBaseTableList: React.FC<{}> = (props: any) => {
}
}
});
});
};
};
const
onCopyDataBase
=
(
row
:
DataBaseItem
)
=>
{
copyDatabase
(
row
);
onRefreshDataBase
();
actionRef
.
current
?.
reloadAndRest
?.();
};
return
(
return
(
<
PageContainer
title=
{
false
}
>
<
PageContainer
title=
{
false
}
>
<
ProList
<
ProList
...
@@ -123,16 +127,18 @@ const DataBaseTableList: React.FC<{}> = (props: any) => {
...
@@ -123,16 +127,18 @@ const DataBaseTableList: React.FC<{}> = (props: any) => {
</
div
>
</
div
>
}
}
actions=
{
[
actions=
{
[
<
HeartOutlined
key=
"setting"
onClick=
{
()
=>
{
<
HeartOutlined
key=
"heartbeat"
title=
{
l
(
'button.heartbeat'
)
}
onClick=
{
()
=>
{
onCheckHeartBeat
(
row
);
onCheckHeartBeat
(
row
as
DataBaseItem
);
}
}
/>,
<
EditOutlined
key=
"edit"
title=
{
l
(
'button.edit'
)
}
onClick=
{
()
=>
{
onEdit
(
row
as
DataBaseItem
);
}
}
/>,
}
}
/>,
<
EditOutlined
key=
"edit"
onClick=
{
()
=>
{
<
DeleteOutlined
key=
"delete"
title=
{
l
(
'button.delete'
)
}
onClick=
{
()
=>
{
on
Edit
(
row
);
on
DeleteDataBase
(
row
as
DataBaseItem
);
}
}
/>,
}
}
/>,
<
DeleteOutlined
key=
"delete"
onClick=
{
()
=>
{
<
CopyOutlined
key=
"copy"
title=
{
l
(
'right.menu.copy'
)
}
onClick=
{
()
=>
{
on
DeleteDataBase
(
row
);
on
CopyDataBase
(
row
as
DataBaseItem
);
}
}
/>,
}
}
/>,
<
EllipsisOutlined
key=
"ellipsis"
/>,
]
}
]
}
>
>
<
Card
.
Meta
<
Card
.
Meta
...
...
dlink-web/src/pages/DataBase/service.ts
View file @
76234b0b
...
@@ -53,3 +53,16 @@ export async function checkHeartBeat(id: number) {
...
@@ -53,3 +53,16 @@ export async function checkHeartBeat(id: number) {
message
.
error
(
l
(
'app.request.failed'
));
message
.
error
(
l
(
'app.request.failed'
));
}
}
}
}
export
async
function
copyDatabase
(
databse
:
DataBaseItem
)
{
const
hide
=
message
.
loading
(
l
(
'pages.registerCenter.db.copyDatabase'
));
try
{
const
{
code
,
msg
}
=
await
postAll
(
'/api/database/copyDatabase'
,
databse
);
hide
();
code
==
0
?
message
.
success
(
msg
)
:
message
.
error
(
msg
);
}
catch
(
error
)
{
hide
();
message
.
error
(
l
(
'app.request.failed'
));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment