Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zhu
dataease
Commits
a0146d9c
提交
a0146d9c
authored
2月 22, 2021
作者:
taojinlong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 获取表的colume属性
上级
99a617e1
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
112 行增加
和
36 行删除
+112
-36
TableFiled.java
.../src/main/java/io/dataease/datasource/dto/TableFiled.java
+15
-0
DatasourceProvider.java
...a/io/dataease/datasource/provider/DatasourceProvider.java
+6
-0
JdbcProvider.java
...in/java/io/dataease/datasource/provider/JdbcProvider.java
+86
-6
Datasource.vue
...nd/src/business/components/settings/system/Datasource.vue
+4
-30
zh-CN.js
frontend/src/i18n/zh-CN.js
+1
-0
没有找到文件。
backend/src/main/java/io/dataease/datasource/dto/TableFiled.java
0 → 100644
浏览文件 @
a0146d9c
package
io
.
dataease
.
datasource
.
dto
;
import
lombok.Getter
;
import
lombok.Setter
;
@Setter
@Getter
public
class
TableFiled
{
private
String
fieldName
;
private
String
remarks
;
private
String
fieldType
;
private
int
fieldSize
;
}
backend/src/main/java/io/dataease/datasource/provider/DatasourceProvider.java
浏览文件 @
a0146d9c
package
io
.
dataease
.
datasource
.
provider
;
import
io.dataease.base.domain.Datasource
;
import
io.dataease.datasource.dto.TableFiled
;
import
java.util.ArrayList
;
import
java.util.List
;
public
abstract
class
DatasourceProvider
{
...
...
@@ -31,6 +33,10 @@ public abstract class DatasourceProvider {
abstract
public
List
<
String
>
getTables
()
throws
Exception
;
public
List
<
TableFiled
>
getTableFileds
(
String
table
)
throws
Exception
{
return
new
ArrayList
<>();
};
public
void
test
()
throws
Exception
{
getData
();
}
...
...
backend/src/main/java/io/dataease/datasource/provider/JdbcProvider.java
浏览文件 @
a0146d9c
...
...
@@ -3,15 +3,14 @@ package io.dataease.datasource.provider;
import
com.google.gson.Gson
;
import
io.dataease.datasource.constants.DatasourceTypes
;
import
io.dataease.datasource.dto.MysqlConfigrationDTO
;
import
io.dataease.datasource.dto.TableFiled
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
import
java.sql.*
;
import
java.util.ArrayList
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.*
;
import
io.dataease.datasource.constants.DatasourceTypes.*
;
import
java.util.Properties
;
@Service
(
"jdbc"
)
...
...
@@ -42,7 +41,9 @@ public class JdbcProvider extends DatasourceProvider{
}
list
.
add
(
row
);
}
}
catch
(
Exception
e
)
{
}
catch
(
SQLException
e
){
throw
new
Exception
(
"ERROR:"
+
e
.
getMessage
(),
e
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"ERROR:"
+
e
.
getMessage
(),
e
);
}
return
list
;
...
...
@@ -64,6 +65,39 @@ public class JdbcProvider extends DatasourceProvider{
return
tables
;
}
@Override
public
List
<
TableFiled
>
getTableFileds
(
String
table
)
throws
Exception
{
List
<
TableFiled
>
list
=
new
LinkedList
<>();
try
(
Connection
connection
=
getConnection
();
)
{
DatabaseMetaData
databaseMetaData
=
connection
.
getMetaData
();
ResultSet
resultSet
=
databaseMetaData
.
getColumns
(
null
,
"%"
,
table
.
toUpperCase
(),
"%"
);
while
(
resultSet
.
next
())
{
String
tableName
=
resultSet
.
getString
(
"TABLE_NAME"
);
String
database
=
resultSet
.
getString
(
"TABLE_CAT"
);
if
(
tableName
.
equals
(
table
)
&&
database
.
equalsIgnoreCase
(
getDatabase
())){
TableFiled
tableFiled
=
new
TableFiled
();
String
colName
=
resultSet
.
getString
(
"COLUMN_NAME"
);
tableFiled
.
setFieldName
(
colName
);
String
remarks
=
resultSet
.
getString
(
"REMARKS"
);
if
(
remarks
==
null
||
remarks
.
equals
(
""
)){
remarks
=
colName
;
}
tableFiled
.
setRemarks
(
remarks
);
String
dbType
=
resultSet
.
getString
(
"TYPE_NAME"
);
tableFiled
.
setFieldType
(
dbType
);
list
.
add
(
tableFiled
);
}
}
}
catch
(
SQLException
e
){
throw
new
Exception
(
"ERROR:"
+
e
.
getMessage
(),
e
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"ERROR:"
+
e
.
getMessage
(),
e
);
}
return
list
;
};
@Override
public
void
test
()
throws
Exception
{
String
queryStr
=
"show tables"
;
...
...
@@ -74,7 +108,6 @@ public class JdbcProvider extends DatasourceProvider{
}
}
private
Connection
getConnection
()
throws
Exception
{
String
username
=
null
;
String
password
=
null
;
...
...
@@ -102,4 +135,51 @@ public class JdbcProvider extends DatasourceProvider{
return
DriverManager
.
getConnection
(
jdbcurl
,
props
);
}
private
String
getDatabase
(){
DatasourceTypes
datasourceType
=
DatasourceTypes
.
valueOf
(
getDatasource
().
getType
());
switch
(
datasourceType
)
{
case
mysql:
MysqlConfigrationDTO
mysqlConfigrationDTO
=
new
Gson
().
fromJson
(
getDatasource
().
getConfiguration
(),
MysqlConfigrationDTO
.
class
);
return
mysqlConfigrationDTO
.
getDataBase
();
default
:
return
null
;
}
}
private
static
String
getSchema
(
Connection
conn
)
throws
Exception
{
String
schema
;
schema
=
conn
.
getMetaData
().
getUserName
();
System
.
out
.
println
(
schema
);
if
((
schema
==
null
)
||
(
schema
.
length
()
==
0
))
{
throw
new
Exception
(
"ORACLE数据库模式不允许为空"
);
}
return
schema
.
toUpperCase
().
toString
();
}
private
static
String
changeDbType
(
String
dbType
)
{
dbType
=
dbType
.
toUpperCase
();
switch
(
dbType
){
case
"VARCHAR"
:
case
"VARCHAR2"
:
case
"CHAR"
:
return
"1"
;
case
"NUMBER"
:
case
"DECIMAL"
:
return
"4"
;
case
"INT"
:
case
"SMALLINT"
:
case
"INTEGER"
:
return
"2"
;
case
"BIGINT"
:
return
"6"
;
case
"DATETIME"
:
case
"TIMESTAMP"
:
case
"DATE"
:
return
"7"
;
default
:
return
"1"
;
}
}
}
frontend/src/business/components/settings/system/Datasource.vue
浏览文件 @
a0146d9c
...
...
@@ -21,34 +21,6 @@
:total=
"total"
/>
</el-card>
<!-- dialog of organization member -->
<el-dialog
:close-on-click-modal=
"false"
:visible
.
sync=
"dialogDatasourceMemberVisible"
width=
"70%"
:destroy-on-close=
"true"
@
close=
"closeFunc"
class=
"dialog-css"
>
<ms-table-header
:condition
.
sync=
"dialogCondition"
@
create=
"addMember"
@
search=
"dialogSearch"
:create-tip=
"$t('member.create')"
:title=
"$t('commons.member')"
/>
<!-- organization member table -->
<el-table
:border=
"true"
class=
"adjust-table"
:data=
"memberLineData"
style=
"width: 100%;margin-top:5px;"
>
<el-table-column
prop=
"id"
label=
"ID"
/>
<el-table-column
prop=
"name"
:label=
"$t('commons.username')"
/>
<el-table-column
prop=
"email"
:label=
"$t('commons.email')"
/>
<el-table-column
prop=
"phone"
:label=
"$t('commons.phone')"
/>
<el-table-column
:label=
"$t('commons.role')"
width=
"140"
>
<
template
v-slot:default=
"scope"
>
<ms-roles-tag
:roles=
"scope.row.roles"
/>
</
template
>
</el-table-column>
<el-table-column
:label=
"$t('commons.operating')"
>
<
template
v-slot:default=
"scope"
>
<ms-table-operator
:tip2=
"$t('commons.remove')"
@
editClick=
"editMember(scope.row)"
@
deleteClick=
"delMember(scope.row)"
/>
</
template
>
</el-table-column>
</el-table>
<ms-table-pagination
:change=
"dialogSearch"
:current-page
.
sync=
"dialogCurrentPage"
:page-size
.
sync=
"dialogPageSize"
:total=
"dialogTotal"
/>
</el-dialog>
<!-- add datasource form -->
<el-dialog
:close-on-click-modal=
"false"
:title=
"$t('datasource.create')"
:visible
.
sync=
"dialogDatasourceAddVisible"
width=
"30%"
@
closed=
"closeFunc"
:destroy-on-close=
"true"
>
...
...
@@ -90,7 +62,8 @@
</el-form>
<
template
v-slot:footer
>
<ms-dialog-footer
is-show-validate=
"true"
<ms-dialog-footer
:isShowValidate=
"true"
@
cancel=
"dialogDatasourceAddVisible = false"
@
validate=
"validaDatasource('createDatasource')"
@
confirm=
"createDatasource('createDatasource')"
/>
...
...
@@ -128,7 +101,8 @@
</el-form-item>
</el-form>
<
template
v-slot:footer
>
<ms-dialog-footer
is-show-validate=
"true"
<ms-dialog-footer
:isShowValidate=
"true"
@
cancel=
"dialogDatasourceUpdateVisible = false"
@
validate=
"validaDatasource('updateDatasourceForm')"
@
confirm=
"updateDatasource('updateDatasourceForm')"
/>
...
...
frontend/src/i18n/zh-CN.js
浏览文件 @
a0146d9c
...
...
@@ -1558,6 +1558,7 @@ export default {
please_input_host
:
'请输入主机'
,
please_input_port
:
'请输入端口'
,
modify
:
'修改组织'
,
validate_success
:
'校验成功'
,
delete
:
'删除组织'
,
delete_confirm
:
'删除该组织会关联删除该组织下的所有资源(如:相关工作空间,项目,测试用例等),确定要删除吗?'
,
input_name
:
'请输入名称'
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论