Commit 663f5dde by 284718418@qq.com

Merge branch 'develop' into feature_20220222_huayi

parents bc3c3fde 2518b4cf
...@@ -784,6 +784,10 @@ public class LoginController { ...@@ -784,6 +784,10 @@ public class LoginController {
} }
qyzxEmpLogin1.setOrgId(ctrl.getId()); qyzxEmpLogin1.setOrgId(ctrl.getId());
if (ctrl.getStatus().equals(9)) {
return ResultUtil.error("9","服务器变更");
}
if (SysRoleType.U_TYPE_ADMIN.getType().equals(ctrl.getUserType()) if (SysRoleType.U_TYPE_ADMIN.getType().equals(ctrl.getUserType())
|| SysRoleType.U_TYPE_C_ADMIN.getType().equals(ctrl.getUserType())) { || SysRoleType.U_TYPE_C_ADMIN.getType().equals(ctrl.getUserType())) {
} else { } else {
......
package cn.timer.api.utils; package cn.timer.api.utils;
import java.io.BufferedReader; import java.io.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ConnectException; import java.net.ConnectException;
import java.net.SocketTimeoutException; import java.net.SocketTimeoutException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import java.util.Map;
import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext; import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager; import javax.net.ssl.X509TrustManager;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* 通用http发送方法 * 通用http发送方法
* *
* @author Tang * @author Tang
*/ */
public class HttpUtils public class HttpUtils
...@@ -44,10 +44,10 @@ public class HttpUtils ...@@ -44,10 +44,10 @@ public class HttpUtils
String urlNameString = url + "?" + param; String urlNameString = url + "?" + param;
log.info("sendGet - {}", urlNameString); log.info("sendGet - {}", urlNameString);
URL realUrl = new URL(urlNameString); URL realUrl = new URL(urlNameString);
URLConnection connection = realUrl.openConnection(); HttpsURLConnection connection = (HttpsURLConnection)realUrl.openConnection();
connection.setRequestProperty("accept", "*/*"); connection.setRequestProperty("accept", "*/*");
connection.setRequestProperty("connection", "Keep-Alive"); connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36)");
connection.connect(); connection.connect();
in = new BufferedReader(new InputStreamReader(connection.getInputStream())); in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line; String line;
...@@ -97,11 +97,12 @@ public class HttpUtils ...@@ -97,11 +97,12 @@ public class HttpUtils
* @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @return 所代表远程资源的响应结果 * @return 所代表远程资源的响应结果
*/ */
public static String sendPost(String url, String param) public static String sendPost(String url, Map paramMap, Map bodyMap)
{ {
PrintWriter out = null; DataOutputStream out=null;
BufferedReader in = null; BufferedReader in = null;
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
String param = getParamString(paramMap);
try try
{ {
String urlNameString = url + "?" + param; String urlNameString = url + "?" + param;
...@@ -110,15 +111,16 @@ public class HttpUtils ...@@ -110,15 +111,16 @@ public class HttpUtils
URLConnection conn = realUrl.openConnection(); URLConnection conn = realUrl.openConnection();
conn.setRequestProperty("accept", "*/*"); conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive"); conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36)");
conn.setRequestProperty("Accept-Charset", "utf-8"); conn.setRequestProperty("Accept-Charset", "utf-8");
conn.setRequestProperty("contentType", "utf-8"); conn.setRequestProperty("contentType", "text/json;charset=UTF-8");
conn.setDoOutput(true); conn.setDoOutput(true);
conn.setDoInput(true); conn.setDoInput(true);
out = new PrintWriter(conn.getOutputStream()); out = new DataOutputStream(conn.getOutputStream());
out.print(param); String json = JSONObject.toJSONString(bodyMap);
out.write(json.getBytes(StandardCharsets.UTF_8));
out.flush(); out.flush();
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8")); in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line; String line;
while ((line = in.readLine()) != null) while ((line = in.readLine()) != null)
{ {
...@@ -176,9 +178,9 @@ public class HttpUtils ...@@ -176,9 +178,9 @@ public class HttpUtils
HttpsURLConnection conn = (HttpsURLConnection) console.openConnection(); HttpsURLConnection conn = (HttpsURLConnection) console.openConnection();
conn.setRequestProperty("accept", "*/*"); conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive"); conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
conn.setRequestProperty("Accept-Charset", "utf-8"); conn.setRequestProperty("Accept-Charset", "utf-8");
conn.setRequestProperty("contentType", "utf-8"); conn.setRequestProperty("contentType", "text/json;charset=UTF-8");
conn.setDoOutput(true); conn.setDoOutput(true);
conn.setDoInput(true); conn.setDoInput(true);
...@@ -245,4 +247,16 @@ public class HttpUtils ...@@ -245,4 +247,16 @@ public class HttpUtils
return true; return true;
} }
} }
} /*参数转为字符串*/
\ No newline at end of file private static String getParamString(Map<String, String> paramMap){
if(null==paramMap || paramMap.isEmpty()){
return "";
}
StringBuilder builder = new StringBuilder();
for(String key : paramMap.keySet() ){
builder.append("&")
.append(key).append("=").append(paramMap.get(key));
}
return builder.deleteCharAt(0).toString();
}
}
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