Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haoban3.0
haoban-manage3.0
Commits
bfbe4105
Commit
bfbe4105
authored
Nov 15, 2023
by
徐高华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TEST
parent
176ddcd1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
4 deletions
+56
-4
TestController.java
.../com/gic/haoban/manage/web/controller/TestController.java
+56
-4
No files found.
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/TestController.java
View file @
bfbe4105
...
...
@@ -5,10 +5,7 @@ import java.io.InputStream;
import
java.io.InputStreamReader
;
import
java.io.OutputStream
;
import
java.io.UnsupportedEncodingException
;
import
java.net.ConnectException
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.net.URLEncoder
;
import
java.net.*
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
...
...
@@ -31,6 +28,7 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.alibaba.fastjson.JSON
;
...
...
@@ -605,4 +603,58 @@ public class TestController extends WebBaseController {
}
return
null
;
}
public
static
String
httpRequest
(
String
requestUrl
,
String
requestMethod
,
String
outputStr
,
int
timeOut
)
{
if
(
timeOut
==
0
)
{
timeOut
=
1000
;
}
try
{
URL
url
=
new
URL
(
requestUrl
);
HttpURLConnection
conn
=
(
HttpURLConnection
)
url
.
openConnection
();
conn
.
setDoOutput
(
true
);
conn
.
setDoInput
(
true
);
conn
.
setUseCaches
(
false
);
conn
.
setReadTimeout
(
timeOut
);
conn
.
setRequestMethod
(
requestMethod
);
if
(
null
!=
outputStr
)
{
OutputStream
outputStream
=
conn
.
getOutputStream
();
outputStream
.
write
(
outputStr
.
getBytes
(
"UTF-8"
));
outputStream
.
close
();
}
InputStream
inputStream
=
conn
.
getInputStream
();
InputStreamReader
inputStreamReader
=
new
InputStreamReader
(
inputStream
,
"utf-8"
);
BufferedReader
bufferedReader
=
new
BufferedReader
(
inputStreamReader
);
String
str
=
null
;
StringBuilder
buffer
=
new
StringBuilder
();
while
((
str
=
bufferedReader
.
readLine
())
!=
null
)
{
buffer
.
append
(
str
);
}
bufferedReader
.
close
();
inputStreamReader
.
close
();
inputStream
.
close
();
inputStream
=
null
;
conn
.
disconnect
();
return
buffer
.
toString
();
}
catch
(
ConnectException
ce
)
{
ce
.
printStackTrace
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
@RequestMapping
(
"self-check"
)
@ResponseBody
public
Object
self
(
String
ips
){
if
(
StringUtils
.
isEmpty
(
ips
))
{
ips
=
"121.36.247.198,60.204.155.186,123.60.35.52,124.70.140.207,121.37.130.214,122.9.64.47,116.63.51.145,122.9.68.94,122.9.190.110"
;
}
String
[]
arr
=
ips
.
split
(
","
)
;
Map
<
String
,
String
>
map
=
new
HashMap
<>()
;
for
(
String
ip
:
arr
)
{
String
s
=
httpRequest
(
"http://"
+
ip
+
":8990/api-qywx-self/index.html"
,
"GET"
,
null
,
3
)
;
map
.
put
(
"ip"
,
s
)
;
}
return
map
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment