Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
dj
/
rop-dj-script
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ddaae8d2
authored
Jun 05, 2026
by
谢海旭
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
查询省市优化
1 parent
ec71e6cc
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
src/main/java/cn/com/glsx/dj/script/controller/ApiRegionSearchController.java
src/main/java/cn/com/glsx/dj/script/controller/ApiRegionSearchController.java
View file @
ddaae8d
...
@@ -9,10 +9,15 @@ import io.swagger.annotations.Api;
...
@@ -9,10 +9,15 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
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.apache.http.util.EntityUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.env.Environment
;
import
org.springframework.web.client.RestTemplate
;
import
java.io.IOException
;
import
java.net.URLEncoder
;
import
java.net.URLEncoder
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
...
@@ -73,9 +78,16 @@ public class ApiRegionSearchController {
...
@@ -73,9 +78,16 @@ public class ApiRegionSearchController {
log
.
info
(
"regionSearch request url: {}"
,
finalUrl
);
log
.
info
(
"regionSearch request url: {}"
,
finalUrl
);
RestTemplate
restTemplate
=
new
RestTemplate
();
try
{
String
response
=
restTemplate
.
getForObject
(
finalUrl
,
String
.
class
);
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
return
RopResponse
.
success
(
response
);
HttpGet
httpGet
=
new
HttpGet
(
urlBuilder
.
toString
());
try
(
CloseableHttpResponse
response
=
httpClient
.
execute
(
httpGet
))
{
return
RopResponse
.
success
(
EntityUtils
.
toString
(
response
.
getEntity
()));
}
}
catch
(
IOException
e
)
{
log
.
error
(
"请求地址"
+
finalUrl
+
"出错"
,
e
);
return
RopResponse
.
error
(
"请求地址出错"
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"请求地址"
+
baseUrl
+
"出错"
,
e
);
log
.
error
(
"请求地址"
+
baseUrl
+
"出错"
,
e
);
return
RopResponse
.
error
(
"请求地址出错"
);
return
RopResponse
.
error
(
"请求地址出错"
);
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment