|
@@ -6,6 +6,7 @@ import cn.hutool.json.JSONUtil;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.dromara.common.core.api.ReturnResult;
|
|
import org.dromara.common.core.api.ReturnResult;
|
|
|
|
|
+import org.dromara.common.core.utils.sms.SmsUtil;
|
|
|
import org.dromara.common.redis.utils.RedisUtils;
|
|
import org.dromara.common.redis.utils.RedisUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -25,30 +26,40 @@ import java.util.Map;
|
|
|
@Service
|
|
@Service
|
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
|
public class AsyncTaskService {
|
|
public class AsyncTaskService {
|
|
|
- @Value("${third-api.sms-api}")
|
|
|
|
|
- String smsApi;
|
|
|
|
|
|
|
+// @Value("${third-api.sms-api}")
|
|
|
|
|
+// String smsApi;
|
|
|
|
|
+
|
|
|
|
|
+ @Value("${sms.gateway.systemCode:SYS004}")
|
|
|
|
|
+ private String systemCode;
|
|
|
|
|
+
|
|
|
|
|
+ @Value("${sms.gateway.secret:afcd53c8cfdcfb2b150238a783a04d355697d84857dacbd931522fa8ade94b2d}")
|
|
|
|
|
+ private String secret;
|
|
|
|
|
+
|
|
|
|
|
+ @Value("${sms.gateway.url:http://172.16.137.140:48088/system/sms-gateway/send}") // http://59.231.239.52:48088/system/sms-gateway/send
|
|
|
|
|
+ private String url;
|
|
|
|
|
|
|
|
|
|
|
|
|
public void asyncSendSms(String mobile, String message) {
|
|
public void asyncSendSms(String mobile, String message) {
|
|
|
- String keyToken = "yktSmsToken";
|
|
|
|
|
- String sendUrl = smsApi + "sms/api/v1/send";
|
|
|
|
|
- String tokens = RedisUtils.getCacheObject(keyToken);
|
|
|
|
|
- Map<String, String> mapHeaders = new HashMap<>(2);
|
|
|
|
|
- mapHeaders.put("businessName","ykt");
|
|
|
|
|
- mapHeaders.put("token", tokens);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- Map<String, String> mapMessages = new HashMap<>(2);
|
|
|
|
|
- mapMessages.put("mobile", mobile);
|
|
|
|
|
- mapMessages.put("message", message);
|
|
|
|
|
- try {
|
|
|
|
|
- HttpRequest req = HttpUtil.createPost(sendUrl);
|
|
|
|
|
- req.headerMap(mapHeaders,false);
|
|
|
|
|
- ReturnResult sendResult = JSONUtil.toBean(req.body(JSONUtil.toJsonStr(mapMessages)).execute().body(), ReturnResult.class);
|
|
|
|
|
- log.info("[短信发送]-{\"内容\":\"{}\",\"结果\":\"{}\"", message, sendResult.getMessage());
|
|
|
|
|
- } catch (Exception ex) {
|
|
|
|
|
- log.info("[短信发送]-{\"内容\":\"{}\",\"发送异常\":\"{}\"", message, ex.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// String keyToken = "yktSmsToken";
|
|
|
|
|
+// String sendUrl = smsApi + "sms/api/v1/send";
|
|
|
|
|
+// String tokens = RedisUtils.getCacheObject(keyToken);
|
|
|
|
|
+// Map<String, String> mapHeaders = new HashMap<>(2);
|
|
|
|
|
+// mapHeaders.put("businessName","ykt");
|
|
|
|
|
+// mapHeaders.put("token", tokens);
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// Map<String, String> mapMessages = new HashMap<>(2);
|
|
|
|
|
+// mapMessages.put("mobile", mobile);
|
|
|
|
|
+// mapMessages.put("message", message);
|
|
|
|
|
+// try {
|
|
|
|
|
+// HttpRequest req = HttpUtil.createPost(sendUrl);
|
|
|
|
|
+// req.headerMap(mapHeaders,false);
|
|
|
|
|
+// ReturnResult sendResult = JSONUtil.toBean(req.body(JSONUtil.toJsonStr(mapMessages)).execute().body(), ReturnResult.class);
|
|
|
|
|
+// log.info("[短信发送]-{\"内容\":\"{}\",\"结果\":\"{}\"", message, sendResult.getMessage());
|
|
|
|
|
+// } catch (Exception ex) {
|
|
|
|
|
+// log.info("[短信发送]-{\"内容\":\"{}\",\"发送异常\":\"{}\"", message, ex.getMessage());
|
|
|
|
|
+// }
|
|
|
|
|
+ SmsUtil.send(url, systemCode, secret, mobile, message);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|