org.zodiac.autoconfigure.sms.PlatformSmsAliAutoConfiguration 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.aliyuncs.IAcsClient.class, org.zodiac.sms.AliSmsTemplate.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_ALIYUN)
public class PlatformSmsAliAutoConfiguration {
private final org.zodiac.redis.RedisDataOperation redisDataOperation;
public PlatformSmsAliAutoConfiguration(org.zodiac.redis.RedisDataOperation redisDataOperation) {
this.redisDataOperation = redisDataOperation;
}
@Bean
@ConditionalOnMissingBean
protected org.zodiac.sms.AliSmsTemplate aliSmsTemplate(PlatformSmsProperties plartformSmsProperties) {
com.aliyuncs.profile.IClientProfile profile = com.aliyuncs.profile.DefaultProfile.getProfile(plartformSmsProperties.getRegionId(), plartformSmsProperties.getAccessKey(),
plartformSmsProperties.getSecretKey());
com.aliyuncs.IAcsClient acsClient = new com.aliyuncs.DefaultAcsClient(profile);
return new org.zodiac.sms.AliSmsTemplate(plartformSmsProperties, acsClient, redisDataOperation);
}
}