houzhongjian
2024-10-16 7da8f196dee8e3c526c009a4bc7f5983ece6bb97
提交 | 用户 | 时间
e7c126 1 package com.iailab.module.system.framework.captcha.config;
H 2
3 import com.iailab.module.system.framework.captcha.core.RedisCaptchaServiceImpl;
4 import com.xingyuv.captcha.properties.AjCaptchaProperties;
5 import com.xingyuv.captcha.service.CaptchaCacheService;
6 import com.xingyuv.captcha.service.impl.CaptchaServiceFactory;
7 import org.springframework.context.annotation.Bean;
8 import org.springframework.context.annotation.Configuration;
9 import org.springframework.data.redis.core.StringRedisTemplate;
10
11 /**
12  * 验证码的配置类
13  *
14  * @author iailab
15  */
16 @Configuration(proxyBeanMethods = false)
17 public class IailabCaptchaConfiguration {
18
19     @Bean
20     public CaptchaCacheService captchaCacheService(AjCaptchaProperties config,
21                                                    StringRedisTemplate stringRedisTemplate) {
22         CaptchaCacheService captchaCacheService = CaptchaServiceFactory.getCache(config.getCacheType().name());
23         if (captchaCacheService instanceof RedisCaptchaServiceImpl) {
24             ((RedisCaptchaServiceImpl) captchaCacheService).setStringRedisTemplate(stringRedisTemplate);
25         }
26         return captchaCacheService;
27     }
28
29 }