SmsUtil参数从sysparam获取
This commit is contained in:
parent
d7102db1e8
commit
d808e70eec
|
|
@ -34,6 +34,10 @@
|
||||||
<groupId>com.pig4cloud.excel</groupId>
|
<groupId>com.pig4cloud.excel</groupId>
|
||||||
<artifactId>excel-spring-boot-starter</artifactId>
|
<artifactId>excel-spring-boot-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.dubbo</groupId>
|
||||||
|
<artifactId>dubbo-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,14 @@ import com.aliyun.dysmsapi20170525.Client;
|
||||||
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
|
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
|
||||||
import com.aliyun.teaopenapi.models.Config;
|
import com.aliyun.teaopenapi.models.Config;
|
||||||
import com.czg.exception.ApiNotPrintException;
|
import com.czg.exception.ApiNotPrintException;
|
||||||
|
import com.czg.resp.CzgResult;
|
||||||
|
import com.czg.system.dto.SysParamsDTO;
|
||||||
|
import com.czg.system.service.SysParamsService;
|
||||||
|
import jakarta.annotation.PostConstruct;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -17,23 +22,41 @@ import org.springframework.stereotype.Component;
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SmsUtil {
|
public class SmsUtil {
|
||||||
|
@Resource
|
||||||
|
private ApplicationContext applicationContext;
|
||||||
|
@DubboReference(check = false)
|
||||||
|
private SysParamsService remoteSysParamsService;
|
||||||
|
private SysParamsService sysParamsService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 阿里云key
|
* 阿里云key
|
||||||
*/
|
*/
|
||||||
@Value("${alipay.sms.key}")
|
// @Value("${alipay.sms.key}")
|
||||||
private String key;
|
private String key;
|
||||||
/**
|
/**
|
||||||
* 阿里云secret
|
* 阿里云secret
|
||||||
*/
|
*/
|
||||||
@Value("${alipay.sms.secret}")
|
// @Value("${alipay.sms.secret}")
|
||||||
private String secret;
|
private String secret;
|
||||||
/**
|
/**
|
||||||
* 短信模板id
|
* 短信模板id
|
||||||
*/
|
*/
|
||||||
@Value("${alipay.sms.templateCode}")
|
// @Value("${alipay.sms.templateCode}")
|
||||||
private String templateCode;
|
private String templateCode;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public SysParamsService init() {
|
||||||
|
sysParamsService = remoteSysParamsService == null ? applicationContext.getBean(SysParamsService.class): remoteSysParamsService;
|
||||||
|
CzgResult<SysParamsDTO> aliSmsKey = sysParamsService.getParamsByCode("ali_sms_key");
|
||||||
|
CzgResult<SysParamsDTO> aliSmsSecret = sysParamsService.getParamsByCode("ali_sms_secret");
|
||||||
|
CzgResult<SysParamsDTO> aliSmsTemplateCode = sysParamsService.getParamsByCode("ali_sms_template_code");
|
||||||
|
key = aliSmsKey.getData().getParamValue();
|
||||||
|
secret = aliSmsSecret.getData().getParamValue();
|
||||||
|
templateCode = aliSmsTemplateCode.getData().getParamValue();
|
||||||
|
log.info("短信工具类初始化完毕,key: {}, secret: {}, templateCode: {}", key, secret, templateCode);
|
||||||
|
return sysParamsService;
|
||||||
|
}
|
||||||
|
|
||||||
public Client createClient() throws Exception {
|
public Client createClient() throws Exception {
|
||||||
Config config = new Config();
|
Config config = new Config();
|
||||||
config.accessKeyId = key;
|
config.accessKeyId = key;
|
||||||
|
|
@ -93,10 +93,7 @@
|
||||||
<artifactId>mysql-connector-j</artifactId>
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.dubbo</groupId>
|
|
||||||
<artifactId>dubbo-spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue