Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
gsc
/
gsc-gateway
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 33d07dd9
authored
Nov 05, 2025
by
叶立庆
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
兼容Bigdecimal类型传参验签
1 parent
456870da
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
3 deletions
src/main/java/com/gsc4cloud/gsc/gateway/filter/WebRequestSignFilter.java
src/main/java/com/gsc4cloud/gsc/gateway/filter/WebRequestSignFilter.java
View file @
33d07dd
package
com
.
gsc4cloud
.
gsc
.
gateway
.
filter
;
package
com
.
gsc4cloud
.
gsc
.
gateway
.
filter
;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.node.JsonNodeFactory
;
import
com.gsc4cloud.gsc.gateway.config.SignConfigProperties
;
import
com.gsc4cloud.gsc.gateway.config.SignConfigProperties
;
import
com.gsc4cloud.gsc.gateway.utils.SignUtil
;
import
com.gsc4cloud.gsc.gateway.utils.SignUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -42,7 +44,9 @@ import java.util.stream.Collectors;
...
@@ -42,7 +44,9 @@ import java.util.stream.Collectors;
@Component
@Component
public
class
WebRequestSignFilter
implements
GlobalFilter
,
Ordered
{
public
class
WebRequestSignFilter
implements
GlobalFilter
,
Ordered
{
private
final
ObjectMapper
objectMapper
=
new
ObjectMapper
();
private
final
ObjectMapper
objectMapper
=
new
ObjectMapper
()
.
configure
(
DeserializationFeature
.
USE_BIG_DECIMAL_FOR_FLOATS
,
true
)
.
setNodeFactory
(
JsonNodeFactory
.
withExactBigDecimals
(
true
));;
@Autowired
@Autowired
private
SignConfigProperties
signConfigProperties
;
private
SignConfigProperties
signConfigProperties
;
...
@@ -215,11 +219,23 @@ public class WebRequestSignFilter implements GlobalFilter, Ordered {
...
@@ -215,11 +219,23 @@ public class WebRequestSignFilter implements GlobalFilter, Ordered {
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
JsonNode
root
=
objectMapper
.
readTree
(
bytes
);
JsonNode
root
=
objectMapper
.
readTree
(
bytes
);
root
.
properties
().
forEach
(
entry
->
{
root
.
properties
().
forEach
(
entry
->
{
JsonNode
value
=
entry
.
getValue
();
// 排除空值字段
// 排除空值字段
if
(
entry
.
getValue
()
.
isNull
())
{
if
(
value
==
null
||
value
.
isNull
())
{
return
;
return
;
}
}
result
.
put
(
entry
.
getKey
(),
entry
.
getValue
());
if
(
value
.
isNumber
())
{
// 保留小数位(如 12.10),用于验签与日志一致性
String
numStr
=
value
.
isFloatingPointNumber
()
?
value
.
decimalValue
().
toPlainString
()
:
value
.
asText
();
result
.
put
(
entry
.
getKey
(),
numStr
);
}
else
if
(
value
.
isTextual
())
{
result
.
put
(
entry
.
getKey
(),
value
.
asText
());
}
else
{
// 其他类型统一序列化为字符串
result
.
put
(
entry
.
getKey
(),
value
.
toString
());
}
});
});
return
result
;
return
result
;
}
}
...
...
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