From f0aeb27566606860e61388f84120cd07c6e13c59 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Tue, 26 Aug 2025 14:17:26 +0800 Subject: [PATCH] =?UTF-8?q?refactor(scenic):=20=E9=87=8D=E6=9E=84=E6=99=AF?= =?UTF-8?q?=E5=8C=BA=E9=85=8D=E7=BD=AE=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 为 FeignClient 添加 contextId 属性,提高服务调用的可读性 - 更新 ScenicIntegrationService 中的接口调用方式 - 修改 ScenicConfigEntity 和 ScenicConfigResp 中的字段类型 -重构 ScenicRepository 中的配置解析逻辑,使用 ConfigValueUtil 工具类 --- .../common/util/ConfigValueUtil.java | 397 ++++++++++++++++++ .../scenic/client/DefaultConfigClient.java | 2 +- .../scenic/client/ScenicConfigV2Client.java | 2 +- .../client/ScenicConfigWithDefaultClient.java | 2 +- .../scenic/client/ScenicMetaClient.java | 2 +- .../scenic/client/ScenicV2Client.java | 2 +- .../service/ScenicIntegrationService.java | 4 +- .../pc/scenic/entity/ScenicConfigEntity.java | 6 +- .../pc/scenic/resp/ScenicConfigResp.java | 10 +- .../basic/repository/ScenicRepository.java | 134 ++---- 10 files changed, 448 insertions(+), 113 deletions(-) create mode 100644 src/main/java/com/ycwl/basic/integration/common/util/ConfigValueUtil.java diff --git a/src/main/java/com/ycwl/basic/integration/common/util/ConfigValueUtil.java b/src/main/java/com/ycwl/basic/integration/common/util/ConfigValueUtil.java new file mode 100644 index 0000000..a38797b --- /dev/null +++ b/src/main/java/com/ycwl/basic/integration/common/util/ConfigValueUtil.java @@ -0,0 +1,397 @@ +package com.ycwl.basic.integration.common.util; + +import com.ycwl.basic.utils.JacksonUtil; +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + +/** + * 配置值转换工具类 + * + * 提供统一的配置Map值类型转换方法,支持多种数据类型的安全转换 + */ +public class ConfigValueUtil { + + /** + * 从配置Map中获取Integer值 + * + * @param config 配置Map + * @param key 配置键 + * @return Integer值,如果转换失败返回null + */ + public static Integer getIntValue(Map config, String key) { + Object value = config.get(key); + if (value == null) return null; + if (value instanceof Integer) return (Integer) value; + if (value instanceof Number) return ((Number) value).intValue(); + if (value instanceof String) { + try { + return Integer.parseInt((String) value); + } catch (NumberFormatException e) { + return null; + } + } + return null; + } + + /** + * 从配置Map中获取Long值 + * + * @param config 配置Map + * @param key 配置键 + * @return Long值,如果转换失败返回null + */ + public static Long getLongValue(Map config, String key) { + Object value = config.get(key); + if (value == null) return null; + if (value instanceof Long) return (Long) value; + if (value instanceof Number) return ((Number) value).longValue(); + if (value instanceof String) { + try { + return Long.parseLong((String) value); + } catch (NumberFormatException e) { + return null; + } + } + return null; + } + + /** + * 从配置Map中获取Float值 + * + * @param config 配置Map + * @param key 配置键 + * @return Float值,如果转换失败返回null + */ + public static Float getFloatValue(Map config, String key) { + Object value = config.get(key); + if (value == null) return null; + if (value instanceof Float) return (Float) value; + if (value instanceof Double) return ((Double) value).floatValue(); + if (value instanceof Number) return ((Number) value).floatValue(); + if (value instanceof String) { + try { + return Float.parseFloat((String) value); + } catch (NumberFormatException e) { + return null; + } + } + return null; + } + + /** + * 从配置Map中获取Double值 + * + * @param config 配置Map + * @param key 配置键 + * @return Double值,如果转换失败返回null + */ + public static Double getDoubleValue(Map config, String key) { + Object value = config.get(key); + if (value == null) return null; + if (value instanceof Double) return (Double) value; + if (value instanceof Number) return ((Number) value).doubleValue(); + if (value instanceof String) { + try { + return Double.parseDouble((String) value); + } catch (NumberFormatException e) { + return null; + } + } + return null; + } + + /** + * 从配置Map中获取BigDecimal值 + * + * @param config 配置Map + * @param key 配置键 + * @return BigDecimal值,如果转换失败返回null + */ + public static BigDecimal getBigDecimalValue(Map config, String key) { + Object value = config.get(key); + if (value == null) return null; + if (value instanceof BigDecimal) return (BigDecimal) value; + if (value instanceof String) { + try { + return new BigDecimal((String) value); + } catch (NumberFormatException e) { + return null; + } + } + if (value instanceof Number) { + return new BigDecimal(value.toString()); + } + return null; + } + + /** + * 从配置Map中获取String值 + * 如果值是复杂对象(Map/List),会自动转换为JSON字符串 + * + * @param config 配置Map + * @param key 配置键 + * @return String值,如果value为null返回null + */ + public static String getStringValue(Map config, String key) { + Object value = config.get(key); + if (value == null) return null; + + // 如果是基础类型,直接转字符串 + if (value instanceof String || value instanceof Number || value instanceof Boolean) { + return value.toString(); + } + + // 如果是复杂对象(Map, List等),转换为JSON字符串 + try { + return JacksonUtil.toJSONString(value); + } catch (Exception e) { + // JSON转换失败,降级为toString + return value.toString(); + } + } + + /** + * 从配置Map中获取Boolean值 + * + * @param config 配置Map + * @param key 配置键 + * @return Boolean值,如果转换失败返回null + */ + public static Boolean getBooleanValue(Map config, String key) { + Object value = config.get(key); + if (value == null) return null; + if (value instanceof Boolean) return (Boolean) value; + if (value instanceof String) { + String str = (String) value; + if ("true".equalsIgnoreCase(str) || "1".equals(str)) return true; + if ("false".equalsIgnoreCase(str) || "0".equals(str)) return false; + } + if (value instanceof Number) { + return ((Number) value).intValue() != 0; + } + return null; + } + + /** + * 从配置Map中获取枚举值 + * + * @param config 配置Map + * @param key 配置键 + * @param enumClass 枚举类型 + * @param 枚举类型泛型 + * @return 枚举值,如果转换失败返回null + */ + public static > T getEnumValue(Map config, String key, Class enumClass) { + Object value = config.get(key); + if (value == null) return null; + try { + if (value instanceof String) { + return Enum.valueOf(enumClass, (String) value); + } + return Enum.valueOf(enumClass, value.toString()); + } catch (IllegalArgumentException e) { + return null; + } + } + + /** + * 从配置Map中获取Integer值,如果为null则返回默认值 + * + * @param config 配置Map + * @param key 配置键 + * @param defaultValue 默认值 + * @return Integer值或默认值 + */ + public static Integer getIntValue(Map config, String key, Integer defaultValue) { + Integer value = getIntValue(config, key); + return value != null ? value : defaultValue; + } + + /** + * 从配置Map中获取String值,如果为null则返回默认值 + * + * @param config 配置Map + * @param key 配置键 + * @param defaultValue 默认值 + * @return String值或默认值 + */ + public static String getStringValue(Map config, String key, String defaultValue) { + String value = getStringValue(config, key); + return value != null ? value : defaultValue; + } + + /** + * 从配置Map中获取Boolean值,如果为null则返回默认值 + * + * @param config 配置Map + * @param key 配置键 + * @param defaultValue 默认值 + * @return Boolean值或默认值 + */ + public static Boolean getBooleanValue(Map config, String key, Boolean defaultValue) { + Boolean value = getBooleanValue(config, key); + return value != null ? value : defaultValue; + } + + // ========== 对象和JSON转换方法 ========== + + /** + * 从配置Map中获取原始对象值 + * + * @param config 配置Map + * @param key 配置键 + * @return 原始Object值 + */ + public static Object getObjectValue(Map config, String key) { + return config.get(key); + } + + /** + * 从配置Map中获取并转换为指定类型的对象 + * 支持JSON字符串自动反序列化 + * + * @param config 配置Map + * @param key 配置键 + * @param clazz 目标类型 + * @param 目标类型泛型 + * @return 转换后的对象,如果转换失败返回null + */ + @SuppressWarnings("unchecked") + public static T getObjectValue(Map config, String key, Class clazz) { + Object value = config.get(key); + if (value == null) return null; + + // 如果类型匹配,直接返回 + if (clazz.isInstance(value)) { + return (T) value; + } + + // 如果是String类型的JSON,尝试反序列化 + if (value instanceof String && !clazz.equals(String.class)) { + try { + return JacksonUtil.parseObject((String) value, clazz); + } catch (Exception e) { + return null; + } + } + + // 如果目标是String,使用增强的字符串转换 + if (clazz.equals(String.class)) { + return (T) getStringValue(config, key); + } + + // 其他情况尝试JSON转换 + try { + String json = JacksonUtil.toJSONString(value); + return JacksonUtil.parseObject(json, clazz); + } catch (Exception e) { + return null; + } + } + + /** + * 从配置Map中获取Map类型的值 + * + * @param config 配置Map + * @param key 配置键 + * @return Map值,如果转换失败返回null + */ + @SuppressWarnings("unchecked") + public static Map getMapValue(Map config, String key) { + Object value = config.get(key); + if (value == null) return null; + + if (value instanceof Map) { + return (Map) value; + } + + if (value instanceof String) { + try { + return JacksonUtil.parseObject((String) value, Map.class); + } catch (Exception e) { + return null; + } + } + + return null; + } + + /** + * 从配置Map中获取List类型的值 + * + * @param config 配置Map + * @param key 配置键 + * @return List值,如果转换失败返回null + */ + @SuppressWarnings("unchecked") + public static List getListValue(Map config, String key) { + Object value = config.get(key); + if (value == null) return null; + + if (value instanceof List) { + return (List) value; + } + + if (value instanceof String) { + try { + return JacksonUtil.parseObject((String) value, List.class); + } catch (Exception e) { + return null; + } + } + + return null; + } + + /** + * 从配置Map中获取指定元素类型的List值 + * + * @param config 配置Map + * @param key 配置键 + * @param elementClass List元素类型 + * @param List元素类型泛型 + * @return 指定类型的List,如果转换失败返回null + */ + public static List getListValue(Map config, String key, Class elementClass) { + Object value = config.get(key); + if (value == null) return null; + + if (value instanceof String) { + try { + return JacksonUtil.parseArray((String) value, elementClass); + } catch (Exception e) { + return null; + } + } + + try { + String json = JacksonUtil.toJSONString(value); + return JacksonUtil.parseArray(json, elementClass); + } catch (Exception e) { + return null; + } + } + + /** + * 检查配置键是否存在 + * + * @param config 配置Map + * @param key 配置键 + * @return true如果键存在,false如果不存在 + */ + public static boolean hasKey(Map config, String key) { + return config != null && config.containsKey(key); + } + + /** + * 检查配置键是否存在且值不为null + * + * @param config 配置Map + * @param key 配置键 + * @return true如果键存在且值不为null + */ + public static boolean hasNonNullValue(Map config, String key) { + return config != null && config.containsKey(key) && config.get(key) != null; + } +} \ No newline at end of file diff --git a/src/main/java/com/ycwl/basic/integration/scenic/client/DefaultConfigClient.java b/src/main/java/com/ycwl/basic/integration/scenic/client/DefaultConfigClient.java index c2f7bca..7c8e99e 100644 --- a/src/main/java/com/ycwl/basic/integration/scenic/client/DefaultConfigClient.java +++ b/src/main/java/com/ycwl/basic/integration/scenic/client/DefaultConfigClient.java @@ -7,7 +7,7 @@ import org.springframework.web.bind.annotation.*; import java.util.List; -@FeignClient(name = "zt-scenic", path = "/api/scenic/default-config") +@FeignClient(name = "zt-scenic", contextId = "scenic-default-config", path = "/api/scenic/default-config") public interface DefaultConfigClient { @GetMapping("/") diff --git a/src/main/java/com/ycwl/basic/integration/scenic/client/ScenicConfigV2Client.java b/src/main/java/com/ycwl/basic/integration/scenic/client/ScenicConfigV2Client.java index 3016812..31c1709 100644 --- a/src/main/java/com/ycwl/basic/integration/scenic/client/ScenicConfigV2Client.java +++ b/src/main/java/com/ycwl/basic/integration/scenic/client/ScenicConfigV2Client.java @@ -8,7 +8,7 @@ import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Map; -@FeignClient(name = "zt-scenic", path = "/api/scenic/config/v2") +@FeignClient(name = "zt-scenic", contextId = "scenic-config-v2", path = "/api/scenic/config/v2") public interface ScenicConfigV2Client { @GetMapping("/{scenicId}") diff --git a/src/main/java/com/ycwl/basic/integration/scenic/client/ScenicConfigWithDefaultClient.java b/src/main/java/com/ycwl/basic/integration/scenic/client/ScenicConfigWithDefaultClient.java index 38c8005..cd235d2 100644 --- a/src/main/java/com/ycwl/basic/integration/scenic/client/ScenicConfigWithDefaultClient.java +++ b/src/main/java/com/ycwl/basic/integration/scenic/client/ScenicConfigWithDefaultClient.java @@ -6,7 +6,7 @@ import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; -@FeignClient(name = "zt-scenic", path = "/api/scenic/config-with-default") +@FeignClient(name = "zt-scenic", contextId = "scenic-config-with-default", path = "/api/scenic/config-with-default") public interface ScenicConfigWithDefaultClient { @GetMapping("/{scenicId}/{configKey}") diff --git a/src/main/java/com/ycwl/basic/integration/scenic/client/ScenicMetaClient.java b/src/main/java/com/ycwl/basic/integration/scenic/client/ScenicMetaClient.java index df28f20..580f7e5 100644 --- a/src/main/java/com/ycwl/basic/integration/scenic/client/ScenicMetaClient.java +++ b/src/main/java/com/ycwl/basic/integration/scenic/client/ScenicMetaClient.java @@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Map; -@FeignClient(name = "zt-scenic", path = "/api/scenic/meta") +@FeignClient(name = "zt-scenic", contextId = "scenic-meta", path = "/api/scenic/meta") public interface ScenicMetaClient { @GetMapping("/{scenicId}/fields/enabled") diff --git a/src/main/java/com/ycwl/basic/integration/scenic/client/ScenicV2Client.java b/src/main/java/com/ycwl/basic/integration/scenic/client/ScenicV2Client.java index 2d56ae0..be88cee 100644 --- a/src/main/java/com/ycwl/basic/integration/scenic/client/ScenicV2Client.java +++ b/src/main/java/com/ycwl/basic/integration/scenic/client/ScenicV2Client.java @@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.*; import java.util.Map; -@FeignClient(name = "zt-scenic", path = "/api/scenic/v2") +@FeignClient(name = "zt-scenic", contextId = "scenic-v2", path = "/api/scenic/v2") public interface ScenicV2Client { @GetMapping("/{scenicId}") diff --git a/src/main/java/com/ycwl/basic/integration/scenic/service/ScenicIntegrationService.java b/src/main/java/com/ycwl/basic/integration/scenic/service/ScenicIntegrationService.java index 6c25b77..ec3e8ea 100644 --- a/src/main/java/com/ycwl/basic/integration/scenic/service/ScenicIntegrationService.java +++ b/src/main/java/com/ycwl/basic/integration/scenic/service/ScenicIntegrationService.java @@ -2,6 +2,7 @@ package com.ycwl.basic.integration.scenic.service; import com.ycwl.basic.integration.common.exception.IntegrationException; import com.ycwl.basic.integration.common.response.CommonResponse; +import com.ycwl.basic.integration.scenic.client.ScenicConfigV2Client; import com.ycwl.basic.integration.scenic.client.ScenicV2Client; import com.ycwl.basic.integration.scenic.dto.filter.ScenicFilterPageResponse; import com.ycwl.basic.integration.scenic.dto.filter.ScenicFilterRequest; @@ -21,6 +22,7 @@ import java.util.Map; public class ScenicIntegrationService { private final ScenicV2Client scenicV2Client; + private final ScenicConfigV2Client scenicConfigV2Client; public ScenicV2DTO getScenic(Long scenicId) { log.info("获取景区信息, scenicId: {}", scenicId); @@ -36,7 +38,7 @@ public class ScenicIntegrationService { public Map getScenicFlatConfig(Long scenicId) { log.info("获取景区扁平化配置, scenicId: {}", scenicId); - CommonResponse> response = scenicV2Client.getScenicFlatConfig(scenicId); + CommonResponse> response = scenicConfigV2Client.getFlatConfigs(scenicId); return handleResponse(response, "获取景区扁平化配置失败"); } diff --git a/src/main/java/com/ycwl/basic/model/pc/scenic/entity/ScenicConfigEntity.java b/src/main/java/com/ycwl/basic/model/pc/scenic/entity/ScenicConfigEntity.java index 3a502f4..c611b5a 100644 --- a/src/main/java/com/ycwl/basic/model/pc/scenic/entity/ScenicConfigEntity.java +++ b/src/main/java/com/ycwl/basic/model/pc/scenic/entity/ScenicConfigEntity.java @@ -72,12 +72,12 @@ public class ScenicConfigEntity { * 是否禁用源视频 * 0-否 1-是 */ - private Integer disableSourceVideo; + private Boolean disableSourceVideo; /** * 是否禁用源图片 * 0-否 1-是 */ - private Integer disableSourceImage; + private Boolean disableSourceImage; private Integer templateNewVideoType; /** * 是否开启防录屏 @@ -130,5 +130,5 @@ public class ScenicConfigEntity { * 是否启用券码功能 * 0-禁用 1-启用 */ - private Integer voucherEnable; + private Boolean voucherEnable; } diff --git a/src/main/java/com/ycwl/basic/model/pc/scenic/resp/ScenicConfigResp.java b/src/main/java/com/ycwl/basic/model/pc/scenic/resp/ScenicConfigResp.java index c0743f6..1903f73 100644 --- a/src/main/java/com/ycwl/basic/model/pc/scenic/resp/ScenicConfigResp.java +++ b/src/main/java/com/ycwl/basic/model/pc/scenic/resp/ScenicConfigResp.java @@ -35,8 +35,8 @@ public class ScenicConfigResp { */ private Integer videoStoreDay; private Integer allFree; - private Integer disableSourceVideo; - private Integer disableSourceImage; + private Boolean disableSourceVideo; + private Boolean disableSourceImage; private Integer antiScreenRecordType; private Integer videoSourceStoreDay; private Integer imageSourceStoreDay; @@ -45,9 +45,5 @@ public class ScenicConfigResp { private String imageSourcePackHint = ""; private String videoSourcePackHint = ""; - /** - * 是否启用券码功能 - * 0-禁用 1-启用 - */ - private Integer voucherEnable; + private Boolean voucherEnable; } diff --git a/src/main/java/com/ycwl/basic/repository/ScenicRepository.java b/src/main/java/com/ycwl/basic/repository/ScenicRepository.java index 58306be..764274d 100644 --- a/src/main/java/com/ycwl/basic/repository/ScenicRepository.java +++ b/src/main/java/com/ycwl/basic/repository/ScenicRepository.java @@ -12,6 +12,7 @@ import com.ycwl.basic.model.pc.scenic.entity.ScenicEntity; import com.ycwl.basic.integration.scenic.service.ScenicIntegrationService; import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2DTO; import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2WithConfigDTO; +import com.ycwl.basic.integration.common.util.ConfigValueUtil; import com.ycwl.basic.facebody.enums.FaceBodyAdapterType; import com.ycwl.basic.pay.enums.PayAdapterType; import com.ycwl.basic.storage.enums.StorageType; @@ -157,110 +158,49 @@ public class ScenicRepository { java.util.Map config = dto.getConfig(); - entity.setBookRoutine(getIntValue(config, "book_routine")); - entity.setForceFinishTime(getIntValue(config, "force_finish_time")); - entity.setTourTime(getIntValue(config, "tour_time")); - entity.setSampleStoreDay(getIntValue(config, "sample_store_day")); - entity.setFaceStoreDay(getIntValue(config, "face_store_day")); - entity.setVideoStoreDay(getIntValue(config, "video_store_day")); - entity.setAllFree(getIntValue(config, "all_free")); - entity.setDisableSourceVideo(getIntValue(config, "disable_source_video")); - entity.setDisableSourceImage(getIntValue(config, "disable_source_image")); - entity.setTemplateNewVideoType(getIntValue(config, "template_new_video_type")); - entity.setAntiScreenRecordType(getIntValue(config, "anti_screen_record_type")); - entity.setVideoSourceStoreDay(getIntValue(config, "video_source_store_day")); - entity.setImageSourceStoreDay(getIntValue(config, "image_source_store_day")); - entity.setUserSourceExpireDay(getIntValue(config, "user_source_expire_day")); - entity.setFaceDetectHelperThreshold(getIntValue(config, "face_detect_helper_threshold")); - entity.setPhotoFreeNum(getIntValue(config, "photo_free_num")); - entity.setVideoFreeNum(getIntValue(config, "video_free_num")); - entity.setVoucherEnable(getIntValue(config, "voucher_enable")); + entity.setBookRoutine(ConfigValueUtil.getIntValue(config, "bookRoutine")); + entity.setForceFinishTime(ConfigValueUtil.getIntValue(config, "forceFinishTime")); + entity.setTourTime(ConfigValueUtil.getIntValue(config, "tourTime")); + entity.setSampleStoreDay(ConfigValueUtil.getIntValue(config, "sampleStoreDay")); + entity.setFaceStoreDay(ConfigValueUtil.getIntValue(config, "faceStoreDay")); + entity.setVideoStoreDay(ConfigValueUtil.getIntValue(config, "videoStoreDay")); + entity.setAllFree(ConfigValueUtil.getIntValue(config, "allFree")); + entity.setDisableSourceVideo(ConfigValueUtil.getBooleanValue(config, "disableSourceVideo")); + entity.setDisableSourceImage(ConfigValueUtil.getBooleanValue(config, "disableSourceImage")); + entity.setTemplateNewVideoType(ConfigValueUtil.getIntValue(config, "templateNewVideoType")); + entity.setAntiScreenRecordType(ConfigValueUtil.getIntValue(config, "antiScreenRecordType")); + entity.setVideoSourceStoreDay(ConfigValueUtil.getIntValue(config, "videoSourceStoreDay")); + entity.setImageSourceStoreDay(ConfigValueUtil.getIntValue(config, "imageSourceStoreDay")); + entity.setUserSourceExpireDay(ConfigValueUtil.getIntValue(config, "userSourceExpireDay")); + entity.setFaceDetectHelperThreshold(ConfigValueUtil.getIntValue(config, "faceDetectHelperThreshold")); + entity.setPhotoFreeNum(ConfigValueUtil.getIntValue(config, "photoFreeNum")); + entity.setVideoFreeNum(ConfigValueUtil.getIntValue(config, "videoFreeNum")); + entity.setVoucherEnable(ConfigValueUtil.getBooleanValue(config, "voucherEnable")); - entity.setFaceScoreThreshold(getFloatValue(config, "face_score_threshold")); - entity.setBrokerDirectRate(getBigDecimalValue(config, "broker_direct_rate")); + entity.setFaceScoreThreshold(ConfigValueUtil.getFloatValue(config, "faceScoreThreshold")); + entity.setBrokerDirectRate(ConfigValueUtil.getBigDecimalValue(config, "brokerDirectRate")); - entity.setWatermarkType(getStringValue(config, "watermark_type")); - entity.setWatermarkScenicText(getStringValue(config, "watermark_scenic_text")); - entity.setWatermarkDtFormat(getStringValue(config, "watermark_dt_format")); - entity.setImageSourcePackHint(getStringValue(config, "image_source_pack_hint")); - entity.setVideoSourcePackHint(getStringValue(config, "video_source_pack_hint")); - entity.setExtraNotificationTime(getStringValue(config, "extra_notification_time")); + entity.setWatermarkType(ConfigValueUtil.getStringValue(config, "watermarkType")); + entity.setWatermarkScenicText(ConfigValueUtil.getStringValue(config, "watermarkScenicText")); + entity.setWatermarkDtFormat(ConfigValueUtil.getStringValue(config, "watermarkDtFormat")); + entity.setImageSourcePackHint(ConfigValueUtil.getStringValue(config, "imageSourcePackHint")); + entity.setVideoSourcePackHint(ConfigValueUtil.getStringValue(config, "videoSourcePackHint")); + entity.setExtraNotificationTime(ConfigValueUtil.getStringValue(config, "extraNotificationTime")); - entity.setStoreType(getEnumValue(config, "store_type", StorageType.class)); - entity.setStoreConfigJson(getStringValue(config, "store_config_json")); - entity.setTmpStoreType(getEnumValue(config, "tmp_store_type", StorageType.class)); - entity.setTmpStoreConfigJson(getStringValue(config, "tmp_store_config_json")); - entity.setLocalStoreType(getEnumValue(config, "local_store_type", StorageType.class)); - entity.setLocalStoreConfigJson(getStringValue(config, "local_store_config_json")); + entity.setStoreType(ConfigValueUtil.getEnumValue(config, "storeType", StorageType.class)); + entity.setStoreConfigJson(ConfigValueUtil.getStringValue(config, "storeConfigJson")); + entity.setTmpStoreType(ConfigValueUtil.getEnumValue(config, "tmpStoreType", StorageType.class)); + entity.setTmpStoreConfigJson(ConfigValueUtil.getStringValue(config, "tmpStoreConfigJson")); + entity.setLocalStoreType(ConfigValueUtil.getEnumValue(config, "localStoreType", StorageType.class)); + entity.setLocalStoreConfigJson(ConfigValueUtil.getStringValue(config, "localStoreConfigJson")); - entity.setFaceType(getEnumValue(config, "face_type", FaceBodyAdapterType.class)); - entity.setFaceConfigJson(getStringValue(config, "face_config_json")); + entity.setFaceType(ConfigValueUtil.getEnumValue(config, "faceType", FaceBodyAdapterType.class)); + entity.setFaceConfigJson(ConfigValueUtil.getStringValue(config, "faceConfigJson")); - entity.setPayType(getEnumValue(config, "pay_type", PayAdapterType.class)); - entity.setPayConfigJson(getStringValue(config, "pay_config_json")); + entity.setPayType(ConfigValueUtil.getEnumValue(config, "payType", PayAdapterType.class)); + entity.setPayConfigJson(ConfigValueUtil.getStringValue(config, "payConfigJson")); return entity; } - - private Integer getIntValue(java.util.Map config, String key) { - Object value = config.get(key); - if (value == null) return null; - if (value instanceof Integer) return (Integer) value; - if (value instanceof String) { - try { - return Integer.parseInt((String) value); - } catch (NumberFormatException e) { - return null; - } - } - return null; - } - - private Float getFloatValue(java.util.Map config, String key) { - Object value = config.get(key); - if (value == null) return null; - if (value instanceof Float) return (Float) value; - if (value instanceof Double) return ((Double) value).floatValue(); - if (value instanceof String) { - try { - return Float.parseFloat((String) value); - } catch (NumberFormatException e) { - return null; - } - } - return null; - } - - private java.math.BigDecimal getBigDecimalValue(java.util.Map config, String key) { - Object value = config.get(key); - if (value == null) return null; - if (value instanceof java.math.BigDecimal) return (java.math.BigDecimal) value; - if (value instanceof String) { - try { - return new java.math.BigDecimal((String) value); - } catch (NumberFormatException e) { - return null; - } - } - if (value instanceof Number) { - return new java.math.BigDecimal(value.toString()); - } - return null; - } - - private String getStringValue(java.util.Map config, String key) { - Object value = config.get(key); - return value != null ? value.toString() : null; - } - - private > T getEnumValue(java.util.Map config, String key, Class enumClass) { - Object value = config.get(key); - if (value == null) return null; - try { - return Enum.valueOf(enumClass, value.toString()); - } catch (IllegalArgumentException e) { - return null; - } - } }