更新
This commit is contained in:
parent
389a91389a
commit
982c7cb71e
@ -1,19 +1,26 @@
|
||||
package com.lovenav.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.lovenav.entity.UrlCateList;
|
||||
import com.lovenav.entity.UrlList;
|
||||
import com.lovenav.service.UrlCateListService;
|
||||
import com.lovenav.service.UrlListService;
|
||||
import com.lovenav.utils.UrlCheckUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
public class UrlListController {
|
||||
@Autowired
|
||||
private UrlCheckUtil urlCheckUtil;
|
||||
@Autowired
|
||||
UrlListService urlListService;
|
||||
@Autowired
|
||||
@ -149,4 +156,26 @@ public class UrlListController {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/urlcheck")
|
||||
public String urlcheck(String url) throws MalformedURLException, URISyntaxException {
|
||||
HashMap<String,Object> hashMap = new HashMap<>();
|
||||
if(urlCheckUtil.CheckHttp(url)){
|
||||
String x = urlCheckUtil.checkUrlConnection(url);
|
||||
if(x.equals("404")){
|
||||
hashMap.put("code",x);
|
||||
hashMap.put("msg", "https");
|
||||
}else{
|
||||
hashMap.put("code",x);
|
||||
hashMap.put("msg", "https");
|
||||
}
|
||||
return JSON.toJSONString(hashMap);
|
||||
// urlCheckUtil.url_speed(url);
|
||||
}else{
|
||||
hashMap.put("msg", "http");
|
||||
return JSON.toJSONString(hashMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,12 +7,15 @@ import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.*;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
@Component
|
||||
public class UrlCheckUtil {
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user