Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sts网站
Project
Project
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
liyang
sts网站
Commits
46a16952
Commit
46a16952
authored
Feb 23, 2020
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复地址开关无效问题
parent
b7107a4d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
9 deletions
+13
-9
AddressUtils.java
...src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java
+13
-9
No files found.
ruoyi/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java
View file @
46a16952
...
@@ -5,6 +5,7 @@ import org.slf4j.LoggerFactory;
...
@@ -5,6 +5,7 @@ import org.slf4j.LoggerFactory;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.http.HttpUtils
;
import
com.ruoyi.common.utils.http.HttpUtils
;
import
com.ruoyi.framework.config.RuoYiConfig
;
/**
/**
* 获取地址类
* 获取地址类
...
@@ -25,17 +26,20 @@ public class AddressUtils
...
@@ -25,17 +26,20 @@ public class AddressUtils
{
{
return
"内网IP"
;
return
"内网IP"
;
}
}
String
rspStr
=
HttpUtils
.
sendPost
(
IP_URL
,
"ip="
+
ip
);
if
(
RuoYiConfig
.
isAddressEnabled
())
if
(
StringUtils
.
isEmpty
(
rspStr
))
{
{
log
.
error
(
"获取地理位置异常 {}"
,
ip
);
String
rspStr
=
HttpUtils
.
sendPost
(
IP_URL
,
"ip="
+
ip
);
return
address
;
if
(
StringUtils
.
isEmpty
(
rspStr
))
{
log
.
error
(
"获取地理位置异常 {}"
,
ip
);
return
address
;
}
JSONObject
obj
=
JSONObject
.
parseObject
(
rspStr
);
JSONObject
data
=
obj
.
getObject
(
"data"
,
JSONObject
.
class
);
String
region
=
data
.
getString
(
"region"
);
String
city
=
data
.
getString
(
"city"
);
address
=
region
+
" "
+
city
;
}
}
JSONObject
obj
=
JSONObject
.
parseObject
(
rspStr
);
JSONObject
data
=
obj
.
getObject
(
"data"
,
JSONObject
.
class
);
String
region
=
data
.
getString
(
"region"
);
String
city
=
data
.
getString
(
"city"
);
address
=
region
+
" "
+
city
;
return
address
;
return
address
;
}
}
}
}
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