Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zhu
dataease
Commits
6ce1adf5
提交
6ce1adf5
authored
7月 05, 2021
作者:
taojinlong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(数据源): 添加oracle 数据源时,指定schema
上级
b9ac54b6
隐藏空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
133 行增加
和
10 行删除
+133
-10
DatasourceController.java
.../dataease/datasource/controller/DatasourceController.java
+7
-0
OracleConfigration.java
...n/java/io/dataease/datasource/dto/OracleConfigration.java
+1
-0
DatasourceProvider.java
...a/io/dataease/datasource/provider/DatasourceProvider.java
+2
-0
JdbcProvider.java
...in/java/io/dataease/datasource/provider/JdbcProvider.java
+44
-2
DatasourceService.java
...ava/io/dataease/datasource/service/DatasourceService.java
+7
-0
messages_en_US.properties
backend/src/main/resources/i18n/messages_en_US.properties
+2
-0
messages_zh_CN.properties
backend/src/main/resources/i18n/messages_zh_CN.properties
+1
-0
messages_zh_TW.properties
backend/src/main/resources/i18n/messages_zh_TW.properties
+2
-0
datasource.js
frontend/src/api/system/datasource.js
+10
-1
en.js
frontend/src/lang/en.js
+7
-1
tw.js
frontend/src/lang/tw.js
+7
-1
zh.js
frontend/src/lang/zh.js
+4
-1
form.vue
frontend/src/views/system/datasource/form.vue
+39
-4
没有找到文件。
backend/src/main/java/io/dataease/datasource/controller/DatasourceController.java
浏览文件 @
6ce1adf5
...
...
@@ -61,4 +61,11 @@ public class DatasourceController {
public
List
<
DBTableDTO
>
getTables
(
@RequestBody
Datasource
datasource
)
throws
Exception
{
return
datasourceService
.
getTables
(
datasource
);
}
@PostMapping
(
"/getSchema"
)
public
List
<
String
>
getSchema
(
@RequestBody
Datasource
datasource
)
throws
Exception
{
return
datasourceService
.
getSchema
(
datasource
);
}
}
backend/src/main/java/io/dataease/datasource/dto/OracleConfigration.java
浏览文件 @
6ce1adf5
...
...
@@ -9,6 +9,7 @@ public class OracleConfigration extends JdbcDTO {
private
String
driver
=
"oracle.jdbc.driver.OracleDriver"
;
private
String
connectionType
;
private
String
schema
;
public
String
getJdbc
()
{
// 连接参数先写死,后边要把编码、时区等参数放到数据源的设置中
...
...
backend/src/main/java/io/dataease/datasource/provider/DatasourceProvider.java
浏览文件 @
6ce1adf5
...
...
@@ -30,4 +30,6 @@ public abstract class DatasourceProvider {
abstract
public
Map
<
String
,
List
>
fetchResultAndField
(
DatasourceRequest
datasourceRequest
)
throws
Exception
;
abstract
public
void
handleDatasource
(
DatasourceRequest
datasourceRequest
,
String
type
)
throws
Exception
;
abstract
public
List
<
String
>
getSchema
(
DatasourceRequest
datasourceRequest
)
throws
Exception
;
}
backend/src/main/java/io/dataease/datasource/provider/JdbcProvider.java
浏览文件 @
6ce1adf5
...
...
@@ -2,6 +2,7 @@ package io.dataease.datasource.provider;
import
com.google.gson.Gson
;
import
com.mchange.v2.c3p0.ComboPooledDataSource
;
import
io.dataease.controller.handler.annotation.I18n
;
import
io.dataease.datasource.constants.DatasourceTypes
;
import
io.dataease.datasource.dto.MysqlConfigration
;
import
io.dataease.datasource.dto.OracleConfigration
;
...
...
@@ -9,10 +10,12 @@ import io.dataease.datasource.dto.SqlServerConfigration;
import
io.dataease.datasource.dto.TableFiled
;
import
io.dataease.datasource.request.DatasourceRequest
;
import
io.dataease.exception.DataEaseException
;
import
io.dataease.i18n.Translator
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
import
java.beans.PropertyVetoException
;
import
java.sql.*
;
import
java.text.MessageFormat
;
import
java.util.*
;
@Service
(
"jdbc"
)
...
...
@@ -212,6 +215,31 @@ public class JdbcProvider extends DatasourceProvider {
return
new
ArrayList
<>();
}
@Override
public
List
<
String
>
getSchema
(
DatasourceRequest
datasourceRequest
)
throws
Exception
{
List
<
String
>
schemas
=
new
ArrayList
<>();
String
queryStr
=
getSchemaSql
(
datasourceRequest
);
Connection
con
=
null
;
try
{
con
=
getConnection
(
datasourceRequest
);
Statement
statement
=
con
.
createStatement
();
ResultSet
resultSet
=
statement
.
executeQuery
(
queryStr
);
while
(
resultSet
.
next
())
{
schemas
.
add
(
resultSet
.
getString
(
1
));
}
resultSet
.
close
();
statement
.
close
();
return
schemas
;
}
catch
(
Exception
e
)
{
DataEaseException
.
throwException
(
e
);
}
finally
{
if
(
con
!=
null
){
con
.
close
();
}
}
return
new
ArrayList
<>();
}
@Override
public
List
<
TableFiled
>
getTableFileds
(
DatasourceRequest
datasourceRequest
)
throws
Exception
{
List
<
TableFiled
>
list
=
new
LinkedList
<>();
...
...
@@ -466,7 +494,7 @@ public class JdbcProvider extends DatasourceProvider {
}
}
private
String
getTablesSql
(
DatasourceRequest
datasourceRequest
)
{
private
String
getTablesSql
(
DatasourceRequest
datasourceRequest
)
throws
Exception
{
DatasourceTypes
datasourceType
=
DatasourceTypes
.
valueOf
(
datasourceRequest
.
getDatasource
().
getType
());
switch
(
datasourceType
)
{
case
mysql:
...
...
@@ -477,7 +505,21 @@ public class JdbcProvider extends DatasourceProvider {
SqlServerConfigration
sqlServerConfigration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
SqlServerConfigration
.
class
);
return
"SELECT TABLE_NAME FROM DATABASE.INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE';"
.
replace
(
"DATABASE"
,
sqlServerConfigration
.
getDataBase
());
case
oracle:
return
"select TABLE_NAME from USER_TABLES"
;
OracleConfigration
oracleConfigration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
OracleConfigration
.
class
);
if
(
StringUtils
.
isEmpty
(
oracleConfigration
.
getSchema
())){
throw
new
Exception
(
Translator
.
get
(
"i18n_schema_is_empty"
));
}
return
"select table_name, owner from all_tables where owner='"
+
oracleConfigration
.
getSchema
()
+
"'"
;
default
:
return
"show tables;"
;
}
}
private
String
getSchemaSql
(
DatasourceRequest
datasourceRequest
)
{
DatasourceTypes
datasourceType
=
DatasourceTypes
.
valueOf
(
datasourceRequest
.
getDatasource
().
getType
());
switch
(
datasourceType
)
{
case
oracle:
return
"select * from all_users"
;
default
:
return
"show tables;"
;
}
...
...
backend/src/main/java/io/dataease/datasource/service/DatasourceService.java
浏览文件 @
6ce1adf5
...
...
@@ -120,6 +120,13 @@ public class DatasourceService {
datasourceProvider
.
checkStatus
(
datasourceRequest
);
}
public
List
<
String
>
getSchema
(
Datasource
datasource
)
throws
Exception
{
DatasourceProvider
datasourceProvider
=
ProviderFactory
.
getProvider
(
datasource
.
getType
());
DatasourceRequest
datasourceRequest
=
new
DatasourceRequest
();
datasourceRequest
.
setDatasource
(
datasource
);
return
datasourceProvider
.
getSchema
(
datasourceRequest
);
}
public
List
<
DBTableDTO
>
getTables
(
Datasource
datasource
)
throws
Exception
{
Datasource
ds
=
datasourceMapper
.
selectByPrimaryKey
(
datasource
.
getId
());
DatasourceProvider
datasourceProvider
=
ProviderFactory
.
getProvider
(
ds
.
getType
());
...
...
backend/src/main/resources/i18n/messages_en_US.properties
浏览文件 @
6ce1adf5
...
...
@@ -261,3 +261,4 @@ i18n_sql_delete_not_matching=The data column of incremental delete SQL does not
i18n_cst_ds_tb_or_field_deleted
=
Custom dataset union data is deleted or field changed,can not display
i18n_no_all_delete_privilege_folder
=
This folder have sources which have no manage or view privilege,Can Not Be Deleted.
i18n_excel_field_repeat
=
Excel exists repeat field,please fix and upload again.
i18n_schema_is_empty
=
Database schema is empty
\ No newline at end of file
backend/src/main/resources/i18n/messages_zh_CN.properties
浏览文件 @
6ce1adf5
...
...
@@ -260,3 +260,4 @@ i18n_sql_delete_not_matching=增量删除 sql 的数据列与数据集不匹配,
i18n_cst_ds_tb_or_field_deleted
=
自定义数据集所关联数据被删除或字段发生变化,无法正常显示
i18n_no_all_delete_privilege_folder
=
该目录下存在没有管理权限或查看权限的资源,无法删除
i18n_excel_field_repeat
=
Excel存在重复字段,请修改后重新上传
i18n_schema_is_empty
=
数据库 Schema 为空
backend/src/main/resources/i18n/messages_zh_TW.properties
浏览文件 @
6ce1adf5
...
...
@@ -263,3 +263,4 @@ i18n_sql_delete_not_matching=增量刪除 sql 的數據列與數據集不匹配,
i18n_cst_ds_tb_or_field_deleted
=
自定義數據集所關聯數據被刪除或字段發生變化,無法正常顯示
i18n_no_all_delete_privilege_folder
=
該目錄下存在沒有管理權限或查看權限的資源,無法刪除
i18n_excel_field_repeat
=
Excel存在重復字段,請修改後重新上傳
i18n_schema_is_empty
=
數據庫 Schema 為空
\ No newline at end of file
frontend/src/api/system/datasource.js
浏览文件 @
6ce1adf5
...
...
@@ -50,4 +50,13 @@ export function validateDs(data) {
})
}
export
default
{
dsGrid
,
addDs
,
editDs
,
delDs
,
validateDs
,
listDatasource
}
export
function
getSchema
(
data
)
{
return
request
({
url
:
'datasource/getSchema/'
,
method
:
'post'
,
loading
:
true
,
data
})
}
export
default
{
dsGrid
,
addDs
,
editDs
,
delDs
,
validateDs
,
listDatasource
,
getSchema
}
frontend/src/lang/en.js
浏览文件 @
6ce1adf5
...
...
@@ -890,7 +890,13 @@ export default {
delete_warning
:
'Confirm to delete?'
,
input_name
:
'Please input name'
,
input_limit_2_25
:
'2-25 chars'
,
input_limit_0_50
:
'0-50 chars'
input_limit_0_50
:
'0-50 chars'
,
oracle_connection_type
:
'Service Name/SID'
,
oracle_sid
:
'SID'
,
oracle_service_name
:
'Service Name'
,
get_schema
:
'Get Schema'
,
schema
:
'Database Schema'
,
please_choose_schema
:
'Please select Schema'
,
},
pblink
:
{
key_pwd
:
'Please enter the password to open the link'
,
...
...
frontend/src/lang/tw.js
浏览文件 @
6ce1adf5
...
...
@@ -932,7 +932,13 @@ export default {
delete_warning
:
'確認刪除?'
,
input_name
:
'請輸入名稱'
,
input_limit_2_25
:
'2-25字符'
,
input_limit_0_50
:
'0-50字符'
input_limit_0_50
:
'0-50字符'
,
oracle_connection_type
:
'服务名/SID'
,
oracle_sid
:
'SID'
,
oracle_service_name
:
'服务名'
,
get_schema
:
'获取 Schema'
,
schema
:
'数据库 Schema'
,
please_choose_schema
:
'请选择数据库 Schema'
,
},
pblink
:
{
key_pwd
:
'請輸入密碼打開鏈接'
,
...
...
frontend/src/lang/zh.js
浏览文件 @
6ce1adf5
...
...
@@ -894,7 +894,10 @@ export default {
input_limit_0_50
:
'0-50字符'
,
oracle_connection_type
:
'服务名/SID'
,
oracle_sid
:
'SID'
,
oracle_service_name
:
'服务名'
oracle_service_name
:
'服务名'
,
get_schema
:
'获取 Schema'
,
schema
:
'数据库 Schema'
,
please_choose_schema
:
'请选择数据库 Schema'
,
},
pblink
:
{
key_pwd
:
'请输入密码打开链接'
,
...
...
frontend/src/views/system/datasource/form.vue
浏览文件 @
6ce1adf5
...
...
@@ -46,6 +46,23 @@
<el-form-item
v-if=
"form.configuration.dataSourceType=='jdbc'"
:label=
"$t('datasource.port')"
prop=
"configuration.port"
>
<el-input
v-model=
"form.configuration.port"
autocomplete=
"off"
/>
</el-form-item>
<el-form-item
v-if=
"form.type=='oracle'"
>
<el-button
icon=
"el-icon-plus"
size=
"mini"
@
click=
"getSchema()"
>
{{ $t('datasource.get_schema') }}
</el-button>
</el-form-item>
<el-form-item
:label=
"$t('datasource.schema')"
v-if=
"form.type=='oracle'"
>
<el-select
v-model=
"form.configuration.schema"
:placeholder=
"$t('datasource.please_choose_schema')"
class=
"select-width"
:disabled=
"formType=='modify'"
>
<el-option
v-for=
"item in schemas"
:key=
"item"
:label=
"item"
:value=
"item"
/>
</el-select>
</el-form-item>
</el-form>
<div
v-if=
"canEdit"
slot=
"footer"
class=
"dialog-footer"
>
<el-button
v-if=
"formType==='add'?true: hasDataPermission('manage',params.privileges)"
@
click=
"validaDatasource"
>
{{ $t('commons.validate') }}
</el-button>
...
...
@@ -61,7 +78,7 @@
<
script
>
import
LayoutContent
from
'@/components/business/LayoutContent'
import
{
addDs
,
editDs
,
validateDs
}
from
'@/api/system/datasource'
import
{
addDs
,
editDs
,
getSchema
,
validateDs
}
from
'@/api/system/datasource'
export
default
{
name
:
'DsForm'
,
components
:
{
LayoutContent
},
...
...
@@ -84,9 +101,11 @@ export default {
'configuration.username'
:
[{
required
:
true
,
message
:
this
.
$t
(
'datasource.please_input_user_name'
),
trigger
:
'blur'
}],
'configuration.password'
:
[{
required
:
true
,
message
:
this
.
$t
(
'datasource.please_input_password'
),
trigger
:
'change'
}],
'configuration.host'
:
[{
required
:
true
,
message
:
this
.
$t
(
'datasource.please_input_host'
),
trigger
:
'change'
}],
'configuration.port'
:
[{
required
:
true
,
message
:
this
.
$t
(
'datasource.please_input_port'
),
trigger
:
'change'
}]
'configuration.port'
:
[{
required
:
true
,
message
:
this
.
$t
(
'datasource.please_input_port'
),
trigger
:
'change'
}],
'configuration.schema'
:
[{
required
:
true
,
message
:
this
.
$t
(
'datasource.please_choose_schema'
),
trigger
:
'change'
}]
},
allTypes
:
[{
name
:
'mysql'
,
label
:
'MySQL'
,
type
:
'jdbc'
},
{
name
:
'oracle'
,
label
:
'Oracle'
,
type
:
'jdbc'
}],
schemas
:
[],
canEdit
:
false
}
},
...
...
@@ -129,10 +148,13 @@ export default {
this
.
$refs
.
dsForm
.
resetFields
()
},
save
()
{
if
(
!
this
.
form
.
configuration
.
schema
){
this
.
$message
.
error
(
this
.
$t
(
'datasource.please_choose_schema'
))
return
}
this
.
$refs
.
dsForm
.
validate
(
valid
=>
{
if
(
valid
)
{
const
method
=
this
.
formType
===
'add'
?
addDs
:
editDs
// this.form.configuration = JSON.stringify(this.form.configuration)
const
form
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
form
))
form
.
configuration
=
JSON
.
stringify
(
form
.
configuration
)
method
(
form
).
then
(
res
=>
{
...
...
@@ -145,12 +167,25 @@ export default {
}
})
},
getSchema
(){
this
.
$refs
.
dsForm
.
validate
(
valid
=>
{
if
(
valid
)
{
const
data
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
form
))
data
.
configuration
=
JSON
.
stringify
(
data
.
configuration
)
getSchema
(
data
).
then
(
res
=>
{
this
.
schemas
=
res
.
data
this
.
$success
(
this
.
$t
(
'datasource.validate_success'
))
})
}
else
{
return
false
}
})
},
validaDatasource
()
{
this
.
$refs
.
dsForm
.
validate
(
valid
=>
{
if
(
valid
)
{
const
data
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
form
))
data
.
configuration
=
JSON
.
stringify
(
data
.
configuration
)
validateDs
(
data
).
then
(
res
=>
{
this
.
$success
(
this
.
$t
(
'datasource.validate_success'
))
})
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论