package com.hwrj.cloud.portal.config.redis;

import com.hwrj.cloud.portal.config.WxPayProperties;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

/**
 * redisson通用化配置
 **/
@Configuration
@EnableConfigurationProperties(RedissonProperties.class)
public class RedissonConfig {


    private RedissonProperties properties;

    @Autowired
    public RedissonConfig(RedissonProperties properties) {
        this.properties = properties;
    }

    @Bean
    public RedissonClient redissonClient() {
        Config config = new Config();
        config.useSingleServer()
                .setAddress(properties.getAddress())
                .setPassword(properties.getPassword());
        RedissonClient client = Redisson.create(config);
        return client;
    }
}
