Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jeecg-boot
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
jeecg-boot
Commits
8d36cd32
Commit
8d36cd32
authored
Jun 04, 2019
by
zhangdaihao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解决继承实体,字典不自动翻译问题
parent
d5067a08
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/aspect/DictAspect.java
+9
-2
No files found.
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/aspect/DictAspect.java
View file @
8d36cd32
...
...
@@ -12,6 +12,7 @@ import org.aspectj.lang.annotation.Aspect;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.jeecg.common.api.vo.Result
;
import
org.jeecg.common.aspect.annotation.Dict
;
import
org.jeecg.common.util.oConvertUtils
;
import
org.jeecg.modules.system.service.ISysDictService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
...
...
@@ -49,7 +50,7 @@ public class DictAspect {
long
time2
=
System
.
currentTimeMillis
();
log
.
debug
(
"获取JSON数据 耗时:"
+(
time2
-
time1
)+
"ms"
);
long
start
=
System
.
currentTimeMillis
();
parseDictText
(
result
);
this
.
parseDictText
(
result
);
long
end
=
System
.
currentTimeMillis
();
log
.
debug
(
"解析注入JSON数据 耗时"
+(
end
-
start
)+
"ms"
);
return
result
;
...
...
@@ -91,18 +92,24 @@ public class DictAspect {
log
.
error
(
"json解析失败"
+
e
.
getMessage
(),
e
);
}
JSONObject
item
=
JSONObject
.
parseObject
(
json
);
for
(
Field
field
:
record
.
getClass
().
getDeclaredFields
())
{
//update-begin--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------
//for (Field field : record.getClass().getDeclaredFields()) {
for
(
Field
field
:
oConvertUtils
.
getAllFields
(
record
))
{
//update-end--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------
if
(
field
.
getAnnotation
(
Dict
.
class
)
!=
null
)
{
String
code
=
field
.
getAnnotation
(
Dict
.
class
).
dicCode
();
String
text
=
field
.
getAnnotation
(
Dict
.
class
).
dicText
();
String
table
=
field
.
getAnnotation
(
Dict
.
class
).
dictTable
();
String
key
=
String
.
valueOf
(
item
.
get
(
field
.
getName
()));
String
textValue
=
null
;
log
.
info
(
" 字典 key : "
+
key
);
if
(!
StringUtils
.
isEmpty
(
table
)){
textValue
=
dictService
.
queryTableDictTextByKey
(
table
,
text
,
code
,
key
);
}
else
{
textValue
=
dictService
.
queryDictTextByKey
(
code
,
key
);
}
log
.
info
(
" 字典Val : "
+
textValue
);
log
.
info
(
" __翻译字典字段__ "
+
field
.
getName
()
+
"_dictText: "
+
textValue
);
item
.
put
(
field
.
getName
()
+
"_dictText"
,
textValue
);
}
//date类型默认转换string格式化日期
...
...
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