package com.zm.order.tool.server.config;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * @Description 内部接口配置类
 * @Author: ph
 * @Date: 2020/1/6 14:22
 */
@Configuration
@EnableConfigurationProperties(InnerApiStorageProperty.class)
public class InnerApiStorageConfig {

    private static final Logger logger = LoggerFactory.getLogger(InnerApiStorageConfig.class);

    @Bean("innerApiStorage")
    public JedisPool innerApiStorage(@Autowired InnerApiStorageProperty innerApiStorageProperty) {
        logger.info("内部接口存储地址：" + innerApiStorageProperty.getHost() + ":" + innerApiStorageProperty.getPort());
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        JedisPool jedisPool;
        jedisPool = new JedisPool(jedisPoolConfig, innerApiStorageProperty.getHost(), innerApiStorageProperty.getPort(), innerApiStorageProperty.getTimeout(), innerApiStorageProperty.getPassword(), innerApiStorageProperty.getDb());
        logger.info("InnerApiStorage注入成功！！");
        return jedisPool;
    }


}
