package com.newfiber.system.builder; import com.aliyuncs.DefaultAcsClient; import com.aliyuncs.IAcsClient; import com.aliyuncs.profile.DefaultProfile; import com.aliyuncs.profile.IClientProfile; import com.newfiber.common.redis.service.RedisService; import com.newfiber.system.domain.SmsConfig; import com.newfiber.system.domain.model.SmsProperties; import com.newfiber.system.template.AliSmsTemplate; import com.newfiber.system.template.SmsTemplate; import lombok.SneakyThrows; /** * 阿里云短信构建类 * * @author Chill */ public class AliSmsBuilder { @SneakyThrows public static SmsTemplate template(SmsConfig sms, RedisService redisService) { SmsProperties smsProperties = new SmsProperties(); smsProperties.setTemplateId(sms.getTemplateId()); smsProperties.setAccessKey(sms.getAccessKey()); smsProperties.setSecretKey(sms.getSecretKey()); smsProperties.setRegionId(sms.getRegionId()); smsProperties.setSignName(sms.getSignName()); IClientProfile profile = DefaultProfile.getProfile(smsProperties.getRegionId(), smsProperties.getAccessKey(), smsProperties.getSecretKey()); IAcsClient acsClient = new DefaultAcsClient(profile); return new AliSmsTemplate(smsProperties, acsClient, redisService); } }