From f659419a25455c1f1eb00afde99a13d0c398b96a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?niohe=C2=B7erbao?= Date: Wed, 15 Mar 2023 11:53:06 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=BA=8F=E5=88=97=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ningdatech/pmapi/common/config/ConfigurerAdapter.java | 10 +++++----- .../ningdatech/pmapi/common/handler/GlobalResponseHandler.java | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/config/ConfigurerAdapter.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/config/ConfigurerAdapter.java index 0ad5a2f..08a29d3 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/config/ConfigurerAdapter.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/config/ConfigurerAdapter.java @@ -28,15 +28,15 @@ public class ConfigurerAdapter implements WebMvcConfigurer { @Override public void configureMessageConverters(List> converters) { // 使用 fastjson 序列化,会导致 @JsonIgnore 失效,可以使用 @JSONField(serialize = false) 替换 -// FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter(); + FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter(); List supportMediaTypeList = new ArrayList<>(); supportMediaTypeList.add(MediaType.APPLICATION_JSON); FastJsonConfig config = new FastJsonConfig(); config.setDateFormat("yyyy-MM-dd HH:mm:ss"); config.setSerializerFeatures(SerializerFeature.DisableCircularReferenceDetect); -// converter.setFastJsonConfig(config); -// converter.setSupportedMediaTypes(supportMediaTypeList); -// converter.setDefaultCharset(StandardCharsets.UTF_8); -// converters.add(converter); + converter.setFastJsonConfig(config); + converter.setSupportedMediaTypes(supportMediaTypeList); + converter.setDefaultCharset(StandardCharsets.UTF_8); + converters.add(converter); } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/handler/GlobalResponseHandler.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/handler/GlobalResponseHandler.java index 42b90a1..57f4565 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/handler/GlobalResponseHandler.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/handler/GlobalResponseHandler.java @@ -44,9 +44,9 @@ public class GlobalResponseHandler implements ResponseBodyAdvice { // ConverterType是StringHttpMessageConverter这个类型转换, // 由于将结果封装成了自定义的ApiResponse类型,所以有ApiResponse转换成String报错 // 所以需要对String类型的返回值单独进行处理 - if (o instanceof String) { - return JSONUtil.toJsonStr(apiResponse); - } +// if (o instanceof String) { +// return JSONUtil.toJsonStr(apiResponse); +// } return ApiResponse.ofSuccess(o); // return o; }