package cn.palmte.work.config;

/*import cn.palmte.work.model.Manager;
import cn.palmte.work.service.CaptchaCodeService;
import cn.palmte.work.service.token.redis.ApiTokenManager;
import cn.palmte.work.service.token.redis.RedisCaptchaManager;
import cn.palmte.work.service.token.redis.RedisErrorCountManager;
import com.alibaba.fastjson.support.spring.GenericFastJsonRedisSerializer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;

import top.jfunc.token.CaptchaManger;
import top.jfunc.token.ErrorCountManager;
import top.jfunc.token.TokenManager;

import static cn.palmte.work.config.SystemConfigWithMemory.API_TOKEN_MANAGER;*/


/*@Configuration
public class SystemConfigWithRedis {

    @Autowired(required = false)
    RedisConnectionFactory connectionFactory;

    @Bean(name = "stringRedisTemplate")
    public StringRedisTemplate stringRedisTemplate() {
        return new StringRedisTemplate(connectionFactory);
    }

    @Bean(name = "redisTemplate")
    public RedisTemplate<Object, Object> redisTemplate(){
        RedisTemplate<Object, Object> template = new RedisTemplate<>();
        template.setConnectionFactory(connectionFactory);
        //避免key出现乱码
        template.setKeySerializer(new StringRedisSerializer());
        //value使用FastJson转换
        template.setValueSerializer(new GenericFastJsonRedisSerializer());
        template.setHashKeySerializer(new StringRedisSerializer());
        template.setHashValueSerializer(new GenericFastJsonRedisSerializer());
        return template;
    }
    @Value("${fourcal.token.api.prefix}")
    private String apiTokenPrefix;

    @Value("#{${fourcal.token.api.expires}}")
    private long apiExpires;


    @Bean(Constant.API_TOKEN_MANAGER)
    public TokenManager<Manager> apiTokenManagerRedis(){
        ApiTokenManager apiTokenManager = new ApiTokenManager();
        apiTokenManager.setRedisTemplate(redisTemplate());
        apiTokenManager.setApiExpires(apiExpires);
        apiTokenManager.setMulti(true);
        apiTokenManager.setTokenPrefix(apiTokenPrefix);
        return apiTokenManager;
    }
    @Bean
    public ErrorCountManager errorCountManager() {
        RedisErrorCountManager redisErrorCountManager = new RedisErrorCountManager();
        redisErrorCountManager.setThreshold(3);
        redisErrorCountManager.setRedisTemplate(redisTemplate());
        return redisErrorCountManager;
    }
    @Bean
    public CaptchaManger captchaManger(@Autowired CaptchaCodeService captchaCodeService) {
        RedisCaptchaManager captchaManger = new RedisCaptchaManager();
        captchaManger.setRedisTemplate(redisTemplate());
        captchaManger.setCaptchaCodeService(captchaCodeService);
        return captchaManger;
    }
}*/
