Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zhu
dataease
Commits
4eaaf227
提交
4eaaf227
authored
8月 23, 2021
作者:
taojinlong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 校验数据源状态时,同时刷新左侧菜单中数据源的状态
上级
378a034f
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
56 行增加
和
9 行删除
+56
-9
DatasourceController.java
.../dataease/datasource/controller/DatasourceController.java
+8
-0
DatasourceService.java
...ava/io/dataease/datasource/service/DatasourceService.java
+16
-5
datasource.js
frontend/src/api/system/datasource.js
+8
-0
form.vue
frontend/src/views/system/datasource/form.vue
+24
-4
没有找到文件。
backend/src/main/java/io/dataease/datasource/controller/DatasourceController.java
浏览文件 @
4eaaf227
...
@@ -7,6 +7,7 @@ import io.dataease.base.domain.Datasource;
...
@@ -7,6 +7,7 @@ import io.dataease.base.domain.Datasource;
import
io.dataease.commons.utils.AuthUtils
;
import
io.dataease.commons.utils.AuthUtils
;
import
io.dataease.commons.utils.PageUtils
;
import
io.dataease.commons.utils.PageUtils
;
import
io.dataease.commons.utils.Pager
;
import
io.dataease.commons.utils.Pager
;
import
io.dataease.controller.ResultHolder
;
import
io.dataease.controller.request.DatasourceUnionRequest
;
import
io.dataease.controller.request.DatasourceUnionRequest
;
import
io.dataease.controller.sys.base.BaseGridRequest
;
import
io.dataease.controller.sys.base.BaseGridRequest
;
import
io.dataease.datasource.dto.DBTableDTO
;
import
io.dataease.datasource.dto.DBTableDTO
;
...
@@ -41,6 +42,13 @@ public class DatasourceController {
...
@@ -41,6 +42,13 @@ public class DatasourceController {
datasourceService
.
validate
(
datasource
);
datasourceService
.
validate
(
datasource
);
}
}
@ApiOperation
(
"验证数据源"
)
@GetMapping
(
"/validate/{datasourceId}"
)
public
ResultHolder
validate
(
@PathVariable
String
datasourceId
)
{
return
datasourceService
.
validate
(
datasourceId
);
}
@ApiOperation
(
"查询当前用户数据源"
)
@ApiOperation
(
"查询当前用户数据源"
)
@GetMapping
(
"/list"
)
@GetMapping
(
"/list"
)
public
List
<
DatasourceDTO
>
getDatasourceList
()
throws
Exception
{
public
List
<
DatasourceDTO
>
getDatasourceList
()
throws
Exception
{
...
...
backend/src/main/java/io/dataease/datasource/service/DatasourceService.java
浏览文件 @
4eaaf227
...
@@ -9,6 +9,7 @@ import io.dataease.commons.exception.DEException;
...
@@ -9,6 +9,7 @@ import io.dataease.commons.exception.DEException;
import
io.dataease.commons.utils.AuthUtils
;
import
io.dataease.commons.utils.AuthUtils
;
import
io.dataease.commons.utils.CommonThreadPool
;
import
io.dataease.commons.utils.CommonThreadPool
;
import
io.dataease.commons.utils.LogUtil
;
import
io.dataease.commons.utils.LogUtil
;
import
io.dataease.controller.ResultHolder
;
import
io.dataease.controller.request.DatasourceUnionRequest
;
import
io.dataease.controller.request.DatasourceUnionRequest
;
import
io.dataease.controller.sys.base.BaseGridRequest
;
import
io.dataease.controller.sys.base.BaseGridRequest
;
import
io.dataease.controller.sys.base.ConditionEntity
;
import
io.dataease.controller.sys.base.ConditionEntity
;
...
@@ -126,13 +127,23 @@ public class DatasourceService {
...
@@ -126,13 +127,23 @@ public class DatasourceService {
datasourceProvider
.
checkStatus
(
datasourceRequest
);
datasourceProvider
.
checkStatus
(
datasourceRequest
);
}
}
public
void
validate
(
String
datasourceId
)
throws
Exception
{
public
ResultHolder
validate
(
String
datasourceId
)
{
if
(
StringUtils
.
isEmpty
(
datasourceId
)){
return
;
}
Datasource
datasource
=
datasourceMapper
.
selectByPrimaryKey
(
datasourceId
);
Datasource
datasource
=
datasourceMapper
.
selectByPrimaryKey
(
datasourceId
);
validate
(
datasource
);
if
(
datasource
==
null
){
return
ResultHolder
.
error
(
"Can not find datasource: "
+
datasourceId
);
}
try
{
validate
(
datasource
);
datasource
.
setStatus
(
"Success"
);
return
ResultHolder
.
success
(
"Success"
);
}
catch
(
Exception
e
){
datasource
.
setStatus
(
"Error"
);
return
ResultHolder
.
error
(
"Datasource is invalid: "
+
e
.
getMessage
());
}
finally
{
datasourceMapper
.
updateByPrimaryKey
(
datasource
);
}
}
}
public
List
<
String
>
getSchema
(
Datasource
datasource
)
throws
Exception
{
public
List
<
String
>
getSchema
(
Datasource
datasource
)
throws
Exception
{
DatasourceProvider
datasourceProvider
=
ProviderFactory
.
getProvider
(
datasource
.
getType
());
DatasourceProvider
datasourceProvider
=
ProviderFactory
.
getProvider
(
datasource
.
getType
());
DatasourceRequest
datasourceRequest
=
new
DatasourceRequest
();
DatasourceRequest
datasourceRequest
=
new
DatasourceRequest
();
...
...
frontend/src/api/system/datasource.js
浏览文件 @
4eaaf227
...
@@ -50,6 +50,14 @@ export function validateDs(data) {
...
@@ -50,6 +50,14 @@ export function validateDs(data) {
})
})
}
}
export
function
validateDsById
(
datasourceId
)
{
return
request
({
url
:
'datasource/validate/'
+
datasourceId
,
method
:
'get'
,
loading
:
true
})
}
export
function
getSchema
(
data
)
{
export
function
getSchema
(
data
)
{
return
request
({
return
request
({
url
:
'datasource/getSchema/'
,
url
:
'datasource/getSchema/'
,
...
...
frontend/src/views/system/datasource/form.vue
浏览文件 @
4eaaf227
...
@@ -100,7 +100,7 @@
...
@@ -100,7 +100,7 @@
<
script
>
<
script
>
import
LayoutContent
from
'@/components/business/LayoutContent'
import
LayoutContent
from
'@/components/business/LayoutContent'
import
{
addDs
,
editDs
,
getSchema
,
validateDs
}
from
'@/api/system/datasource'
import
{
addDs
,
editDs
,
getSchema
,
validateDs
,
validateDsById
}
from
'@/api/system/datasource'
import
{
$confirm
}
from
'@/utils/message'
import
{
$confirm
}
from
'@/utils/message'
export
default
{
export
default
{
...
@@ -276,9 +276,29 @@ export default {
...
@@ -276,9 +276,29 @@ export default {
if
(
valid
)
{
if
(
valid
)
{
const
data
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
form
))
const
data
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
form
))
data
.
configuration
=
JSON
.
stringify
(
data
.
configuration
)
data
.
configuration
=
JSON
.
stringify
(
data
.
configuration
)
validateDs
(
data
).
then
(
res
=>
{
if
(
data
.
showModel
===
'show'
&&
!
this
.
canEdit
){
this
.
$success
(
this
.
$t
(
'datasource.validate_success'
))
validateDsById
(
data
.
id
).
then
(
res
=>
{
})
if
(
res
.
success
===
'true'
){
this
.
$success
(
this
.
$t
(
'datasource.validate_success'
))
}
else
{
this
.
$error
(
this
.
$t
(
res
.
message
))
}
this
.
refreshTree
()
}).
catch
(
res
=>
{
this
.
$error
(
res
.
message
)
})
}
else
{
validateDs
(
data
).
then
(
res
=>
{
if
(
res
.
success
===
'true'
){
this
.
$success
(
this
.
$t
(
'datasource.validate_success'
))
}
else
{
this
.
$error
(
this
.
$t
(
res
.
message
))
}
}).
catch
(
res
=>
{
this
.
$error
(
res
.
message
)
})
}
}
else
{
}
else
{
return
false
return
false
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论