在IpUtils里修复ip空字符串引起的异常问题pull/30/head
parent
e618f8e404
commit
cdc52f32ea
|
@ -51,7 +51,7 @@ public class IPUtils {
|
||||||
*/
|
*/
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public static Integer getAreaId(String ip) {
|
public static Integer getAreaId(String ip) {
|
||||||
return Integer.parseInt(SEARCHER.search(ip));
|
return Integer.parseInt(SEARCHER.search(ip.trim()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class AreaController {
|
||||||
@Parameter(name = "ip", description = "IP", required = true)
|
@Parameter(name = "ip", description = "IP", required = true)
|
||||||
public CommonResult<String> getAreaByIp(@RequestParam("ip") String ip) {
|
public CommonResult<String> getAreaByIp(@RequestParam("ip") String ip) {
|
||||||
// 获得城市
|
// 获得城市
|
||||||
Area area = IPUtils.getArea(ip.trim());
|
Area area = IPUtils.getArea(ip);
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return success("未知");
|
return success("未知");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue