qxp 4 years ago
parent
commit
5ab7446e9f

+ 2 - 2
suishenbang-admin/src/main/resources/application-uat.yml

@@ -9,9 +9,9 @@ ruoyi:
   # 实例演示开关
   demoEnabled: true
   # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
-  profile: /home/admin/priject/file
+  profile: /home/admin/project/file
   # 获取ip地址开关
-  addressEnabled: true
+  addressEnabled: false
   cloudPath: http://suishenbangtest.nipponpaint.com.cn/gateway/
 #经销商微信接口相关配置
 customer:

+ 2 - 2
suishenbang-api/src/main/resources/application-uat.yml

@@ -7,9 +7,9 @@ ruoyi:
   # 版权年份
   copyrightYear: 2020
   # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
-  profile: /home/admin/priject/file
+  profile: /home/admin/project/file
   # 获取ip地址开关
-  addressEnabled: true
+  addressEnabled: false
   #是否开启swagger
   openSwagger: true
 #接口安全验证

+ 65 - 0
suishenbang-common/src/main/java/com/dgtly/common/utils/http/HttpUtils.java

@@ -9,6 +9,7 @@ import java.net.ConnectException;
 import java.net.SocketTimeoutException;
 import java.net.URL;
 import java.net.URLConnection;
+import java.security.cert.CertificateException;
 import java.security.cert.X509Certificate;
 import java.text.ParseException;
 import javax.net.ssl.HostnameVerifier;
@@ -54,6 +55,7 @@ public class HttpUtils
             String urlNameString = url;
             log.info("sendGet - {}", urlNameString);
             URL realUrl = new URL(urlNameString);
+
             URLConnection connection = realUrl.openConnection();
             connection.setRequestProperty("accept", "*/*");
             connection.setRequestProperty("connection", "Keep-Alive");
@@ -117,6 +119,7 @@ public class HttpUtils
             String urlNameString = url + "?" + param;
             log.info("sendPost - {}", urlNameString);
             URL realUrl = new URL(urlNameString);
+
             URLConnection conn = realUrl.openConnection();
             conn.setRequestProperty("accept", "*/*");
             conn.setRequestProperty("connection", "Keep-Alive");
@@ -189,6 +192,7 @@ public class HttpUtils
         {
             log.info("sendPost - {}", url);
             URL realUrl = new URL(url);
+
             URLConnection conn = realUrl.openConnection();
             conn.setRequestProperty("accept", "*/*");
             conn.setRequestProperty("connection", "Keep-Alive");
@@ -244,7 +248,67 @@ public class HttpUtils
         }
         return result.toString();
     }
+    public static String sendSSLGet(String url)
+    {
+        StringBuilder result = new StringBuilder();
+        BufferedReader in = null;
+        try
+        {
+            String urlNameString = url;
+            log.info("sendSSLGet - {}", urlNameString);
+            SSLContext sc = SSLContext.getInstance("SSL");
+            sc.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new java.security.SecureRandom());
+            URL realUrl = new URL(urlNameString);
 
+            HttpsURLConnection connection = (HttpsURLConnection)realUrl.openConnection();
+            connection.setRequestProperty("accept", "*/*");
+            connection.setRequestProperty("connection", "Keep-Alive");
+            connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
+
+            connection.setSSLSocketFactory(sc.getSocketFactory());
+            connection.setHostnameVerifier(new TrustAnyHostnameVerifier());
+
+            connection.connect();
+            in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+            String line;
+            while ((line = in.readLine()) != null)
+            {
+                result.append(line);
+            }
+            log.info("recv - {}", result);
+        }
+        catch(ConnectException e)
+        {
+            log.error("调用HttpUtils.sendGet ConnectException, url=" + url , e);
+        }
+        catch (SocketTimeoutException e)
+        {
+            log.error("调用HttpUtils.sendGet SocketTimeoutException, url=" + url , e);
+        }
+        catch (IOException e)
+        {
+            log.error("调用HttpUtils.sendGet IOException, url=" + url, e);
+        }
+        catch (Exception e)
+        {
+            log.error("调用HttpsUtil.sendGet Exception, url=" + url , e);
+        }
+        finally
+        {
+            try
+            {
+                if (in != null)
+                {
+                    in.close();
+                }
+            }
+            catch (Exception ex)
+            {
+                log.error("调用in.close Exception, url=" + url , ex);
+            }
+        }
+        return result.toString();
+    }
 
 
     public static String sendSSLPost(String url, String param)
@@ -257,6 +321,7 @@ public class HttpUtils
             SSLContext sc = SSLContext.getInstance("SSL");
             sc.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new java.security.SecureRandom());
             URL console = new URL(urlNameString);
+
             HttpsURLConnection conn = (HttpsURLConnection) console.openConnection();
             conn.setRequestProperty("accept", "*/*");
             conn.setRequestProperty("connection", "Keep-Alive");

+ 2 - 2
suishenbang-sync/suishenbang-sync-common/src/main/java/com/dgtly/sync/service/AnalysisDiyCustomerComponent.java

@@ -79,7 +79,7 @@ public class AnalysisDiyCustomerComponent {
         long total = 0;
         long success = 0;
         Set<String> loginNameSet = sysUserService.selectAllUserLoginName();
-        String managerJson = HttpUtils.sendGet(customerAccessTokenUtil.getUrl(UrlType.MANAGER));
+        String managerJson = HttpUtils.sendSSLGet(customerAccessTokenUtil.getUrl(UrlType.MANAGER));
         JSONObject mjson = JSONObject.parseObject(managerJson);
 
         int code = mjson.getInteger("code");
@@ -91,7 +91,7 @@ public class AnalysisDiyCustomerComponent {
 
 
 
-        String guideJson = HttpUtils.sendGet(customerAccessTokenUtil.getUrl(UrlType.STOREGUIDE));
+        String guideJson = HttpUtils.sendSSLGet(customerAccessTokenUtil.getUrl(UrlType.STOREGUIDE));
         JSONObject gjson = JSONObject.parseObject(guideJson);
         code = gjson.getInteger("code");
         if(code==0){

+ 1 - 1
suishenbang-sync/suishenbang-sync-common/src/main/java/com/dgtly/sync/utils/CustomerAccessTokenUtil.java

@@ -66,7 +66,7 @@ public class CustomerAccessTokenUtil {
         //token未过期使用缓存的token
         long currentTiem = new Date().getSeconds();
         if(accessToken==null||((currentTiem-createTime)>=expires)){
-            String res = HttpUtils.sendGet(String.format(tokenUrl,appid,appsecret));
+            String res = HttpUtils.sendSSLGet(String.format(tokenUrl,appid,appsecret));
             JSONObject json = JSONObject.parseObject(res);
             int code = json.getInteger("code");
             if(code==0){

+ 3 - 1
suishenbang-wxportal/suishenbang-wxportal-common/src/main/java/com/dgtly/wxportal/domain/WxBanner.java

@@ -5,6 +5,8 @@ import org.apache.commons.lang3.builder.ToStringStyle;
 import com.dgtly.common.annotation.Excel;
 import com.dgtly.common.core.domain.BaseEntity;
 
+import javax.validation.constraints.Size;
+
 /**
  * 企业微信门户首页banner图对象 wx_banner
  * 
@@ -70,7 +72,7 @@ public class WxBanner extends BaseEntity
     {
         this.des = des;
     }
-
+    @Size(min = 0, max = 255, message = "摘要不能超过255个字符")
     public String getDes() 
     {
         return des;

+ 3 - 2
suishenbang-wxportal/suishenbang-wxportal-common/src/main/java/com/dgtly/wxportal/domain/WxMagnet.java

@@ -77,7 +77,7 @@ public class WxMagnet extends BaseEntity
         this.orderNum = orderNum;
     }
 
-    @Size(min = 0, max = 200, message = "请求地址不能超过200个字符")
+    @Size(min = 0, max = 400, message = "请求地址不能超过200个字符")
     public String getUrl()
     {
         return url;
@@ -98,7 +98,7 @@ public class WxMagnet extends BaseEntity
         this.visible = visible;
     }
 
-    @Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符")
+    @Size(min = 0, max = 1, message = "权限标识长度不能超过100个字符")
     public String getMagnetSize()
     {
         return magnetSize;
@@ -109,6 +109,7 @@ public class WxMagnet extends BaseEntity
         this.magnetSize = magnetSize;
     }
 
+    @Size(min = 0, max = 400, message = "请求图片地址不能超过200个字符")
     public String getBgUrl()
     {
         return bgUrl;