File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
continew-starter-core/src/main/java/top/continew/starter/core Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -254,6 +254,11 @@ public class StringConstants {
254254 */
255255 public static final String QUESTION_MARK = "?" ;
256256
257+ /**
258+ * 管道符
259+ */
260+ public static final String PIPE = "|" ;
261+
257262 /**
258263 * 中文逗号
259264 */
Original file line number Diff line number Diff line change 1818
1919import cn .hutool .core .collection .CollUtil ;
2020import cn .hutool .core .net .NetUtil ;
21- import cn .hutool .core .text .CharSequenceUtil ;
2221import cn .hutool .extra .spring .SpringUtil ;
2322import cn .hutool .http .HtmlUtil ;
2423import net .dreamlu .mica .ip2region .core .Ip2regionSearcher ;
2524import net .dreamlu .mica .ip2region .core .IpInfo ;
2625import top .continew .starter .core .constant .StringConstants ;
2726
27+ import java .util .Objects ;
2828import java .util .Set ;
2929
3030/**
@@ -50,12 +50,13 @@ public static String getIpv4Address(String ip) {
5050 }
5151 Ip2regionSearcher ip2regionSearcher = SpringUtil .getBean (Ip2regionSearcher .class );
5252 IpInfo ipInfo = ip2regionSearcher .memorySearch (ip );
53- if (null != ipInfo ) {
54- Set <String > regionSet = CollUtil .newLinkedHashSet (ipInfo .getAddress (), ipInfo .getIsp ());
55- regionSet .removeIf (CharSequenceUtil ::isBlank );
56- return String .join (StringConstants .SPACE , regionSet );
53+ if (null == ipInfo ) {
54+ return null ;
5755 }
58- return null ;
56+ Set <String > regionSet = CollUtil .newLinkedHashSet (ipInfo .getCountry (), ipInfo .getRegion (), ipInfo
57+ .getProvince (), ipInfo .getCity (), ipInfo .getIsp ());
58+ regionSet .removeIf (Objects ::isNull );
59+ return String .join (StringConstants .PIPE , regionSet );
5960 }
6061
6162 /**
You can’t perform that action at this time.
0 commit comments