| | |
| | |
|
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | | import com.alibaba.fastjson.JSONObject;
|
| | | import com.alibaba.fastjson2.JSON;
|
| | | import com.alibaba.fastjson2.JSONObject;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.common.utils.http.HttpUtils;
|
| | |
| | |
|
| | | public static String getRealAddressByIP(String ip)
|
| | | {
|
| | | String address = UNKNOWN;
|
| | | // 内网不查询
|
| | | if (IpUtils.internalIp(ip))
|
| | | {
|
| | |
| | | log.error("获取地理位置异常 {}", ip);
|
| | | return UNKNOWN;
|
| | | }
|
| | | JSONObject obj = JSONObject.parseObject(rspStr);
|
| | | JSONObject obj = JSON.parseObject(rspStr);
|
| | | String region = obj.getString("pro");
|
| | | String city = obj.getString("city");
|
| | | return String.format("%s %s", region, city);
|
| | |
| | | log.error("获取地理位置异常 {}", ip);
|
| | | }
|
| | | }
|
| | | return address;
|
| | | return UNKNOWN;
|
| | | }
|
| | | }
|