优化maxmind

pull/80/head
awenes 2024-02-04 20:56:02 +08:00
parent 56a9a7daee
commit a46786fe88
1 changed files with 3 additions and 4 deletions

View File

@ -34,7 +34,6 @@ import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.client.ResourceAccessException; import org.springframework.web.client.ResourceAccessException;
@ -133,9 +132,9 @@ public class MaxmindGeoLocationServiceImpl implements GeoLocationService {
.countryName(country.getName()) .countryName(country.getName())
.countryCode(country.getGeoNameId().toString()) .countryCode(country.getGeoNameId().toString())
.cityName(city.getName()) .cityName(city.getName())
.cityCode(StringUtils.defaultString(CITY_DISTRICT.get(city.getName()), String.valueOf(city.getGeoNameId()))) .cityCode(Objects.toString(CITY_DISTRICT.get(city.getName()), String.valueOf(city.getGeoNameId())))
.provinceName(subdivision.getName()) .provinceName(subdivision.getName())
.provinceCode(StringUtils.defaultString(PROVINCE_DISTRICT.get(subdivision.getName()), subdivision.getIsoCode())) .provinceCode(Objects.toString(PROVINCE_DISTRICT.get(subdivision.getName()), subdivision.getIsoCode()))
.longitude(location.getLongitude()) .longitude(location.getLongitude())
.latitude(location.getLatitude()) .latitude(location.getLatitude())
.provider(MAXMIND).build(); .provider(MAXMIND).build();
@ -234,7 +233,7 @@ public class MaxmindGeoLocationServiceImpl implements GeoLocationService {
File extractFolder = new File(extractPath); File extractFolder = new File(extractPath);
TarArchiveEntry entry; TarArchiveEntry entry;
// 将 tar 文件解压到 extractPath 目录下 // 将 tar 文件解压到 extractPath 目录下
while ((entry = fin.getNextTarEntry()) != null) { while ((entry = fin.getNextEntry()) != null) {
if (entry.isDirectory()) { if (entry.isDirectory()) {
continue; continue;
} }