|
|
@@ -21,6 +21,7 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
import org.apache.http.impl.client.HttpClients;
|
|
|
import org.apache.http.util.EntityUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
@@ -32,10 +33,22 @@ public class SmsTServiceImpl implements SmsService {
|
|
|
@Autowired
|
|
|
private RedisCache redisCache;
|
|
|
|
|
|
+ /** 腾讯云 SecretId,从配置注入,禁止硬编码 */
|
|
|
+ @Value("${tencent.cloud.secret-id:}")
|
|
|
+ private String tencentSecretId;
|
|
|
+
|
|
|
+ /** 腾讯云 SecretKey,从配置注入,禁止硬编码 */
|
|
|
+ @Value("${tencent.cloud.secret-key:}")
|
|
|
+ private String tencentSecretKey;
|
|
|
+
|
|
|
@Override
|
|
|
public R sendTSms(String mobile, String code) {
|
|
|
try {
|
|
|
- Credential cred = new Credential("AKIDdAdvzoQpzuOo11mq2TntjKI5eqrhNp22", "zmLgpzzcwAFNJ4dx2iDTVHgw3ELCrIVg");
|
|
|
+ if (tencentSecretId == null || tencentSecretId.isEmpty()
|
|
|
+ || tencentSecretKey == null || tencentSecretKey.isEmpty()) {
|
|
|
+ return R.error("腾讯云短信密钥未配置,请设置 tencent.cloud.secret-id/secret-key");
|
|
|
+ }
|
|
|
+ Credential cred = new Credential(tencentSecretId, tencentSecretKey);
|
|
|
HttpProfile httpProfile = new HttpProfile();
|
|
|
httpProfile.setEndpoint("sms.tencentcloudapi.com");
|
|
|
ClientProfile clientProfile = new ClientProfile();
|