From 34981c30a78e8bbd7791131059a9210f9928b62c Mon Sep 17 00:00:00 2001
From: 刘光辉 <347230014@qq.com>
Date: 星期四, 17 九月 2026 09:24:09 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master' into master
---
jnpf-lims/jnpf-lims-biz/src/main/java/jnpf/config/JacksonConfig.java | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 49 insertions(+), 0 deletions(-)
diff --git a/jnpf-lims/jnpf-lims-biz/src/main/java/jnpf/config/JacksonConfig.java b/jnpf-lims/jnpf-lims-biz/src/main/java/jnpf/config/JacksonConfig.java
new file mode 100644
index 0000000..e5d1b20
--- /dev/null
+++ b/jnpf-lims/jnpf-lims-biz/src/main/java/jnpf/config/JacksonConfig.java
@@ -0,0 +1,49 @@
+package jnpf.config;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.PropertyNamingStrategies;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.MapperFeature;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+import java.text.SimpleDateFormat;
+import java.util.List;
+import java.util.TimeZone;
+
+@Configuration
+public class JacksonConfig implements WebMvcConfigurer {
+
+ @Bean
+ @Primary
+ public ObjectMapper objectMapper() {
+ ObjectMapper objectMapper = new ObjectMapper();
+
+ // 鍘熸湁閰嶇疆
+ objectMapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
+ objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true);
+ objectMapper.configure(MapperFeature.USE_GETTERS_AS_SETTERS, true);
+
+ // 鏂板锛氳缃叏灞�鏃ユ湡鏍煎紡鍜屾椂鍖�
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ dateFormat.setTimeZone(TimeZone.getTimeZone("GMT+8")); // 璁剧疆鏃跺尯锛岄伩鍏嶆椂闂村亸绉�
+ objectMapper.setDateFormat(dateFormat);
+
+ return objectMapper;
+ }
+
+ @Override
+ public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
+ for (HttpMessageConverter<?> converter : converters) {
+ if (converter instanceof MappingJackson2HttpMessageConverter) {
+ ((MappingJackson2HttpMessageConverter) converter).setObjectMapper(objectMapper());
+ }
+ }
+ }
+}
--
Gitblit v1.8.0