//package com.ruoyi.framework.config;
//
//import com.fasterxml.jackson.databind.BeanDescription;
//import com.fasterxml.jackson.databind.DeserializationConfig;
//import com.fasterxml.jackson.databind.JsonDeserializer;
//import com.fasterxml.jackson.databind.deser.BeanDeserializerModifier;
//import com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer;
//import com.fasterxml.jackson.databind.module.SimpleModule;
//import com.fasterxml.jackson.core.JsonParser;
//import com.fasterxml.jackson.databind.DeserializationContext;
//import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.util.StringUtils;
//
//import java.io.IOException;
//
//@Configuration
//public class JacksonConfig {
//
//    @Bean
//    public Jackson2ObjectMapperBuilderCustomizer trimCustomizer() {
//        return builder -> {
//            // 注册一个 SimpleModule，把 String 的反序列化改掉
//            SimpleModule module = new SimpleModule("string-trim-module");
//            module.addDeserializer(String.class, new StdScalarDeserializer<String>(String.class) {
//                @Override
//                public String deserialize(JsonParser p, DeserializationContext ctxt)
//                        throws IOException {
//                    String value = p.getValueAsString();
//                    return value == null ? null : value.trim();
//                }
//            });
//            builder.modules(module);   // 关键：用 modules(...) 而不是不存在的 deserializerModifier(...)
//        };
//    }
//}
