提交 cdc52f32 authored 作者: Chasel's avatar Chasel

https://gitee.com/zhijiantianya/yudao-cloud/issues/I6KP0U

在IpUtils里修复ip空字符串引起的异常问题
上级 e618f8e4
...@@ -51,7 +51,7 @@ public class IPUtils { ...@@ -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 { ...@@ -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("未知");
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论