mirror of
https://gitee.com/dromara/dax-pay
synced 2026-08-07 21:55:46 +08:00
fix 同步通知接收路径, 对账差错状态, 订单号生成工具类重命名, 一些注释相关的微调
This commit is contained in:
@@ -70,4 +70,17 @@ public class JacksonConfiguration {
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* 序列化时忽略空值
|
||||
*/
|
||||
@Bean
|
||||
public ObjectMapper ignoreNullObjectMapper(ObjectMapper objectMapper) {
|
||||
// 对象映射器
|
||||
ObjectMapper copy = objectMapper.copy()
|
||||
// null 值不序列化
|
||||
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
JacksonUtil.setIgnoreNullObjectMapper(copy);
|
||||
return copy;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,8 +21,12 @@ public class JacksonUtil {
|
||||
|
||||
private static boolean typeObjectMapperFlag;
|
||||
|
||||
private static boolean ignoreNullObjectMapperFlag;
|
||||
|
||||
private static ObjectMapper objectMapper;
|
||||
|
||||
private static ObjectMapper ignoreNullObjectMapper;
|
||||
|
||||
private static ObjectMapper typeObjectMapper;
|
||||
|
||||
public static void setObjectMapper(ObjectMapper objectMapper) {
|
||||
@@ -41,12 +45,28 @@ public class JacksonUtil {
|
||||
JacksonUtil.typeObjectMapper = typeObjectMapper;
|
||||
}
|
||||
|
||||
public static void setIgnoreNullObjectMapper(ObjectMapper ignoreNullObjectMapper) {
|
||||
if (ignoreNullObjectMapperFlag) {
|
||||
throw new RepetitiveOperationException();
|
||||
}
|
||||
ignoreNullObjectMapperFlag = true;
|
||||
JacksonUtil.ignoreNullObjectMapper = ignoreNullObjectMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对象序列化为json字符串,转换异常将被抛出
|
||||
*/
|
||||
public static String toJson(Object o) {
|
||||
return toJson(o,false);
|
||||
}
|
||||
|
||||
public static String toJson(Object o, boolean ignoreNull) {
|
||||
try {
|
||||
return objectMapper.writeValueAsString(o);
|
||||
if (ignoreNull){
|
||||
return ignoreNullObjectMapper.writeValueAsString(o);
|
||||
}else {
|
||||
return objectMapper.writeValueAsString(o);
|
||||
}
|
||||
}
|
||||
catch (JsonProcessingException e) {
|
||||
throw new RuntimeException("json序列化失败");
|
||||
@@ -70,8 +90,19 @@ public class JacksonUtil {
|
||||
* JSON字符串转为实体类对象,转换异常将被抛出
|
||||
*/
|
||||
public static <T> T toBean(String content, TypeReference<? extends T> ref) {
|
||||
return toBean(content, ref,false);
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON字符串转为实体类对象,转换异常将被抛出
|
||||
*/
|
||||
public static <T> T toBean(String content, TypeReference<? extends T> ref, boolean ignoreNull) {
|
||||
try {
|
||||
return objectMapper.readValue(content, ref);
|
||||
if (ignoreNull){
|
||||
return ignoreNullObjectMapper.readValue(content, ref);
|
||||
} else {
|
||||
return objectMapper.readValue(content, ref);
|
||||
}
|
||||
}
|
||||
catch (JsonProcessingException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
<flyway.version>7.15.0</flyway.version>
|
||||
<xml-apis.version>1.4.01</xml-apis.version>
|
||||
<!-- 升级新版本会有兼容性问题 -->
|
||||
<logback-classic.version>1.2.12</logback-classic.version>
|
||||
<logback-classic.version>1.2.13</logback-classic.version>
|
||||
<!-- 3.5.3 滚动日志不可用 -->
|
||||
<plumelog.version>3.5.3</plumelog.version>
|
||||
<easyexcel.version>3.3.2</easyexcel.version>
|
||||
@@ -82,7 +82,7 @@
|
||||
<velocity.version>2.3</velocity.version>
|
||||
<wxjava.version>4.5.2.B</wxjava.version>
|
||||
<ding-talk.version>1.3.81</ding-talk.version>
|
||||
<lock4j.version>2.2.5</lock4j.version>
|
||||
<lock4j.version>2.2.7</lock4j.version>
|
||||
<ip2region.version>2.7.0</ip2region.version>
|
||||
<sms4j.version>2.2.0</sms4j.version>
|
||||
<table-modify.version>1.5.5</table-modify.version>
|
||||
|
||||
Reference in New Issue
Block a user