All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.macrocloud.kernel.sms.config.QiniuSmsConfiguration Maven / Gradle / Ivy

package org.macrocloud.kernel.sms.config;

import com.qiniu.sms.SmsManager;
import com.qiniu.util.Auth;
import lombok.AllArgsConstructor;

import org.macrocloud.kernel.redis.cache.BaseRedis;
import org.macrocloud.kernel.sms.QiniuSmsTemplate;
import org.macrocloud.kernel.sms.props.SmsProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 阿里云短信配置类
 *
 */
@Configuration(proxyBeanMethods = false)
@AllArgsConstructor
@ConditionalOnClass(SmsManager.class)
@EnableConfigurationProperties(SmsProperties.class)
@ConditionalOnProperty(value = "sms.name", havingValue = "qiniu")
public class QiniuSmsConfiguration {

	private final BaseRedis macroRedis;

	@Bean
	public QiniuSmsTemplate qiniuSmsTemplate(SmsProperties smsProperties) {
		Auth auth = Auth.create(smsProperties.getAccessKey(), smsProperties.getSecretKey());
		SmsManager smsManager = new SmsManager(auth);
		return new QiniuSmsTemplate(smsProperties, smsManager, macroRedis);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy