Newer
Older
newfiber-termite / newfiber-system / newfiber-system-sms / src / main / java / com / newfiber / system / builder / QiniuSmsBuilder.java
package com.newfiber.system.builder;

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.QiniuSmsTemplate;
import com.newfiber.system.template.SmsTemplate;
import com.qiniu.sms.SmsManager;
import com.qiniu.util.Auth;
import lombok.SneakyThrows;

/**
 * 七牛云短信构建类
 *
 * @author Chill
 */
public class QiniuSmsBuilder {

	@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());
		Auth auth = Auth.create(smsProperties.getAccessKey(), smsProperties.getSecretKey());
		SmsManager smsManager = new SmsManager(auth);
		return new QiniuSmsTemplate(smsProperties, smsManager, redisService);
	}

}