Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
chejia-smart-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 96696ad6
authored
May 18, 2021
by
tyfanchz
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feign 解码器修改
1 parent
62c8a786
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
src/main/java/com/glsx/admin/config/FeignDecoderForR.java
src/main/java/com/glsx/admin/config/FeignDecoderForR.java
View file @
96696ad
...
...
@@ -67,9 +67,12 @@ public class FeignDecoderForR extends FeignDecoder<R> {
PAGE_HELPER_PAGE_INFO
(
PageInfo
.
class
)
{
@Override
public
Object
parse
(
R
resp
,
Type
type
)
{
ParameterizedType
parameterizedType
=
(
ParameterizedType
)
type
;
Type
itemType
=
parameterizedType
.
getActualTypeArguments
()[
0
];
JSONObject
dataObj
=
JSON
.
parseObject
(
FeignParserForR
.
extractDataJson
(
resp
));
// 先创造出 PageInfo 对象,再填充数据
PageInfo
<?>
pageInfo
=
PageInfo
.
of
(
dataObj
.
getJSONArray
(
"list"
));
PageInfo
<?>
pageInfo
=
PageInfo
.
of
(
dataObj
.
getJSONArray
(
"list"
)
.
toJavaList
((
Class
<?>)
itemType
));
pageInfo
.
setPages
(
dataObj
.
getInteger
(
"totalPages"
));
pageInfo
.
setTotal
(
dataObj
.
getLong
(
"totalElements"
));
return
pageInfo
;
...
...
@@ -83,11 +86,11 @@ public class FeignDecoderForR extends FeignDecoder<R> {
@Override
public
Object
parse
(
R
resp
,
Type
type
)
{
ParameterizedType
parameterizedType
=
(
ParameterizedType
)
type
;
Type
itemType
=
parameterizedType
.
getActualTypeArguments
()[
0
];
JSONObject
dataObj
=
JSON
.
parseObject
(
FeignParserForR
.
extractDataJson
(
resp
));
// 解析出 Page 对象,再填充数据
Page
<?>
page
=
dataObj
.
getJSONArray
(
"page"
).
toJavaObject
(
type
);
page
.
addAll
(
dataObj
.
getJSONArray
(
"items"
).
toJavaObject
(
parameterizedType
.
getActualTypeArguments
()[
0
]));
page
.
addAll
(
dataObj
.
getJSONArray
(
"items"
).
toJavaList
((
Class
)
itemType
));
return
page
;
}
},
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment