package com.yanzhu.framework.signature.config;

import com.yanzhu.framework.signature.core.aop.ApiSignatureAspect;
import com.yanzhu.framework.signature.core.redis.ApiSignatureRedisDAO;
import com.yanzhu.framework.redis.config.YanzhuRedisAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.core.StringRedisTemplate;

@AutoConfiguration(after = YanzhuRedisAutoConfiguration.class)
public class YanzhuApiSignatureAutoConfiguration {

    @Bean
    @ConditionalOnBean(StringRedisTemplate.class)
    public ApiSignatureAspect apiSignatureAspect(ApiSignatureRedisDAO signatureRedisDAO) {
        return new ApiSignatureAspect(signatureRedisDAO);
    }

    @Bean
    @ConditionalOnBean(StringRedisTemplate.class)
    public ApiSignatureRedisDAO apiSignatureRedisDAO(StringRedisTemplate stringRedisTemplate) {
        return new ApiSignatureRedisDAO(stringRedisTemplate);
    }

}
