| | |
| | | package com.ruoyi.framework.config; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.TimeZone; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.fasterxml.jackson.core.JsonParser; |
| | | import com.fasterxml.jackson.databind.DeserializationContext; |
| | | import com.fasterxml.jackson.databind.JsonDeserializer; |
| | | import com.fasterxml.jackson.databind.JsonNode; |
| | | import com.fasterxml.jackson.databind.module.SimpleModule; |
| | | import org.mybatis.spring.annotation.MapperScan; |
| | | import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; |
| | | import org.springframework.context.annotation.Bean; |
| | |
| | | @Bean |
| | | public Jackson2ObjectMapperBuilderCustomizer jacksonObjectMapperCustomization() |
| | | { |
| | | return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(TimeZone.getDefault()); |
| | | return jacksonObjectMapperBuilder -> { |
| | | jacksonObjectMapperBuilder.timeZone(TimeZone.getDefault()); |
| | | // 支持将 JSON 对象反序列化为 fastjson JSONObject |
| | | SimpleModule module = new SimpleModule(); |
| | | module.addDeserializer(JSONObject.class, new JsonDeserializer<JSONObject>() { |
| | | @Override |
| | | public JSONObject deserialize(JsonParser p, DeserializationContext ctx) throws IOException { |
| | | JsonNode node = p.getCodec().readTree(p); |
| | | return JSONObject.parseObject(node.toString()); |
| | | } |
| | | }); |
| | | jacksonObjectMapperBuilder.modules(module); |
| | | }; |
| | | } |
| | | } |