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
d56575fe
Commit
d56575fe
authored
Apr 28, 2020
by
yuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2.0.0项目初始化
parent
bb5b9c28
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
79 additions
and
57 deletions
+79
-57
SpringContextHolder.java
.../main/java/cn/datax/common/utils/SpringContextHolder.java
+0
-13
DbQueryProperty.java
...a/cn/datax/common/database/constants/DbQueryProperty.java
+3
-3
DbType.java
.../main/java/cn/datax/common/database/constants/DbType.java
+14
-14
DictAnalysis.java
.../java/cn/datax/common/dictionary/config/DictAnalysis.java
+8
-6
DictUtil.java
.../main/java/cn/datax/common/dictionary/utils/DictUtil.java
+30
-16
RedisService.java
...main/java/cn/datax/common/redis/service/RedisService.java
+1
-1
DataSourceDto.java
.../cn/datax/service/data/factory/api/dto/DataSourceDto.java
+1
-1
DataSourceEntity.java
...tax/service/data/factory/api/entity/DataSourceEntity.java
+1
-1
DataSourceVo.java
...va/cn/datax/service/data/factory/api/vo/DataSourceVo.java
+1
-1
RoleVo.java
.../src/main/java/cn/datax/service/system/api/vo/RoleVo.java
+1
-0
DictController.java
...va/cn/datax/service/system/controller/DictController.java
+12
-0
DictServiceImpl.java
...cn/datax/service/system/service/impl/DictServiceImpl.java
+7
-1
No files found.
datax-common/datax-common-core/src/main/java/cn/datax/common/utils/SpringContextHolder.java
View file @
d56575fe
...
...
@@ -5,7 +5,6 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.DisposableBean
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.context.ApplicationEvent
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.stereotype.Component
;
...
...
@@ -58,18 +57,6 @@ public class SpringContextHolder implements ApplicationContextAware, DisposableB
}
/**
* 发布事件
*
* @param event
*/
public
static
void
publishEvent
(
ApplicationEvent
event
)
{
if
(
applicationContext
==
null
)
{
return
;
}
applicationContext
.
publishEvent
(
event
);
}
/**
* 实现DisposableBean接口, 在Context关闭时清理静态变量.
*/
@Override
...
...
datax-common/datax-common-database/src/main/java/cn/datax/common/database/constants/DbQueryProperty.java
View file @
d56575fe
...
...
@@ -13,7 +13,7 @@ public class DbQueryProperty implements Serializable {
private
static
final
long
serialVersionUID
=
1L
;
private
String
dbType
;
private
Integer
dbType
;
private
String
host
;
private
String
username
;
private
String
password
;
...
...
@@ -24,12 +24,12 @@ public class DbQueryProperty implements Serializable {
* 参数合法性校验
*/
public
void
viald
()
{
if
(
StringUtils
.
isEmpty
(
dbType
)
||
StringUtils
.
isEmpty
(
host
)
||
if
(
null
==
dbType
||
StringUtils
.
isEmpty
(
host
)
||
StringUtils
.
isEmpty
(
username
)
||
StringUtils
.
isEmpty
(
password
)
||
StringUtils
.
isEmpty
(
port
)
||
StringUtils
.
isEmpty
(
dbName
))
{
throw
new
DataQueryException
(
"参数不完整"
);
}
if
(
DbType
.
OTHER
.
getDb
()
.
equals
(
dbType
)
)
{
if
(
DbType
.
OTHER
.
getDb
()
==
dbType
)
{
throw
new
DataQueryException
(
"不支持的数据库类型"
);
}
}
...
...
datax-common/datax-common-database/src/main/java/cn/datax/common/database/constants/DbType.java
View file @
d56575fe
...
...
@@ -11,40 +11,40 @@ public enum DbType {
/**
* MYSQL
*/
MYSQL
(
"mysql"
,
"MySql数据库"
,
"jdbc:mysql://${host}:${port}/${dbName}?serverTimezone=GMT%2B8&characterEncoding=UTF-8&useUnicode=true&useSSL=false"
),
MYSQL
(
1
,
"MySql数据库"
,
"jdbc:mysql://${host}:${port}/${dbName}?serverTimezone=GMT%2B8&characterEncoding=UTF-8&useUnicode=true&useSSL=false"
),
/**
* MARIADB
*/
MARIADB
(
"mariadb"
,
"MariaDB数据库"
,
"jdbc:mariadb://${host}:${port}/${dbName}"
),
MARIADB
(
2
,
"MariaDB数据库"
,
"jdbc:mariadb://${host}:${port}/${dbName}"
),
/**
* ORACLE
*/
ORACLE
(
"oracle"
,
"Oracle11g及以下数据库"
,
"jdbc:oracle:thin:@${host}:${port}:${dbName}"
),
ORACLE
(
3
,
"Oracle11g及以下数据库"
,
"jdbc:oracle:thin:@${host}:${port}:${dbName}"
),
/**
* oracle12c new pagination
*/
ORACLE_12C
(
"oracle12c"
,
"Oracle12c+数据库"
,
"jdbc:oracle:thin:@${host}:${port}:${dbName}"
),
ORACLE_12C
(
4
,
"Oracle12c+数据库"
,
"jdbc:oracle:thin:@${host}:${port}:${dbName}"
),
/**
* POSTGRE
* POSTGRE
SQL
*/
POSTGRE_SQL
(
"postgresql"
,
"Postgre
数据库"
,
"jdbc:postgresql://${host}:${port}/${dbName}"
),
POSTGRE_SQL
(
5
,
"PostgreSql
数据库"
,
"jdbc:postgresql://${host}:${port}/${dbName}"
),
/**
* SQLSERVER2005
*/
SQL_SERVER2008
(
"sqlserver2008"
,
"SQLServer2008及以下数据库"
,
"jdbc:sqlserver://${host}:${port};DatabaseName=${dbName}"
),
SQL_SERVER2008
(
6
,
"SQLServer2008及以下数据库"
,
"jdbc:sqlserver://${host}:${port};DatabaseName=${dbName}"
),
/**
* SQLSERVER
*/
SQL_SERVER
(
"sqlserver"
,
"SQLServer2012+数据库"
,
"jdbc:sqlserver://${host}:${port};DatabaseName=${dbName}"
),
SQL_SERVER
(
7
,
"SQLServer2012+数据库"
,
"jdbc:sqlserver://${host}:${port};DatabaseName=${dbName}"
),
/**
* UNKONWN DB
*/
OTHER
(
"other"
,
"其他数据库"
,
""
);
OTHER
(
8
,
"其他数据库"
,
""
);
/**
* 数据库名称
*/
private
final
String
db
;
private
final
Integer
db
;
/**
* 描述
...
...
@@ -56,7 +56,7 @@ public enum DbType {
*/
private
final
String
url
;
public
String
getDb
()
{
public
Integer
getDb
()
{
return
this
.
db
;
}
...
...
@@ -68,7 +68,7 @@ public enum DbType {
return
this
.
url
;
}
DbType
(
String
db
,
String
desc
,
String
url
)
{
DbType
(
Integer
db
,
String
desc
,
String
url
)
{
this
.
db
=
db
;
this
.
desc
=
desc
;
this
.
url
=
url
;
...
...
@@ -79,9 +79,9 @@ public enum DbType {
*
* @param dbType 数据库类型字符串
*/
public
static
DbType
getDbType
(
String
dbType
)
{
public
static
DbType
getDbType
(
Integer
dbType
)
{
for
(
DbType
type
:
DbType
.
values
())
{
if
(
type
.
db
.
equalsIgnoreCase
(
dbType
)
)
{
if
(
type
.
db
==
dbType
)
{
return
type
;
}
}
...
...
datax-common/datax-common-dictionary/src/main/java/cn/datax/common/dictionary/config/DictAnalysis.java
View file @
d56575fe
...
...
@@ -45,12 +45,14 @@ public class DictAnalysis implements ResponseBodyAdvice {
if
(
null
!=
dictAop
)
{
String
code
=
dictAop
.
code
();
String
text
=
field
.
getName
();
System
.
out
.
println
(
"code:"
+
code
);
System
.
out
.
println
(
"field:"
+
text
);
System
.
out
.
println
(
"value:"
+
item
.
get
(
field
.
getName
()));
// 字典翻译
String
dictValue
=
DictUtil
.
getInstance
().
getDictItemValue
(
code
,
text
);
item
.
put
(
field
.
getName
()
+
"_dictText"
,
dictValue
);
Object
object
=
item
.
get
(
field
.
getName
());
if
(
null
!=
object
)
{
// 字典翻译
Object
dictValue
=
DictUtil
.
getInstance
().
getDictItemValue
(
code
,
object
.
toString
());
if
(
null
!=
dictValue
)
{
item
.
put
(
field
.
getName
()
+
"_dictText"
,
dictValue
);
}
}
}
}
items
.
add
(
item
);
...
...
datax-common/datax-common-dictionary/src/main/java/cn/datax/common/dictionary/utils/DictUtil.java
View file @
d56575fe
package
cn
.
datax
.
common
.
dictionary
.
utils
;
import
cn.datax.common.redis.service.RedisService
;
import
cn.datax.common.utils.SpringContextHolder
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Slf4j
public
class
DictUtil
{
...
...
@@ -22,24 +28,22 @@ public class DictUtil {
return
instance
;
}
@Autowired
private
RedisService
redisService
;
static
{
initDictionary
();
}
// 初始化字典数据
private
static
void
initDictionary
()
{
log
.
info
(
"DictUtil初始化中..."
);
}
private
RedisService
redisService
=
SpringContextHolder
.
getBean
(
RedisService
.
class
);
/**
* 获取字典项
* @param code
*/
public
void
getDictItemList
(
String
code
)
{
public
Object
getDictItemList
(
String
code
)
{
String
key
=
"data:system:dicts"
;
Object
object
=
redisService
.
get
(
key
);
if
(
null
==
object
)
{
return
null
;
}
JSONArray
jsonArray
=
JSONArray
.
parseArray
(
JSON
.
toJSONString
(
object
));
List
<
Object
>
list
=
jsonArray
.
stream
().
filter
(
obj
->
((
JSONObject
)
obj
).
get
(
"dictCode"
).
equals
(
code
))
.
flatMap
(
obj
->
((
JSONObject
)
obj
).
getJSONArray
(
"items"
).
stream
()).
collect
(
Collectors
.
toList
());
return
list
;
}
/**
...
...
@@ -48,7 +52,17 @@ public class DictUtil {
* @param text
* @return
*/
public
String
getDictItemValue
(
String
code
,
String
text
)
{
return
"test"
;
public
Object
getDictItemValue
(
String
code
,
String
text
)
{
String
key
=
"data:system:dicts"
;
Object
object
=
redisService
.
get
(
key
);
if
(
null
==
object
)
{
return
null
;
}
JSONArray
jsonArray
=
JSONArray
.
parseArray
(
JSON
.
toJSONString
(
object
));
Object
o
=
jsonArray
.
stream
().
filter
(
obj
->
((
JSONObject
)
obj
).
get
(
"dictCode"
).
equals
(
code
))
.
flatMap
(
obj
->
((
JSONObject
)
obj
).
getJSONArray
(
"items"
).
stream
())
.
filter
(
obj
->
((
JSONObject
)
obj
).
get
(
"itemText"
).
equals
(
text
))
.
map
(
obj
->
((
JSONObject
)
obj
).
get
(
"itemValue"
)).
findFirst
().
orElse
(
null
);
return
o
;
}
}
datax-common/datax-common-redis/src/main/java/cn/datax/common/redis/service/RedisService.java
View file @
d56575fe
...
...
@@ -403,7 +403,7 @@ public class RedisService {
* @param end 结束 0 到 -1代表所有值
* @return List
*/
public
List
<
Object
>
lGet
(
String
key
,
Long
start
,
Long
end
)
{
public
List
<
Object
>
lGet
(
String
key
,
int
start
,
int
end
)
{
try
{
return
redisTemplate
.
opsForList
().
range
(
key
,
start
,
end
);
}
catch
(
Exception
e
)
{
...
...
datax-modules/data-factory-service-parent/data-factory-service-api/src/main/java/cn/datax/service/data/factory/api/dto/DataSourceDto.java
View file @
d56575fe
...
...
@@ -27,7 +27,7 @@ public class DataSourceDto implements Serializable {
private
String
id
;
@ApiModelProperty
(
value
=
"数据源类型"
)
@NotBlank
(
message
=
"数据源类型不能为空"
,
groups
=
{
ValidationGroups
.
Insert
.
class
,
ValidationGroups
.
Update
.
class
})
private
String
dbType
;
private
Integer
dbType
;
@ApiModelProperty
(
value
=
"数据源名称"
)
@NotBlank
(
message
=
"数据源名称不能为空"
,
groups
=
{
ValidationGroups
.
Insert
.
class
,
ValidationGroups
.
Update
.
class
})
private
String
sourceName
;
...
...
datax-modules/data-factory-service-parent/data-factory-service-api/src/main/java/cn/datax/service/data/factory/api/entity/DataSourceEntity.java
View file @
d56575fe
...
...
@@ -28,7 +28,7 @@ public class DataSourceEntity extends DataScopeBaseEntity {
/**
* 数据源类型
*/
private
String
dbType
;
private
Integer
dbType
;
/**
* 数据源名称
...
...
datax-modules/data-factory-service-parent/data-factory-service-api/src/main/java/cn/datax/service/data/factory/api/vo/DataSourceVo.java
View file @
d56575fe
...
...
@@ -24,7 +24,7 @@ public class DataSourceVo implements Serializable {
private
Integer
status
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
LocalDateTime
createTime
;
private
String
dbType
;
private
Integer
dbType
;
private
String
sourceName
;
private
String
remark
;
private
DbSchema
dbSchema
;
...
...
datax-modules/system-service-parent/system-service-api/src/main/java/cn/datax/service/system/api/vo/RoleVo.java
View file @
d56575fe
...
...
@@ -20,6 +20,7 @@ public class RoleVo implements Serializable {
private
LocalDateTime
createTime
;
private
String
roleName
;
private
String
roleCode
;
@DictAop
(
code
=
"dataScope"
)
private
Integer
dataScope
;
private
List
<
MenuVo
>
menus
;
private
List
<
DeptVo
>
depts
;
...
...
datax-modules/system-service-parent/system-service/src/main/java/cn/datax/service/system/controller/DictController.java
View file @
d56575fe
...
...
@@ -2,6 +2,7 @@ package cn.datax.service.system.controller;
import
cn.datax.common.core.JsonPage
;
import
cn.datax.common.core.R
;
import
cn.datax.common.dictionary.utils.DictUtil
;
import
cn.datax.common.validate.ValidationGroups
;
import
cn.datax.service.system.api.dto.DictDto
;
import
cn.datax.service.system.api.entity.DictEntity
;
...
...
@@ -120,6 +121,17 @@ public class DictController extends BaseController {
}
/**
* 获取字典项
*
* @return
*/
@GetMapping
(
"/code/{code}"
)
public
R
getDictItems
(
@PathVariable
String
code
)
{
Object
list
=
DictUtil
.
getInstance
().
getDictItemList
(
code
);
return
R
.
ok
().
setData
(
list
);
}
/**
* 刷新字典
*
* @return
...
...
datax-modules/system-service-parent/system-service/src/main/java/cn/datax/service/system/service/impl/DictServiceImpl.java
View file @
d56575fe
package
cn
.
datax
.
service
.
system
.
service
.
impl
;
import
cn.datax.common.core.DataConstant
;
import
cn.datax.common.exception.DataException
;
import
cn.datax.common.redis.service.RedisService
;
import
cn.datax.service.system.api.entity.DictEntity
;
import
cn.datax.service.system.api.dto.DictDto
;
...
...
@@ -8,6 +9,7 @@ import cn.datax.service.system.service.DictService;
import
cn.datax.service.system.mapstruct.DictMapper
;
import
cn.datax.service.system.dao.DictDao
;
import
cn.datax.common.base.BaseServiceImpl
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
...
...
@@ -40,6 +42,10 @@ public class DictServiceImpl extends BaseServiceImpl<DictDao, DictEntity> implem
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
saveDict
(
DictDto
dictDto
)
{
DictEntity
dict
=
dictMapper
.
toEntity
(
dictDto
);
int
n
=
dictDao
.
selectCount
(
Wrappers
.<
DictEntity
>
lambdaQuery
().
eq
(
DictEntity:
:
getDictCode
,
dict
.
getDictCode
()));
if
(
n
>
0
){
throw
new
DataException
(
"该字典编码已存在"
);
}
dictDao
.
insert
(
dict
);
}
...
...
@@ -64,6 +70,6 @@ public class DictServiceImpl extends BaseServiceImpl<DictDao, DictEntity> implem
if
(
hasKey
)
{
redisService
.
del
(
key
);
}
redisService
.
lS
et
(
key
,
dictEntityList
);
redisService
.
s
et
(
key
,
dictEntityList
);
}
}
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