Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
文鑫
/
docking-api
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
2c1550de
...
2c1550de2d745fd9394d6b2fae395477c1045b44
authored
2024-05-28 17:31:34 +0800
by
文鑫
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
反射优化
1 parent
4a8a31f9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
src/main/java/com/topdraw/dockingapi/config/EncodeLifeCycle.java
src/main/java/com/topdraw/dockingapi/config/EncodeLifeCycle.java
View file @
2c1550d
...
...
@@ -18,6 +18,7 @@ import java.lang.reflect.Parameter;
*/
public
class
EncodeLifeCycle
implements
MethodAnnotationLifeCycle
<
Encode
,
Object
>
{
private
Integer
bodyIndex
;
/**
* 当方法调用时调用此方法,此时还没有执行请求发送
...
...
@@ -27,11 +28,7 @@ public class EncodeLifeCycle implements MethodAnnotationLifeCycle<Encode, Object
@Override
public
void
onInvokeMethod
(
ForestRequest
request
,
ForestMethod
method
,
Object
[]
args
)
{
String
value
=
(
String
)
getAttribute
(
request
,
"value"
);
Parameter
[]
parameters
=
method
.
getMethod
().
getParameters
();
for
(
int
i
=
0
;
i
<
parameters
.
length
;
i
++)
{
EncodeBody
annotation
=
parameters
[
i
].
getAnnotation
(
EncodeBody
.
class
);
if
(
annotation
!=
null
)
{
Object
body
=
args
[
i
];
Object
body
=
args
[
bodyIndex
];
String
jsonString
=
JSON
.
toJSONString
(
body
);
String
encode
=
DecryptUtils
.
encode
(
value
,
jsonString
);
EncryptEntity
encodeBody
=
new
EncryptEntity
(
encode
);
...
...
@@ -40,12 +37,17 @@ public class EncodeLifeCycle implements MethodAnnotationLifeCycle<Encode, Object
forestBody
.
clear
();
request
.
addBody
(
encodeBody
);
}
}
}
@Override
public
void
onMethodInitialized
(
ForestMethod
method
,
Encode
annotation
)
{
Parameter
[]
parameters
=
method
.
getMethod
().
getParameters
();
for
(
int
i
=
0
;
i
<
parameters
.
length
;
i
++)
{
Parameter
parameter
=
parameters
[
i
];
EncodeBody
body
=
parameter
.
getAnnotation
(
EncodeBody
.
class
);
if
(
body
!=
null
)
{
bodyIndex
=
i
;
}
}
}
}
...
...
Please
register
or
sign in
to post a comment