| 
					
				 | 
			
			
				@@ -1,5 +1,6 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.ym.mec.util.http; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.alibaba.fastjson.JSON; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.alibaba.fastjson.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.alibaba.fastjson.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.util.compress.ZipUtil; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -39,11 +40,33 @@ import java.util.Map.Entry; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class HttpUtil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //	public static void main(String[] args) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//		System.out.println(getSortUrl("https://mstuonline.dayaedu.com/#/studentDownload")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//		System.out.println(getSortUrl2("https://mstuonline.dayaedu.com/#/studentDownload")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	public static String getSortUrl(String url){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			//自有短网址 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			JSONObject result = getSortUrl2(url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			String code = result.getString("code"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if(StringUtils.equals(code,"200")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				return result.getString("data"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			}else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				//百度短网址 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				result = getSortUrl3(url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				code = result.getString("Code"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if(code.equals("0")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					return JSONArray.parseArray(result.getString("ShortUrls")).getJSONObject(0).getString("ShortUrl"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				}else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					//第三方免费短网址 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					return getSortUrl1(url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		}catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			return url; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public static JSONObject getSortUrl3(String url){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			JSONArray jsonArray = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			JSONObject jsonObject = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			jsonObject.put("LongUrl",url); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -54,24 +77,11 @@ public class HttpUtil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			HeadMap.put("Content-Type","application/json; charset=UTF-8"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			HeadMap.put("Content-Language","zh"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			String s = postForHttps("https://dwz.cn/api/v3/short-urls", jsonArray.toJSONString(),HeadMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			JSONObject result = JSONObject.parseObject(s); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			String code=result.getString("Code"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if(code.equals("0")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				String shortUrl = JSONArray.parseArray(result.getString("ShortUrls")).getJSONObject(0).getString("ShortUrl"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				return shortUrl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			}else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				JSONArray jsonArray1 = JSONArray.parseArray(result.getString("ShortUrls")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				if(jsonArray1 != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					String errorMsg = JSONArray.parseArray(result.getString("ShortUrls")).getJSONObject(0).getString("ErrMsg"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					System.out.println("短网址生成失败:" + errorMsg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				}else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					System.out.println("短网址生成失败:" + result.getString("ErrMsg")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				return getSortUrl1(url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			return JSONObject.parseObject(s); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		}catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			return url; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			return new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	public static String getSortUrl1(String url){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -91,6 +101,20 @@ public class HttpUtil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			return url; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public static JSONObject getSortUrl2(String url){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			Map<String,Object> paramMap = new HashMap<>(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			paramMap.put("longURL",URLDecoder.decode(url,"UTF-8")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			paramMap.put("key","dayayuemeng"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			Map<String,String> HeadMap = new HashMap<>(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			HeadMap.put("Content-Type","application/json; charset=UTF-8"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			String s = postForHttps("http://dwz.lexiaoya.cn/generate", JSON.toJSONString(paramMap),HeadMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			return JSONObject.parseObject(s); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		}catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			return new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * POST请求http url 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 *  
			 |