Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zhu
dataease
Commits
08afbe5e
提交
08afbe5e
authored
4月 24, 2022
作者:
taojinlong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: Oracle 数据源指定字符集
上级
a5d8d6cb
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
71 行增加
和
9 行删除
+71
-9
ProviderFactory.java
...d/src/main/java/io/dataease/provider/ProviderFactory.java
+3
-0
JdbcProvider.java
...in/java/io/dataease/provider/datasource/JdbcProvider.java
+37
-4
en.js
frontend/src/lang/en.js
+2
-0
tw.js
frontend/src/lang/tw.js
+2
-0
zh.js
frontend/src/lang/zh.js
+2
-0
DsConfiguration.vue
frontend/src/views/system/datasource/DsConfiguration.vue
+23
-2
form.vue
frontend/src/views/system/datasource/form.vue
+2
-3
没有找到文件。
backend/src/main/java/io/dataease/provider/ProviderFactory.java
浏览文件 @
08afbe5e
...
...
@@ -26,6 +26,9 @@ public class ProviderFactory implements ApplicationContextAware {
final
ConfigurableListableBeanFactory
beanFactory
=
((
ConfigurableApplicationContext
)
context
).
getBeanFactory
();
if
(
d
.
isDatasource
()){
DataSourceType
dataSourceType
=
new
DataSourceType
(
d
.
getType
(),
d
.
getName
(),
false
,
d
.
getExtraParams
(),
d
.
getCalculationMode
());
if
(
dataSourceType
.
getType
().
equalsIgnoreCase
(
"oracle"
)){
dataSourceType
.
setCharset
(
d
.
getCharset
());
}
beanFactory
.
registerSingleton
(
d
.
getType
(),
dataSourceType
);
}
}
...
...
backend/src/main/java/io/dataease/provider/datasource/JdbcProvider.java
浏览文件 @
08afbe5e
...
...
@@ -195,7 +195,7 @@ public class JdbcProvider extends DefaultJdbcProvider {
try
(
Connection
connection
=
getConnectionFromPool
(
datasourceRequest
);
Statement
stat
=
connection
.
createStatement
();
ResultSet
rs
=
stat
.
executeQuery
(
datasourceRequest
.
getQuery
()))
{
fieldList
=
fetchResultField
(
rs
,
datasourceRequest
);
result
.
put
(
"fieldList"
,
fieldList
);
dataList
=
getDataResult
(
rs
);
dataList
=
getDataResult
(
rs
,
datasourceRequest
);
result
.
put
(
"dataList"
,
dataList
);
return
result
;
}
catch
(
SQLException
e
)
{
...
...
@@ -206,7 +206,14 @@ public class JdbcProvider extends DefaultJdbcProvider {
return
new
HashMap
<>();
}
private
List
<
String
[]>
getDataResult
(
ResultSet
rs
)
throws
Exception
{
private
List
<
String
[]>
getDataResult
(
ResultSet
rs
,
DatasourceRequest
datasourceRequest
)
throws
Exception
{
String
charset
=
null
;
if
(
datasourceRequest
!=
null
&&
datasourceRequest
.
getDatasource
().
getType
().
equalsIgnoreCase
(
"oracle"
)){
JdbcConfiguration
JdbcConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
JdbcConfiguration
.
class
);
if
(
StringUtils
.
isNotEmpty
(
JdbcConfiguration
.
getCharset
())
&&
!
JdbcConfiguration
.
getCharset
().
equalsIgnoreCase
(
"Default"
)
){
charset
=
JdbcConfiguration
.
getCharset
();
}
}
List
<
String
[]>
list
=
new
LinkedList
<>();
ResultSetMetaData
metaData
=
rs
.
getMetaData
();
int
columnCount
=
metaData
.
getColumnCount
();
...
...
@@ -224,7 +231,11 @@ public class JdbcProvider extends DefaultJdbcProvider {
row
[
j
]
=
rs
.
getBoolean
(
j
+
1
)
?
"1"
:
"0"
;
break
;
default
:
row
[
j
]
=
rs
.
getString
(
j
+
1
);
if
(
charset
!=
null
&&
StringUtils
.
isNotEmpty
(
rs
.
getString
(
j
+
1
))){
row
[
j
]
=
new
String
(
rs
.
getString
(
j
+
1
).
getBytes
(
charset
),
"UTF-8"
);
}
else
{
row
[
j
]
=
rs
.
getString
(
j
+
1
);
}
break
;
}
}
...
...
@@ -265,6 +276,23 @@ public class JdbcProvider extends DefaultJdbcProvider {
}
return
fieldList
;
}
@Override
public
List
<
String
[]>
getData
(
DatasourceRequest
dsr
)
throws
Exception
{
List
<
String
[]>
list
=
new
LinkedList
<>();
try
(
Connection
connection
=
getConnectionFromPool
(
dsr
);
Statement
stat
=
connection
.
createStatement
();
ResultSet
rs
=
stat
.
executeQuery
(
dsr
.
getQuery
()))
{
list
=
getDataResult
(
rs
,
dsr
);
if
(
dsr
.
isPageable
()
&&
(
dsr
.
getDatasource
().
getType
().
equalsIgnoreCase
(
DatasourceTypes
.
sqlServer
.
name
())
||
dsr
.
getDatasource
().
getType
().
equalsIgnoreCase
(
DatasourceTypes
.
db2
.
name
())))
{
Integer
realSize
=
dsr
.
getPage
()
*
dsr
.
getPageSize
()
<
list
.
size
()
?
dsr
.
getPage
()
*
dsr
.
getPageSize
()
:
list
.
size
();
list
=
list
.
subList
((
dsr
.
getPage
()
-
1
)
*
dsr
.
getPageSize
(),
realSize
);
}
}
catch
(
SQLException
e
)
{
io
.
dataease
.
plugins
.
common
.
exception
.
DataEaseException
.
throwException
(
"SQL ERROR"
+
e
.
getMessage
());
}
catch
(
Exception
e
)
{
io
.
dataease
.
plugins
.
common
.
exception
.
DataEaseException
.
throwException
(
"Data source connection exception: "
+
e
.
getMessage
());
}
return
list
;
}
@Override
public
Connection
getConnection
(
DatasourceRequest
datasourceRequest
)
throws
Exception
{
...
...
@@ -398,7 +426,12 @@ public class JdbcProvider extends DefaultJdbcProvider {
dataSource
.
setDriverClassName
(
oracleConfiguration
.
getDriver
());
dataSource
.
setUrl
(
oracleConfiguration
.
getJdbc
());
dataSource
.
setValidationQuery
(
"select 1 from dual"
);
jdbcConfiguration
=
oracleConfiguration
;
if
(
StringUtils
.
isNotEmpty
(
oracleConfiguration
.
getCharset
())
&&
!
oracleConfiguration
.
getCharset
().
equalsIgnoreCase
(
"Default"
)){
Properties
props
=
new
Properties
();
props
.
put
(
"serverEncoding"
,
oracleConfiguration
.
getCharset
());
props
.
put
(
"clientEncoding"
,
"UTF-8"
);
jdbcConfiguration
=
oracleConfiguration
;
}
break
;
case
pg:
PgConfiguration
pgConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
PgConfiguration
.
class
);
...
...
frontend/src/lang/en.js
浏览文件 @
08afbe5e
...
...
@@ -1350,6 +1350,8 @@ export default {
get_schema
:
'Get Schema'
,
schema
:
'Database Schema'
,
please_choose_schema
:
'Please select Schema'
,
charset
:
'Charset'
,
please_choose_charset
:
'Please select Charset'
,
edit_datasource_msg
:
'Modifying the data source information may make the data set under the modified data source unavailable. Confirm the modification?'
,
repeat_datasource_msg
:
'Data source information with the same configuration already exists, '
,
confirm_save
:
'Confirm save?'
,
...
...
frontend/src/lang/tw.js
浏览文件 @
08afbe5e
...
...
@@ -1351,6 +1351,8 @@ export default {
get_schema
:
'獲取 Schema'
,
schema
:
'數據庫 Schema'
,
please_choose_schema
:
'請選擇數據庫 Schema'
,
charset
:
'字符集'
,
please_choose_charset
:
'請選擇數據庫字符集'
,
edit_datasource_msg
:
'修改數據源信息,可能會導致改數據源下的數據集不可用,確認修改?'
,
repeat_datasource_msg
:
'已經存在相同配置的數據源信息,'
,
confirm_save
:
'確認保存?'
,
...
...
frontend/src/lang/zh.js
浏览文件 @
08afbe5e
...
...
@@ -1357,7 +1357,9 @@ export default {
oracle_service_name
:
'服务名'
,
get_schema
:
'获取 Schema'
,
schema
:
'数据库 Schema'
,
charset
:
'字符集'
,
please_choose_schema
:
'请选择数据库 Schema'
,
please_choose_charset
:
'请选择数据库字符集'
,
edit_datasource_msg
:
'修改数据源信息,可能会导致该数据源下的数据集不可用,确认修改?'
,
repeat_datasource_msg
:
'已经存在相同配置的数据源信息, '
,
confirm_save
:
'确认保存?'
,
...
...
frontend/src/views/system/datasource/DsConfiguration.vue
浏览文件 @
08afbe5e
...
...
@@ -177,6 +177,13 @@
</el-select>
</el-form-item>
<el-form-item
v-if=
"form.type=='oracle'"
:label=
"$t('datasource.charset')"
>
<el-select
v-model=
"form.configuration.charset"
filterable
:placeholder=
"$t('datasource.please_choose_charset')"
class=
"select-width"
>
<el-option
v-for=
"item in datasourceType.charset"
:key=
"item"
:label=
"item"
:value=
"item"
/>
</el-select>
</el-form-item>
<el-collapse
v-if=
"form.type !=='es' && form.type !== 'api' && form.type !== 'mongo'"
>
<el-collapse-item
:title=
"$t('datasource.priority')"
name=
"1"
>
<el-form-item
:label=
"$t('datasource.initial_pool_size')"
prop=
"configuration.initialPoolSize"
>
...
...
@@ -203,7 +210,7 @@
import
i18n
from
"@/lang"
;
import
{
checkApiDatasource
}
from
"@/api/system/datasource"
;
import
{
checkApiDatasource
,
getSchema
}
from
"@/api/system/datasource"
;
import
ApiHttpRequestForm
from
'@/views/system/datasource/ApiHttpRequestForm'
import
LayoutContent
from
'@/components/business/LayoutContent'
...
...
@@ -223,6 +230,7 @@ export default {
method
:
String
,
request
:
{},
response
:
{},
datasourceType
:
{},
showScript
:
{
type
:
Boolean
,
default
:
true
,
...
...
@@ -369,7 +377,20 @@ export default {
},
methods
:
{
getSchema
()
{
this
.
$refs
.
DsConfig
.
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
(
i18n
.
t
(
'commons.success'
))
})
}
else
{
return
false
}
})
},
next
()
{
if
(
this
.
active
===
1
)
{
let
hasRepeatName
=
false
...
...
frontend/src/views/system/datasource/form.vue
浏览文件 @
08afbe5e
...
...
@@ -41,7 +41,7 @@
</el-select>
</el-form-item>
<ds-configuration
ref=
"dsConfig"
v-if=
"!datasourceType.isPlugin"
:form=
"form"
:disabled=
"params && params.id && params.showModel && params.showModel === 'show' && !canEdit"
></ds-configuration>
<ds-configuration
ref=
"dsConfig"
v-if=
"!datasourceType.isPlugin"
:
datasource-type=
'datasourceType'
:
form=
"form"
:disabled=
"params && params.id && params.showModel && params.showModel === 'show' && !canEdit"
></ds-configuration>
<plugin-com
ref=
"pluginDsConfig"
v-if=
"datasourceType.isPlugin"
:component-name=
"datasourceType.type"
:obj=
"{form, disabled }"
/>
...
...
@@ -352,7 +352,7 @@ export default {
if
(
this
.
datasourceType
.
isPlugin
){
status
=
this
.
$refs
[
'pluginDsConfig'
].
callPluginInner
({
methodName
:
'validate'
})
}
else
{
status
=
this
.
$refs
[
'dsConfig'
].
$refs
[
'DsConfig'
].
validate
(
valid
=>
{
this
.
$refs
[
'dsConfig'
].
$refs
[
'DsConfig'
].
validate
(
valid
=>
{
status
=
valid
})
}
...
...
@@ -424,7 +424,6 @@ export default {
})
},
validaDatasource
()
{
console
.
log
(
this
.
$refs
)
if
(
!
this
.
form
.
configuration
.
schema
&&
this
.
form
.
type
===
'oracle'
)
{
this
.
$message
.
error
(
i18n
.
t
(
'datasource.please_choose_schema'
))
return
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论