Commit cd39595d authored by 刘鑫鹏's avatar 刘鑫鹏

修改发送短信接口

parent 84287542
...@@ -27,15 +27,8 @@ import com.tiptimes.service.SpaceFundService; ...@@ -27,15 +27,8 @@ import com.tiptimes.service.SpaceFundService;
import com.tiptimes.service.SpaceMessageService; import com.tiptimes.service.SpaceMessageService;
import com.tiptimes.service.TeamMessageService; import com.tiptimes.service.TeamMessageService;
import com.tiptimes.service.UserService; import com.tiptimes.service.UserService;
import com.tiptimes.util.BASE64Util; import com.tiptimes.util.*;
import com.tiptimes.util.DATEUtil;
import com.tiptimes.util.ExcelUtil;
import com.tiptimes.util.MD5Util;
import com.tiptimes.util.NumberUtil;
import com.tiptimes.util.RandomNumUtil;
import com.tiptimes.util.RegexValidateUtil;
import com.tiptimes.util.UUIDUtils;
import com.tiptimes.util.yuntongxunSMSUtil;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLDecoder; import java.net.URLDecoder;
...@@ -324,7 +317,8 @@ public class SpaceMessageCtrl { ...@@ -324,7 +317,8 @@ public class SpaceMessageCtrl {
SpaceMessage spaceMessage = this.spaceMessageService.getSpaceMessageBySpaceMessageID(spaceMessageID); SpaceMessage spaceMessage = this.spaceMessageService.getSpaceMessageBySpaceMessageID(spaceMessageID);
if (spaceMessage != null) { if (spaceMessage != null) {
if (!"".equals(spaceMessage.getPrincipalTell())) { if (!"".equals(spaceMessage.getPrincipalTell())) {
boolean a = yuntongxunSMSUtil.sandSMSPassword(spaceMessage.getPrincipalTell(), password_str); Boolean a = SendMessageUtil.sendMessage(spaceMessage.getPrincipalTell(), password_str);
// boolean a = yuntongxunSMSUtil.sandSMSPassword(spaceMessage.getPrincipalTell(), password_str);
System.err.println(password_str); System.err.println(password_str);
if (a) { if (a) {
userLogin.setUserPassword(MD5Util.encryptByMD5(password_str)); userLogin.setUserPassword(MD5Util.encryptByMD5(password_str));
......
package com.tiptimes.util;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class SendMessageUtil {
public static Boolean sendMessage(String tell, String code) {
try {
// 设置请求的 URL
String urlString = "http://124.251.7.232:9100/QxtSms/QxtFirewall";
String name = "tjsrj";
String pass = "T6jes@832#TJ";
// 获取当前时间
LocalDateTime now = LocalDateTime.now();
// 定义时间增量为5秒
Duration duration = Duration.ofSeconds(5);
// 增加时间增量
LocalDateTime later = now.plus(duration);
// 定义日期时间格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
// 格式化当前时间
String sendtime = later.format(formatter);
String content = "【天津高校众创空间运营管理信息平台】您重置后的密码是:" + code;
StringBuilder queryParams = new StringBuilder();
queryParams.append("name=").append(URLEncoder.encode(name, "UTF-8"));
queryParams.append("&pass=").append(URLEncoder.encode(pass, "UTF-8"));
queryParams.append("&mobiles=").append(URLEncoder.encode(tell, "UTF-8"));
queryParams.append("&content=").append(URLEncoder.encode(content, "UTF-8"));
queryParams.append("&sendtime=").append(URLEncoder.encode(sendtime, "UTF-8"));
String requestUrl = urlString + "?" + queryParams.toString();
URL url = new URL(requestUrl);
// 创建连接对象
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// 设置请求方法为 GET
connection.setRequestMethod("GET");
// 发送请求并获取响应
int responseCode = connection.getResponseCode();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
StringBuilder response = new StringBuilder();
while ((line = reader.readLine()) != null) {
response.append(line);
}
reader.close();
// 获取响应字符串
String responseBody = response.toString();
// 判断响应结果并返回布尔值
if (responseBody.endsWith(",00")) {
return true;
} else {
return false;
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment