org.zodiac.autoconfigure.sms.PlatformSmsTencentAutoConfiguration Maven / Gradle / Ivy
package org.zodiac.autoconfigure.sms;
import org.zodiac.autoconfigure.redis.RedisTemplateAutoConfiguration;
import org.zodiac.autoconfigure.sms.condition.ConditionalOnPlatformSms;
import org.zodiac.commons.util.Func;
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.github.qcloudsms.SmsMultiSender.class, org.zodiac.sms.TencentSmsTemplate.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_TENCENT)
public class PlatformSmsTencentAutoConfiguration {
private final org.zodiac.redis.RedisDataOperation redisDataOperation;
public PlatformSmsTencentAutoConfiguration(org.zodiac.redis.RedisDataOperation redisDataOperation) {
this.redisDataOperation = redisDataOperation;
}
@Bean
@ConditionalOnMissingBean
protected org.zodiac.sms.TencentSmsTemplate tencentSmsTemplate(PlatformSmsProperties plartformSmsProperties) {
com.github.qcloudsms.SmsMultiSender smsSender =
new com.github.qcloudsms.SmsMultiSender(Func.toInt(plartformSmsProperties.getAccessKey()), plartformSmsProperties.getSecretKey());
return new org.zodiac.sms.TencentSmsTemplate(plartformSmsProperties, smsSender, redisDataOperation);
}
}