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
411515c9
Commit
411515c9
authored
Apr 24, 2020
by
yuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2.0.0项目初始化
parent
c2617e9a
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
172 additions
and
0 deletions
+172
-0
pom.xml
datax-common/datax-common-core/pom.xml
+5
-0
pom.xml
datax-common/datax-common-dictionary/pom.xml
+33
-0
DictAop.java
...n/java/cn/datax/common/dictionary/annotation/DictAop.java
+12
-0
DictAnalysis.java
.../java/cn/datax/common/dictionary/config/DictAnalysis.java
+65
-0
DictUtil.java
.../main/java/cn/datax/common/dictionary/utils/DictUtil.java
+54
-0
pom.xml
datax-common/pom.xml
+2
-0
pom.xml
pom.xml
+1
-0
No files found.
datax-common/datax-common-core/pom.xml
View file @
411515c9
...
...
@@ -49,6 +49,11 @@
<version>
${hutool.version}
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
${fastjson.version}
</version>
</dependency>
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-extension
</artifactId>
<version>
${mybatis-plus.version}
</version>
...
...
datax-common/datax-common-dictionary/pom.xml
0 → 100644
View file @
411515c9
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
datax-common
</artifactId>
<groupId>
cn.datax
</groupId>
<version>
2.0.0
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<version>
2.0.0
</version>
<artifactId>
datax-common-dictionary
</artifactId>
<dependencies>
<!-- SpringWeb模块 -->
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-webmvc
</artifactId>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
cn.datax
</groupId>
<artifactId>
system-service-api
</artifactId>
<version>
2.0.0
</version>
</dependency>
<dependency>
<groupId>
cn.datax
</groupId>
<artifactId>
datax-common-redis
</artifactId>
<version>
2.0.0
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
datax-common/datax-common-dictionary/src/main/java/cn/datax/common/dictionary/annotation/DictAop.java
0 → 100644
View file @
411515c9
package
cn
.
datax
.
common
.
dictionary
.
annotation
;
import
java.lang.annotation.*
;
@Target
({
ElementType
.
PARAMETER
,
ElementType
.
METHOD
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
public
@interface
DictAop
{
/** 字典编码 */
String
code
()
default
""
;
}
datax-common/datax-common-dictionary/src/main/java/cn/datax/common/dictionary/config/DictAnalysis.java
0 → 100644
View file @
411515c9
package
cn
.
datax
.
common
.
dictionary
.
config
;
import
cn.datax.common.core.JsonPage
;
import
cn.datax.common.core.R
;
import
cn.datax.common.dictionary.annotation.DictAop
;
import
cn.datax.common.dictionary.utils.DictUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.springframework.core.MethodParameter
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.server.ServerHttpRequest
;
import
org.springframework.http.server.ServerHttpResponse
;
import
org.springframework.web.bind.annotation.ControllerAdvice
;
import
org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice
;
import
java.lang.reflect.Field
;
import
java.util.ArrayList
;
import
java.util.List
;
@ControllerAdvice
public
class
DictAnalysis
implements
ResponseBodyAdvice
{
@Override
public
Object
beforeBodyWrite
(
Object
o
,
MethodParameter
methodParameter
,
MediaType
mediaType
,
Class
aClass
,
ServerHttpRequest
serverHttpRequest
,
ServerHttpResponse
serverHttpResponse
)
{
if
(
o
instanceof
R
)
{
if
(((
R
)
o
).
getData
()
instanceof
JsonPage
)
{
List
list
=
((
JsonPage
)
((
R
)
o
).
getData
()).
getData
();
List
<
JSONObject
>
items
=
new
ArrayList
<>();
ObjectMapper
mapper
=
new
ObjectMapper
();
for
(
Object
record
:
list
)
{
String
json
=
"{}"
;
try
{
json
=
mapper
.
writeValueAsString
(
record
);
}
catch
(
JsonProcessingException
e
)
{
e
.
printStackTrace
();
}
JSONObject
item
=
JSONObject
.
parseObject
(
json
);
for
(
Field
field
:
record
.
getClass
().
getDeclaredFields
())
{
// 获取自定义注解
DictAop
dictAop
=
field
.
getAnnotation
(
DictAop
.
class
);
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
);
}
}
items
.
add
(
item
);
}
((
JsonPage
)
((
R
)
o
).
getData
()).
setData
(
items
);
}
}
return
o
;
}
@Override
public
boolean
supports
(
MethodParameter
methodParameter
,
Class
aClass
)
{
return
true
;
}
}
datax-common/datax-common-dictionary/src/main/java/cn/datax/common/dictionary/utils/DictUtil.java
0 → 100644
View file @
411515c9
package
cn
.
datax
.
common
.
dictionary
.
utils
;
import
cn.datax.common.redis.service.RedisService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
@Slf4j
public
class
DictUtil
{
private
DictUtil
()
{}
private
static
volatile
DictUtil
instance
;
public
static
DictUtil
getInstance
()
{
if
(
instance
==
null
)
{
synchronized
(
DictUtil
.
class
)
{
if
(
instance
==
null
)
{
instance
=
new
DictUtil
();
}
}
}
return
instance
;
}
@Autowired
private
RedisService
redisService
;
static
{
initDictionary
();
}
// 初始化字典数据
private
static
void
initDictionary
()
{
log
.
info
(
"DictUtil初始化中..."
);
}
/**
* 获取字典项
* @param code
*/
public
void
getDictItemList
(
String
code
)
{
}
/**
* 获取字典项值
* @param code
* @param text
* @return
*/
public
String
getDictItemValue
(
String
code
,
String
text
)
{
return
"test"
;
}
}
datax-common/pom.xml
View file @
411515c9
...
...
@@ -20,5 +20,6 @@
<module>
datax-common-log
</module>
<module>
datax-common-database
</module>
<module>
datax-common-office
</module>
<module>
datax-common-dictionary
</module>
</modules>
</project>
\ No newline at end of file
pom.xml
View file @
411515c9
...
...
@@ -23,6 +23,7 @@
<spring-cloud.version>
Hoxton.SR3
</spring-cloud.version>
<spring-boot-admin.version>
2.2.1
</spring-boot-admin.version>
<fastjson.version>
1.2.66
</fastjson.version>
<hutool.version>
5.2.3
</hutool.version>
<mybatis-plus.version>
3.3.1
</mybatis-plus.version>
<dynamic-datasource.version>
2.5.7
</dynamic-datasource.version>
...
...
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