org.zodiac.autoconfigure.sms.PlatformSmsQiniuAutoConfiguration Maven / Gradle / Ivy
package org.zodiac.autoconfigure.sms;
import org.zodiac.autoconfigure.redis.RedisTemplateAutoConfiguration;
import org.zodiac.autoconfigure.sms.condition.ConditionalOnPlatformSms;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
@SpringBootConfiguration
@ConditionalOnPlatformSms
@AutoConfigureAfter(value = {RedisTemplateAutoConfiguration.class})
@ConditionalOnClass(value = {com.qiniu.sms.SmsManager.class, org.zodiac.sms.QiniuSmsTemplate.class, org.zodiac.redis.RedisDataOperation.class})
@ConditionalOnProperty(value = org.zodiac.sms.constants.PlatformSmsSystemPropertiesConstants.PLATFORM_SMS_NAME, havingValue = org.zodiac.sms.constants.PlatformSmsConstants.PLATFORM_SMS_VENDOR_QINNIU)
public class PlatformSmsQiniuAutoConfiguration {
private final org.zodiac.redis.RedisDataOperation redisDataOperation;
public PlatformSmsQiniuAutoConfiguration(org.zodiac.redis.RedisDataOperation redisDataOperation) {
this.redisDataOperation = redisDataOperation;
}
@Bean
@ConditionalOnMissingBean
protected org.zodiac.sms.QiniuSmsTemplate qiniuSmsTemplate(PlatformSmsProperties plartformSmsProperties) {
com.qiniu.util.Auth auth = com.qiniu.util.Auth.create(plartformSmsProperties.getAccessKey(), plartformSmsProperties.getSecretKey());
com.qiniu.sms.SmsManager smsManager = new com.qiniu.sms.SmsManager(auth);
return new org.zodiac.sms.QiniuSmsTemplate(plartformSmsProperties, smsManager, redisDataOperation);
}
}