package com.huimv.employment.integration.kb;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 * 大模型网关 HTTP 客户端自动配置。
 */
@Configuration
@EnableConfigurationProperties(KbApiProperties.class)
public class KbAutoConfiguration {

    @Bean("kbRestTemplate")
    public RestTemplate kbRestTemplate(KbApiProperties properties) {
        SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
        factory.setConnectTimeout(properties.getConnectTimeoutMs());
        factory.setReadTimeout(properties.getReadTimeoutMs());
        return new RestTemplate(factory);
    }
}
