From 9d2cd04d4e0595414ac5958952a96e402a346485 Mon Sep 17 00:00:00 2001 From: awenes <1121353141@qq.com> Date: Thu, 4 Apr 2024 21:36:49 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E6=96=B0=E5=A2=9E=E9=BB=98?= =?UTF-8?q?=E8=AE=A4IP=E5=9C=B0=E7=90=86=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../setting/GeoLocationSettingConverter.java | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/eiam-console/src/main/java/cn/topiam/employee/console/converter/setting/GeoLocationSettingConverter.java b/eiam-console/src/main/java/cn/topiam/employee/console/converter/setting/GeoLocationSettingConverter.java index 5d7c7901..c6d0a9b0 100644 --- a/eiam-console/src/main/java/cn/topiam/employee/console/converter/setting/GeoLocationSettingConverter.java +++ b/eiam-console/src/main/java/cn/topiam/employee/console/converter/setting/GeoLocationSettingConverter.java @@ -19,6 +19,7 @@ package cn.topiam.employee.console.converter.setting; import java.util.Objects; +import org.apache.commons.lang3.StringUtils; import org.mapstruct.Mapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -115,27 +116,27 @@ public interface GeoLocationSettingConverter { */ default GeoIpProviderResult entityToGeoLocationProviderConfig(SettingEntity entity) { //没有数据,默认未启用 - if (Objects.isNull(entity)) { + if (Objects.isNull(entity) || StringUtils.isBlank(entity.getValue())) { return null; } - try { - String value = entity.getValue(); - ObjectMapper objectMapper = EncryptionModule.deserializerDecrypt(); - // 指定序列化输入的类型 - objectMapper.activateDefaultTyping(objectMapper.getPolymorphicTypeValidator(), - ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY); - // 根据提供商序列化 - GeoLocationProviderConfig setting = objectMapper.readValue(value, GeoLocationProviderConfig.class); - if (MAXMIND.equals(setting.getProvider())) { - MaxmindProviderConfig config = (MaxmindProviderConfig) setting.getConfig(); - //@formatter:off - return GeoIpProviderResult.builder() - .provider(setting.getProvider().getProvider()) - .config(config) - .enabled(true) - .build(); - } - //@formatter:on + try { + String value = entity.getValue(); + ObjectMapper objectMapper = EncryptionModule.deserializerDecrypt(); + // 指定序列化输入的类型 + objectMapper.activateDefaultTyping(objectMapper.getPolymorphicTypeValidator(), + ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY); + // 根据提供商序列化 + GeoLocationProviderConfig setting = objectMapper.readValue(value, GeoLocationProviderConfig.class); + if (MAXMIND.equals(setting.getProvider())) { + MaxmindProviderConfig config = (MaxmindProviderConfig) setting.getConfig(); + //@formatter:off + return GeoIpProviderResult.builder() + .provider(setting.getProvider().getProvider()) + .config(config) + .enabled(true) + .build(); + } + //@formatter:on return null; } catch (JsonProcessingException e) { throw new RuntimeException(e);