package com.philisense.www;

import com.philisense.www.api.generator.impl.*;
import com.philisense.www.api.repository.VcodeRepository;
import com.philisense.www.api.repository.impl.RedisVcodeRepository;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class VcodeBeanConfig {

    @Bean
    @ConditionalOnMissingBean(name = "puzzleCaptchaGenerator")
    public PuzzleCaptchaGenerator puzzleCaptchaGenerator() {
        return new PuzzleCaptchaGenerator("imgs/captcha-1.jpg");
    }

    @Bean
    @ConditionalOnMissingBean(name = "wordCombGenerator")
    public WordCombGenerator wordCombGenerator() {
        return new WordCombGenerator();
    }

    @Bean
    @ConditionalOnMissingBean(name = "imageCodeGenerator")
    public ImageCodeGenerator imageCodeGenerator() {
        return new ImageCodeGenerator();
    }

    @Bean
    @ConditionalOnMissingBean(name = "smsCodeGenerator")
    public SmsCodeGenerator smsCodeGenerator() {
        return new SmsCodeGenerator();
    }

    @Bean
    @ConditionalOnMissingBean(name = "emailCodeGenerator")
    public EmailCodeGenerator emailCodeGenerator() {
        return new EmailCodeGenerator();
    }

    @Bean
    @ConditionalOnMissingBean(VcodeRepository.class)
    public VcodeRepository vcodeRepository() {
        return new RedisVcodeRepository();
    }
}
