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

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

package org.macrocloud.kernel.sms.config;

import com.github.qcloudsms.SmsMultiSender;
import lombok.AllArgsConstructor;

import org.macrocloud.kernel.redis.cache.BaseRedis;
import org.macrocloud.kernel.sms.TencentSmsTemplate;
import org.macrocloud.kernel.sms.props.SmsProperties;
import org.macrocloud.kernel.toolkit.utils.Func;
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(SmsMultiSender.class)
@EnableConfigurationProperties(SmsProperties.class)
@ConditionalOnProperty(value = "sms.name", havingValue = "tencent")
public class TencentSmsConfiguration {

	private final BaseRedis macroRedis;

	@Bean
	public TencentSmsTemplate tencentSmsTemplate(SmsProperties smsProperties) {
		SmsMultiSender smsSender = new SmsMultiSender(Func.toInt(smsProperties.getAccessKey()), smsProperties.getSecretKey());
		return new TencentSmsTemplate(smsProperties, smsSender, macroRedis);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy