package com.lanyuanxiaoyao.service.forest.configuration;

import com.dtflys.forest.converter.json.ForestJacksonConverter;
import com.dtflys.forest.springboot.annotation.ForestScan;
import com.fasterxml.jackson.datatype.eclipsecollections.EclipseCollectionsModule;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author lanyuanxiaoyao
 * @date 2023-04-24
 */
@ForestScan(basePackages = {
        "com.lanyuanxiaoyao.service.forest.service"
})
@Configuration
public class ForestsConfiguration {
    @Bean
    public ForestJacksonConverter forestJacksonConverter() {
        ForestJacksonConverter converter = new ForestJacksonConverter();
        converter.getMapper().registerModule(new EclipseCollectionsModule());
        converter.getMapper().registerModule(new JavaTimeModule());
        return converter;
    }

    /*@Bean
    public ForestConfigurationProperties forestConfigurationProperties() {
        ForestConfigurationProperties properties = new ForestConfigurationProperties();
        properties.setBackend("httpclient");
        properties.setInterceptors(ListUtil.of(SpringCloudDiscoveryInterceptor.class));
        properties.setLogEnabled(false);
        properties.setTimeout(60000);
        return properties;
    }*/
}
