1.修改日志报错问题
2.移动公用地址到common下
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package com.ruoyi.common.core.domain.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SmsRequestDTO {
|
||||
/**
|
||||
* name
|
||||
*/
|
||||
private String secretName;
|
||||
/**
|
||||
* key
|
||||
*/
|
||||
private String secretKey;
|
||||
/**
|
||||
* 手机号码,多个号码请用英文逗号隔开
|
||||
*/
|
||||
private String mobile;
|
||||
/**
|
||||
* 短信内容,请保持在500字以内。注意:使用短信模板进行提交时,请填写模板拼接后的完整内容。
|
||||
* 方式一:
|
||||
* {"SecretName":"API","SecretKey":"000000","TimeStamp":null,"Mobile":"13000000000","Content":"你好,你的验证码是541254,有效期5分钟。","TemplateId":"","ExtCode":"","SignName":"","Timing":"","CustomId":""}
|
||||
* 方式二:
|
||||
* {"SecretName":"API","SecretKey":"000000","TimeStamp":null,"Mobile":"13000000000","Content":"","TemplateId":"000000","TemplateVars":["541254","5"],"ExtCode":"","SignName":"","Timing":"","CustomId":""}
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 模板id
|
||||
*/
|
||||
private String templateId;
|
||||
|
||||
/**
|
||||
* 短信模板变量集合,集合中数据类型为String
|
||||
*/
|
||||
private String[] templateVars;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.ruoyi.common.utils.aliyun;
|
||||
|
||||
/**
|
||||
* 阿里云配置
|
||||
*/
|
||||
public class AliyunNlsUtils {
|
||||
|
||||
/**
|
||||
* 标志
|
||||
*/
|
||||
public static final boolean USE_TEST_ENV=true;
|
||||
/**
|
||||
* 测试nls
|
||||
*/
|
||||
public static final String NLS_TEST_URL="wss://nls-gateway-cn-shanghai.aliyuncs.com";
|
||||
/**
|
||||
* 测试微信获取oppenid链接
|
||||
*/
|
||||
public static final String WX_TEST_URL="https://api.weixin.qq.com/sns/jscode2session";
|
||||
/**
|
||||
* 正式nls
|
||||
*/
|
||||
public static final String NLS_FORMAL_URL="http://192.168.2.102:10044";
|
||||
|
||||
/**
|
||||
* 测试短短地址
|
||||
*/
|
||||
public static final String SMS_TEST_URL="https://api.028lk.com/Sms/Api/Send";
|
||||
|
||||
/**
|
||||
* 根据环境判断正式还是测试
|
||||
* @return
|
||||
*/
|
||||
public static String getNlsUrl(){
|
||||
String url = USE_TEST_ENV ? NLS_TEST_URL : NLS_FORMAL_URL;
|
||||
System.out.println("nls当前环境:" + (USE_TEST_ENV ? "测试" : "正式") + ",WebSocket地址:" + url);
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信授权登录
|
||||
* @return
|
||||
*/
|
||||
public static String getWXoppenidUrl(){
|
||||
String url = USE_TEST_ENV ? WX_TEST_URL : NLS_FORMAL_URL+"/weixin";
|
||||
System.out.println("微信授权登录当前环境:" + (USE_TEST_ENV ? "测试" : "正式") + ",获取oppenid地址:" + url);
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 短信验证码地址
|
||||
* @return
|
||||
*/
|
||||
public static String getSmsUrl(){
|
||||
String url = USE_TEST_ENV ? SMS_TEST_URL : NLS_FORMAL_URL+"/ksSend";
|
||||
System.out.println("短信地址当前环境:" + (USE_TEST_ENV ? "测试" : "正式") + ",sms地址:" + url);
|
||||
return url;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,7 @@
|
||||
package com.ruoyi.common.utils.http;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.ConnectException;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.cert.X509Certificate;
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
@@ -244,6 +237,78 @@ public class HttpUtils
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public static String snedSmsPost(String httpUrl, String data) {
|
||||
|
||||
HttpURLConnection connection = null;
|
||||
InputStream inputStream = null;
|
||||
OutputStream outputStream = null;
|
||||
BufferedReader bufferedReader = null;
|
||||
String result = null;
|
||||
try {
|
||||
URL url = new URL(httpUrl);
|
||||
// 通过远程url连接对象打开连接
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
// 设置连接请求方式
|
||||
connection.setRequestMethod("POST");
|
||||
// 设置连接主机服务器超时时间:15000毫秒
|
||||
connection.setConnectTimeout(15000);
|
||||
// 设置读取主机服务器返回数据超时时间:60000毫秒
|
||||
connection.setReadTimeout(60000);
|
||||
// 默认值为:false,当向远程服务器传送数据/写数据时,需要设置为true
|
||||
connection.setDoOutput(true);
|
||||
// 设置传入参数的格式:请求参数应该是 name1=value1&name2=value2 的形式。
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
// 通过连接对象获取一个输出流
|
||||
outputStream = connection.getOutputStream();
|
||||
// 通过输出流对象将参数写出去/传输出去,它是通过字节数组写出的
|
||||
outputStream.write(data.getBytes());
|
||||
// 通过连接对象获取一个输入流,向远程读取
|
||||
if (connection.getResponseCode() == 200) {
|
||||
inputStream = connection.getInputStream();
|
||||
// 对输入流对象进行包装:charset根据工作项目组的要求来设置
|
||||
bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
String temp = null;
|
||||
// 循环遍历一行一行读取数据
|
||||
while ((temp = bufferedReader.readLine()) != null) {
|
||||
stringBuffer.append(temp);
|
||||
stringBuffer.append("\r\n");
|
||||
}
|
||||
result = stringBuffer.toString();
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
// 关闭资源
|
||||
if (null != bufferedReader) {
|
||||
try {
|
||||
bufferedReader.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (null != outputStream) {
|
||||
try {
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (null != inputStream) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// 断开与远程地址url的连接
|
||||
connection.disconnect();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static class TrustAnyTrustManager implements X509TrustManager
|
||||
{
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user