Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
datax-cloud
Overview
Overview
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
黄营
datax-cloud
Commits
d99fc897
Commit
d99fc897
authored
Jun 19, 2020
by
yuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2.0.0项目初始化
parent
9a857bbd
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
111 additions
and
16 deletions
+111
-16
DataSourceServiceFeign.java
...ervice/data/factory/api/feign/DataSourceServiceFeign.java
+1
-1
DateHander.java
...rvice/data/factory/sql/console/concurrent/DateHander.java
+71
-11
SqlConsoleServiceImpl.java
...ctory/sql/console/service/impl/SqlConsoleServiceImpl.java
+10
-2
index.vue
datax-ui/src/views/factory/console/index.vue
+28
-1
UserAdd.vue
datax-ui/src/views/system/user/UserAdd.vue
+1
-1
No files found.
datax-modules/data-factory-service-parent/data-factory-service-api/src/main/java/cn/datax/service/data/factory/api/feign/DataSourceServiceFeign.java
View file @
d99fc897
...
@@ -9,6 +9,6 @@ import org.springframework.web.bind.annotation.PathVariable;
...
@@ -9,6 +9,6 @@ import org.springframework.web.bind.annotation.PathVariable;
@FeignClient
(
contextId
=
"dataSourceServiceFeign"
,
value
=
"datax-service-data-factory"
,
fallbackFactory
=
DataSourceServiceFeignFallbackFactory
.
class
)
@FeignClient
(
contextId
=
"dataSourceServiceFeign"
,
value
=
"datax-service-data-factory"
,
fallbackFactory
=
DataSourceServiceFeignFallbackFactory
.
class
)
public
interface
DataSourceServiceFeign
{
public
interface
DataSourceServiceFeign
{
@GetMapping
(
"/dataSource/{id}"
)
@GetMapping
(
"/dataSource
s
/{id}"
)
R
getDataSourceById
(
@PathVariable
(
"id"
)
String
id
);
R
getDataSourceById
(
@PathVariable
(
"id"
)
String
id
);
}
}
datax-modules/data-factory-service-parent/data-factory-service-sql-console/src/main/java/cn/datax/service/data/factory/sql/console/concurrent/DateHander.java
View file @
d99fc897
...
@@ -3,6 +3,8 @@ package cn.datax.service.data.factory.sql.console.concurrent;
...
@@ -3,6 +3,8 @@ package cn.datax.service.data.factory.sql.console.concurrent;
import
cn.datax.service.data.factory.api.vo.SqlConsoleVo
;
import
cn.datax.service.data.factory.api.vo.SqlConsoleVo
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
java.io.BufferedReader
;
import
java.io.Reader
;
import
java.sql.*
;
import
java.sql.*
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -52,20 +54,78 @@ public class DateHander extends CallableTemplate<SqlConsoleVo> {
...
@@ -52,20 +54,78 @@ public class DateHander extends CallableTemplate<SqlConsoleVo> {
ResultSetMetaData
rsmd
=
rs
.
getMetaData
();
ResultSetMetaData
rsmd
=
rs
.
getMetaData
();
// 获取列字段的个数
// 获取列字段的个数
int
colunmCount
=
rsmd
.
getColumnCount
();
int
colunmCount
=
rsmd
.
getColumnCount
();
// 存储列名的数组
String
[]
columnNames
=
new
String
[
colunmCount
];
for
(
int
i
=
0
;
i
<
colunmCount
;
i
++)
{
// 获取所有的字段名称
columnNames
[
i
]
=
rsmd
.
getColumnLabel
(
i
+
1
);
}
while
(
rs
.
next
()){
while
(
rs
.
next
()){
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
for
(
int
i
=
0
;
i
<
colunmCount
;
i
++)
{
for
(
int
i
=
1
;
i
<=
colunmCount
;
i
++)
{
// 获取列名
// 获取列名
String
columnName
=
columnNames
[
i
];
String
columnName
=
rsmd
.
getColumnName
(
i
);
// 获取该列对应的值
Object
val
=
null
;
Object
value
=
rs
.
getObject
(
columnName
);
switch
(
rsmd
.
getColumnType
(
i
))
{
map
.
put
(
columnName
,
value
);
case
Types
.
ARRAY
:
val
=
rs
.
getArray
(
columnName
);
break
;
case
Types
.
BIGINT
:
val
=
rs
.
getLong
(
columnName
);
break
;
case
Types
.
BOOLEAN
:
case
Types
.
BIT
:
val
=
rs
.
getBoolean
(
columnName
);
break
;
case
Types
.
DOUBLE
:
val
=
rs
.
getDouble
(
columnName
);
break
;
case
Types
.
FLOAT
:
case
Types
.
REAL
:
val
=
rs
.
getFloat
(
columnName
);
break
;
case
Types
.
INTEGER
:
val
=
rs
.
getInt
(
columnName
);
break
;
case
Types
.
NVARCHAR
:
case
Types
.
NCHAR
:
case
Types
.
LONGNVARCHAR
:
val
=
rs
.
getNString
(
columnName
);
break
;
case
Types
.
VARCHAR
:
case
Types
.
CHAR
:
case
Types
.
LONGVARCHAR
:
val
=
rs
.
getString
(
columnName
);
break
;
case
Types
.
TINYINT
:
case
Types
.
BINARY
:
case
Types
.
VARBINARY
:
val
=
rs
.
getByte
(
columnName
);
break
;
case
Types
.
SMALLINT
:
val
=
rs
.
getShort
(
columnName
);
break
;
case
Types
.
DATE
:
val
=
rs
.
getDate
(
columnName
);
break
;
case
Types
.
TIME
:
val
=
rs
.
getTime
(
columnName
);
break
;
case
Types
.
TIMESTAMP
:
val
=
rs
.
getTimestamp
(
columnName
);
break
;
case
Types
.
NUMERIC
:
case
Types
.
DECIMAL
:
val
=
rs
.
getBigDecimal
(
columnName
);
break
;
case
Types
.
BLOB
:
case
Types
.
CLOB
:
case
Types
.
LONGVARBINARY
:
case
Types
.
DATALINK
:
case
Types
.
REF
:
case
Types
.
STRUCT
:
case
Types
.
DISTINCT
:
case
Types
.
JAVA_OBJECT
:
break
;
default
:
val
=
rs
.
getObject
(
columnName
);
break
;
}
map
.
put
(
columnName
,
val
);
}
}
list
.
add
(
map
);
list
.
add
(
map
);
}
}
...
...
datax-modules/data-factory-service-parent/data-factory-service-sql-console/src/main/java/cn/datax/service/data/factory/sql/console/service/impl/SqlConsoleServiceImpl.java
View file @
d99fc897
...
@@ -16,7 +16,8 @@ import cn.datax.service.data.factory.sql.console.concurrent.DateHander;
...
@@ -16,7 +16,8 @@ import cn.datax.service.data.factory.sql.console.concurrent.DateHander;
import
cn.datax.service.data.factory.sql.console.service.SqlConsoleService
;
import
cn.datax.service.data.factory.sql.console.service.SqlConsoleService
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
net.sf.jsqlparser.JSQLParserException
;
import
net.sf.jsqlparser.JSQLParserException
;
import
net.sf.jsqlparser.parser.CCJSqlParserUtil
;
import
net.sf.jsqlparser.parser.CCJSqlParserUtil
;
...
@@ -42,6 +43,9 @@ public class SqlConsoleServiceImpl implements SqlConsoleService {
...
@@ -42,6 +43,9 @@ public class SqlConsoleServiceImpl implements SqlConsoleService {
@Autowired
@Autowired
private
DataSourceServiceFeign
dataSourceServiceFeign
;
private
DataSourceServiceFeign
dataSourceServiceFeign
;
@Autowired
private
ObjectMapper
objectMapper
;
private
static
Map
<
String
,
List
<
Connection
>>
connectionMap
=
new
ConcurrentHashMap
<>();
private
static
Map
<
String
,
List
<
Connection
>>
connectionMap
=
new
ConcurrentHashMap
<>();
@Override
@Override
...
@@ -62,7 +66,11 @@ public class SqlConsoleServiceImpl implements SqlConsoleService {
...
@@ -62,7 +66,11 @@ public class SqlConsoleServiceImpl implements SqlConsoleService {
if
(
sourceResult
==
null
||
!
sourceResult
.
isSuccess
()
||
ObjectUtil
.
isEmpty
(
sourceResult
.
getData
())){
if
(
sourceResult
==
null
||
!
sourceResult
.
isSuccess
()
||
ObjectUtil
.
isEmpty
(
sourceResult
.
getData
())){
throw
new
DataException
(
"SQL工作台查询数据源出错"
);
throw
new
DataException
(
"SQL工作台查询数据源出错"
);
}
}
DataSourceEntity
dataSource
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
sourceResult
.
getData
()),
DataSourceEntity
.
class
);
DataSourceEntity
dataSource
=
null
;
try
{
dataSource
=
objectMapper
.
readValue
(
objectMapper
.
writeValueAsString
(
sourceResult
.
getData
()),
DataSourceEntity
.
class
);
}
catch
(
JsonProcessingException
e
)
{
}
DbSchema
dbSchema
=
dataSource
.
getDbSchema
();
DbSchema
dbSchema
=
dataSource
.
getDbSchema
();
DbQueryProperty
dbQueryProperty
=
new
DbQueryProperty
(
dataSource
.
getDbType
(),
dbSchema
.
getHost
(),
DbQueryProperty
dbQueryProperty
=
new
DbQueryProperty
(
dataSource
.
getDbType
(),
dbSchema
.
getHost
(),
dbSchema
.
getUsername
(),
dbSchema
.
getPassword
(),
dbSchema
.
getPort
(),
dbSchema
.
getDbName
());
dbSchema
.
getUsername
(),
dbSchema
.
getPassword
(),
dbSchema
.
getPort
(),
dbSchema
.
getDbName
());
...
...
datax-ui/src/views/factory/console/index.vue
View file @
d99fc897
...
@@ -15,6 +15,19 @@
...
@@ -15,6 +15,19 @@
</el-row>
</el-row>
<el-row>
<el-row>
<el-col
:span=
"24"
>
<el-col
:span=
"24"
>
<el-select
v-model=
"sqlDataSource"
placeholder=
"请选择数据源"
>
<el-option
v-for=
"source in sourceOptions"
:key=
"source.id"
:label=
"source.sourceName"
:value=
"source.id"
:disabled=
"source.status === '0'"
></el-option>
</el-select>
</el-col>
</el-row>
<el-row>
<el-col
:span=
"24"
>
<sql-editor
<sql-editor
ref=
"sqleditor"
ref=
"sqleditor"
:value=
"sqlText"
:value=
"sqlText"
...
@@ -48,6 +61,7 @@
...
@@ -48,6 +61,7 @@
<
script
>
<
script
>
import
sqlFormatter
from
'sql-formatter'
import
sqlFormatter
from
'sql-formatter'
import
SqlEditor
from
'@/components/SqlEditor'
import
SqlEditor
from
'@/components/SqlEditor'
import
{
listDataSource
}
from
'@/api/factory/datasource'
export
default
{
export
default
{
name
:
'SqlConsole'
,
name
:
'SqlConsole'
,
...
@@ -61,15 +75,28 @@ export default {
...
@@ -61,15 +75,28 @@ export default {
height
:
document
.
body
.
offsetHeight
-
240
+
'px'
height
:
document
.
body
.
offsetHeight
-
240
+
'px'
},
},
title
:
'SQL工作台'
,
title
:
'SQL工作台'
,
// 数据源数据字典
sourceOptions
:
[],
sqlDataSource
:
''
,
sqlText
:
''
,
sqlExecuting
:
false
,
sqlExecuting
:
false
,
activeTabName
:
'table0'
,
activeTabName
:
'table0'
,
sqlExecutorId
:
undefined
,
sqlExecutorId
:
undefined
,
sqlText
:
''
,
sqlConsole
:
[],
sqlConsole
:
[],
executeResultInfo
:
''
executeResultInfo
:
''
}
}
},
},
created
()
{
this
.
getDataSourceList
()
},
methods
:
{
methods
:
{
getDataSourceList
()
{
listDataSource
().
then
(
response
=>
{
if
(
response
.
success
)
{
this
.
sourceOptions
=
response
.
data
}
})
},
runData
()
{
runData
()
{
this
.
sqlExecuting
=
true
this
.
sqlExecuting
=
true
this
.
sqlExecutorId
=
(
new
Date
()).
getTime
()
this
.
sqlExecutorId
=
(
new
Date
()).
getTime
()
...
...
datax-ui/src/views/system/user/UserAdd.vue
View file @
d99fc897
...
@@ -166,7 +166,7 @@ export default {
...
@@ -166,7 +166,7 @@ export default {
this
.
statusOptions
=
response
.
data
this
.
statusOptions
=
response
.
data
}
}
})
})
this
.
getConfigKey
(
'sys.user.
initP
assword'
).
then
(
response
=>
{
this
.
getConfigKey
(
'sys.user.
p
assword'
).
then
(
response
=>
{
if
(
response
.
success
)
{
if
(
response
.
success
)
{
this
.
initPassword
=
response
.
data
this
.
initPassword
=
response
.
data
this
.
form
.
password
=
this
.
initPassword
this
.
form
.
password
=
this
.
initPassword
...
...
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