Newer
Older
newfiber-termite / newfiber-system / newfiber-system-sms / src / main / java / com / newfiber / system / builder / TencentSmsBuilder.java
@yanghui yanghui on 11 May 1005 bytes 白蚁项目初版代码提交
package com.newfiber.system.builder;

import com.github.qcloudsms.SmsMultiSender;
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.SmsTemplate;
import com.newfiber.system.template.TencentSmsTemplate;
import lombok.SneakyThrows;

/**
 * 腾讯云短信构建类
 *
 * @author Chill
 */
public class TencentSmsBuilder {

	@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.setSignName(sms.getSignName());
		SmsMultiSender smsSender = new SmsMultiSender(Integer.parseInt(smsProperties.getAccessKey()), sms.getSecretKey());
		return new TencentSmsTemplate(smsProperties, smsSender, redisService);
	}

}