You've already forked FrameTour-BE
refactor(scenic): 重构景区配置相关代码
- 为 FeignClient 添加 contextId 属性,提高服务调用的可读性 - 更新 ScenicIntegrationService 中的接口调用方式 - 修改 ScenicConfigEntity 和 ScenicConfigResp 中的字段类型 -重构 ScenicRepository 中的配置解析逻辑,使用 ConfigValueUtil 工具类
This commit is contained in:
@@ -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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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 <T> 枚举类型泛型
|
||||||
|
* @return 枚举值,如果转换失败返回null
|
||||||
|
*/
|
||||||
|
public static <T extends Enum<T>> T getEnumValue(Map<String, Object> config, String key, Class<T> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> config, String key) {
|
||||||
|
return config.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从配置Map中获取并转换为指定类型的对象
|
||||||
|
* 支持JSON字符串自动反序列化
|
||||||
|
*
|
||||||
|
* @param config 配置Map
|
||||||
|
* @param key 配置键
|
||||||
|
* @param clazz 目标类型
|
||||||
|
* @param <T> 目标类型泛型
|
||||||
|
* @return 转换后的对象,如果转换失败返回null
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static <T> T getObjectValue(Map<String, Object> config, String key, Class<T> 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<String, Object> getMapValue(Map<String, Object> config, String key) {
|
||||||
|
Object value = config.get(key);
|
||||||
|
if (value == null) return null;
|
||||||
|
|
||||||
|
if (value instanceof Map) {
|
||||||
|
return (Map<String, Object>) 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<Object> getListValue(Map<String, Object> config, String key) {
|
||||||
|
Object value = config.get(key);
|
||||||
|
if (value == null) return null;
|
||||||
|
|
||||||
|
if (value instanceof List) {
|
||||||
|
return (List<Object>) 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 <T> List元素类型泛型
|
||||||
|
* @return 指定类型的List,如果转换失败返回null
|
||||||
|
*/
|
||||||
|
public static <T> List<T> getListValue(Map<String, Object> config, String key, Class<T> 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<String, Object> config, String key) {
|
||||||
|
return config != null && config.containsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查配置键是否存在且值不为null
|
||||||
|
*
|
||||||
|
* @param config 配置Map
|
||||||
|
* @param key 配置键
|
||||||
|
* @return true如果键存在且值不为null
|
||||||
|
*/
|
||||||
|
public static boolean hasNonNullValue(Map<String, Object> config, String key) {
|
||||||
|
return config != null && config.containsKey(key) && config.get(key) != null;
|
||||||
|
}
|
||||||
|
}
|
@@ -7,7 +7,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import java.util.List;
|
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 {
|
public interface DefaultConfigClient {
|
||||||
|
|
||||||
@GetMapping("/")
|
@GetMapping("/")
|
||||||
|
@@ -8,7 +8,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
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 {
|
public interface ScenicConfigV2Client {
|
||||||
|
|
||||||
@GetMapping("/{scenicId}")
|
@GetMapping("/{scenicId}")
|
||||||
|
@@ -6,7 +6,7 @@ import org.springframework.cloud.openfeign.FeignClient;
|
|||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
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 {
|
public interface ScenicConfigWithDefaultClient {
|
||||||
|
|
||||||
@GetMapping("/{scenicId}/{configKey}")
|
@GetMapping("/{scenicId}/{configKey}")
|
||||||
|
@@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
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 {
|
public interface ScenicMetaClient {
|
||||||
|
|
||||||
@GetMapping("/{scenicId}/fields/enabled")
|
@GetMapping("/{scenicId}/fields/enabled")
|
||||||
|
@@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import java.util.Map;
|
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 {
|
public interface ScenicV2Client {
|
||||||
|
|
||||||
@GetMapping("/{scenicId}")
|
@GetMapping("/{scenicId}")
|
||||||
|
@@ -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.exception.IntegrationException;
|
||||||
import com.ycwl.basic.integration.common.response.CommonResponse;
|
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.client.ScenicV2Client;
|
||||||
import com.ycwl.basic.integration.scenic.dto.filter.ScenicFilterPageResponse;
|
import com.ycwl.basic.integration.scenic.dto.filter.ScenicFilterPageResponse;
|
||||||
import com.ycwl.basic.integration.scenic.dto.filter.ScenicFilterRequest;
|
import com.ycwl.basic.integration.scenic.dto.filter.ScenicFilterRequest;
|
||||||
@@ -21,6 +22,7 @@ import java.util.Map;
|
|||||||
public class ScenicIntegrationService {
|
public class ScenicIntegrationService {
|
||||||
|
|
||||||
private final ScenicV2Client scenicV2Client;
|
private final ScenicV2Client scenicV2Client;
|
||||||
|
private final ScenicConfigV2Client scenicConfigV2Client;
|
||||||
|
|
||||||
public ScenicV2DTO getScenic(Long scenicId) {
|
public ScenicV2DTO getScenic(Long scenicId) {
|
||||||
log.info("获取景区信息, scenicId: {}", scenicId);
|
log.info("获取景区信息, scenicId: {}", scenicId);
|
||||||
@@ -36,7 +38,7 @@ public class ScenicIntegrationService {
|
|||||||
|
|
||||||
public Map<String, Object> getScenicFlatConfig(Long scenicId) {
|
public Map<String, Object> getScenicFlatConfig(Long scenicId) {
|
||||||
log.info("获取景区扁平化配置, scenicId: {}", scenicId);
|
log.info("获取景区扁平化配置, scenicId: {}", scenicId);
|
||||||
CommonResponse<Map<String, Object>> response = scenicV2Client.getScenicFlatConfig(scenicId);
|
CommonResponse<Map<String, Object>> response = scenicConfigV2Client.getFlatConfigs(scenicId);
|
||||||
return handleResponse(response, "获取景区扁平化配置失败");
|
return handleResponse(response, "获取景区扁平化配置失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -72,12 +72,12 @@ public class ScenicConfigEntity {
|
|||||||
* 是否禁用源视频
|
* 是否禁用源视频
|
||||||
* 0-否 1-是
|
* 0-否 1-是
|
||||||
*/
|
*/
|
||||||
private Integer disableSourceVideo;
|
private Boolean disableSourceVideo;
|
||||||
/**
|
/**
|
||||||
* 是否禁用源图片
|
* 是否禁用源图片
|
||||||
* 0-否 1-是
|
* 0-否 1-是
|
||||||
*/
|
*/
|
||||||
private Integer disableSourceImage;
|
private Boolean disableSourceImage;
|
||||||
private Integer templateNewVideoType;
|
private Integer templateNewVideoType;
|
||||||
/**
|
/**
|
||||||
* 是否开启防录屏
|
* 是否开启防录屏
|
||||||
@@ -130,5 +130,5 @@ public class ScenicConfigEntity {
|
|||||||
* 是否启用券码功能
|
* 是否启用券码功能
|
||||||
* 0-禁用 1-启用
|
* 0-禁用 1-启用
|
||||||
*/
|
*/
|
||||||
private Integer voucherEnable;
|
private Boolean voucherEnable;
|
||||||
}
|
}
|
||||||
|
@@ -35,8 +35,8 @@ public class ScenicConfigResp {
|
|||||||
*/
|
*/
|
||||||
private Integer videoStoreDay;
|
private Integer videoStoreDay;
|
||||||
private Integer allFree;
|
private Integer allFree;
|
||||||
private Integer disableSourceVideo;
|
private Boolean disableSourceVideo;
|
||||||
private Integer disableSourceImage;
|
private Boolean disableSourceImage;
|
||||||
private Integer antiScreenRecordType;
|
private Integer antiScreenRecordType;
|
||||||
private Integer videoSourceStoreDay;
|
private Integer videoSourceStoreDay;
|
||||||
private Integer imageSourceStoreDay;
|
private Integer imageSourceStoreDay;
|
||||||
@@ -45,9 +45,5 @@ public class ScenicConfigResp {
|
|||||||
|
|
||||||
private String imageSourcePackHint = "";
|
private String imageSourcePackHint = "";
|
||||||
private String videoSourcePackHint = "";
|
private String videoSourcePackHint = "";
|
||||||
/**
|
private Boolean voucherEnable;
|
||||||
* 是否启用券码功能
|
|
||||||
* 0-禁用 1-启用
|
|
||||||
*/
|
|
||||||
private Integer voucherEnable;
|
|
||||||
}
|
}
|
||||||
|
@@ -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.service.ScenicIntegrationService;
|
||||||
import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2DTO;
|
import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2DTO;
|
||||||
import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2WithConfigDTO;
|
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.facebody.enums.FaceBodyAdapterType;
|
||||||
import com.ycwl.basic.pay.enums.PayAdapterType;
|
import com.ycwl.basic.pay.enums.PayAdapterType;
|
||||||
import com.ycwl.basic.storage.enums.StorageType;
|
import com.ycwl.basic.storage.enums.StorageType;
|
||||||
@@ -157,110 +158,49 @@ public class ScenicRepository {
|
|||||||
|
|
||||||
java.util.Map<String, Object> config = dto.getConfig();
|
java.util.Map<String, Object> config = dto.getConfig();
|
||||||
|
|
||||||
entity.setBookRoutine(getIntValue(config, "book_routine"));
|
entity.setBookRoutine(ConfigValueUtil.getIntValue(config, "bookRoutine"));
|
||||||
entity.setForceFinishTime(getIntValue(config, "force_finish_time"));
|
entity.setForceFinishTime(ConfigValueUtil.getIntValue(config, "forceFinishTime"));
|
||||||
entity.setTourTime(getIntValue(config, "tour_time"));
|
entity.setTourTime(ConfigValueUtil.getIntValue(config, "tourTime"));
|
||||||
entity.setSampleStoreDay(getIntValue(config, "sample_store_day"));
|
entity.setSampleStoreDay(ConfigValueUtil.getIntValue(config, "sampleStoreDay"));
|
||||||
entity.setFaceStoreDay(getIntValue(config, "face_store_day"));
|
entity.setFaceStoreDay(ConfigValueUtil.getIntValue(config, "faceStoreDay"));
|
||||||
entity.setVideoStoreDay(getIntValue(config, "video_store_day"));
|
entity.setVideoStoreDay(ConfigValueUtil.getIntValue(config, "videoStoreDay"));
|
||||||
entity.setAllFree(getIntValue(config, "all_free"));
|
entity.setAllFree(ConfigValueUtil.getIntValue(config, "allFree"));
|
||||||
entity.setDisableSourceVideo(getIntValue(config, "disable_source_video"));
|
entity.setDisableSourceVideo(ConfigValueUtil.getBooleanValue(config, "disableSourceVideo"));
|
||||||
entity.setDisableSourceImage(getIntValue(config, "disable_source_image"));
|
entity.setDisableSourceImage(ConfigValueUtil.getBooleanValue(config, "disableSourceImage"));
|
||||||
entity.setTemplateNewVideoType(getIntValue(config, "template_new_video_type"));
|
entity.setTemplateNewVideoType(ConfigValueUtil.getIntValue(config, "templateNewVideoType"));
|
||||||
entity.setAntiScreenRecordType(getIntValue(config, "anti_screen_record_type"));
|
entity.setAntiScreenRecordType(ConfigValueUtil.getIntValue(config, "antiScreenRecordType"));
|
||||||
entity.setVideoSourceStoreDay(getIntValue(config, "video_source_store_day"));
|
entity.setVideoSourceStoreDay(ConfigValueUtil.getIntValue(config, "videoSourceStoreDay"));
|
||||||
entity.setImageSourceStoreDay(getIntValue(config, "image_source_store_day"));
|
entity.setImageSourceStoreDay(ConfigValueUtil.getIntValue(config, "imageSourceStoreDay"));
|
||||||
entity.setUserSourceExpireDay(getIntValue(config, "user_source_expire_day"));
|
entity.setUserSourceExpireDay(ConfigValueUtil.getIntValue(config, "userSourceExpireDay"));
|
||||||
entity.setFaceDetectHelperThreshold(getIntValue(config, "face_detect_helper_threshold"));
|
entity.setFaceDetectHelperThreshold(ConfigValueUtil.getIntValue(config, "faceDetectHelperThreshold"));
|
||||||
entity.setPhotoFreeNum(getIntValue(config, "photo_free_num"));
|
entity.setPhotoFreeNum(ConfigValueUtil.getIntValue(config, "photoFreeNum"));
|
||||||
entity.setVideoFreeNum(getIntValue(config, "video_free_num"));
|
entity.setVideoFreeNum(ConfigValueUtil.getIntValue(config, "videoFreeNum"));
|
||||||
entity.setVoucherEnable(getIntValue(config, "voucher_enable"));
|
entity.setVoucherEnable(ConfigValueUtil.getBooleanValue(config, "voucherEnable"));
|
||||||
|
|
||||||
entity.setFaceScoreThreshold(getFloatValue(config, "face_score_threshold"));
|
entity.setFaceScoreThreshold(ConfigValueUtil.getFloatValue(config, "faceScoreThreshold"));
|
||||||
entity.setBrokerDirectRate(getBigDecimalValue(config, "broker_direct_rate"));
|
entity.setBrokerDirectRate(ConfigValueUtil.getBigDecimalValue(config, "brokerDirectRate"));
|
||||||
|
|
||||||
entity.setWatermarkType(getStringValue(config, "watermark_type"));
|
entity.setWatermarkType(ConfigValueUtil.getStringValue(config, "watermarkType"));
|
||||||
entity.setWatermarkScenicText(getStringValue(config, "watermark_scenic_text"));
|
entity.setWatermarkScenicText(ConfigValueUtil.getStringValue(config, "watermarkScenicText"));
|
||||||
entity.setWatermarkDtFormat(getStringValue(config, "watermark_dt_format"));
|
entity.setWatermarkDtFormat(ConfigValueUtil.getStringValue(config, "watermarkDtFormat"));
|
||||||
entity.setImageSourcePackHint(getStringValue(config, "image_source_pack_hint"));
|
entity.setImageSourcePackHint(ConfigValueUtil.getStringValue(config, "imageSourcePackHint"));
|
||||||
entity.setVideoSourcePackHint(getStringValue(config, "video_source_pack_hint"));
|
entity.setVideoSourcePackHint(ConfigValueUtil.getStringValue(config, "videoSourcePackHint"));
|
||||||
entity.setExtraNotificationTime(getStringValue(config, "extra_notification_time"));
|
entity.setExtraNotificationTime(ConfigValueUtil.getStringValue(config, "extraNotificationTime"));
|
||||||
|
|
||||||
entity.setStoreType(getEnumValue(config, "store_type", StorageType.class));
|
entity.setStoreType(ConfigValueUtil.getEnumValue(config, "storeType", StorageType.class));
|
||||||
entity.setStoreConfigJson(getStringValue(config, "store_config_json"));
|
entity.setStoreConfigJson(ConfigValueUtil.getStringValue(config, "storeConfigJson"));
|
||||||
entity.setTmpStoreType(getEnumValue(config, "tmp_store_type", StorageType.class));
|
entity.setTmpStoreType(ConfigValueUtil.getEnumValue(config, "tmpStoreType", StorageType.class));
|
||||||
entity.setTmpStoreConfigJson(getStringValue(config, "tmp_store_config_json"));
|
entity.setTmpStoreConfigJson(ConfigValueUtil.getStringValue(config, "tmpStoreConfigJson"));
|
||||||
entity.setLocalStoreType(getEnumValue(config, "local_store_type", StorageType.class));
|
entity.setLocalStoreType(ConfigValueUtil.getEnumValue(config, "localStoreType", StorageType.class));
|
||||||
entity.setLocalStoreConfigJson(getStringValue(config, "local_store_config_json"));
|
entity.setLocalStoreConfigJson(ConfigValueUtil.getStringValue(config, "localStoreConfigJson"));
|
||||||
|
|
||||||
entity.setFaceType(getEnumValue(config, "face_type", FaceBodyAdapterType.class));
|
entity.setFaceType(ConfigValueUtil.getEnumValue(config, "faceType", FaceBodyAdapterType.class));
|
||||||
entity.setFaceConfigJson(getStringValue(config, "face_config_json"));
|
entity.setFaceConfigJson(ConfigValueUtil.getStringValue(config, "faceConfigJson"));
|
||||||
|
|
||||||
entity.setPayType(getEnumValue(config, "pay_type", PayAdapterType.class));
|
entity.setPayType(ConfigValueUtil.getEnumValue(config, "payType", PayAdapterType.class));
|
||||||
entity.setPayConfigJson(getStringValue(config, "pay_config_json"));
|
entity.setPayConfigJson(ConfigValueUtil.getStringValue(config, "payConfigJson"));
|
||||||
|
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer getIntValue(java.util.Map<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> config, String key) {
|
|
||||||
Object value = config.get(key);
|
|
||||||
return value != null ? value.toString() : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T extends Enum<T>> T getEnumValue(java.util.Map<String, Object> config, String key, Class<T> enumClass) {
|
|
||||||
Object value = config.get(key);
|
|
||||||
if (value == null) return null;
|
|
||||||
try {
|
|
||||||
return Enum.valueOf(enumClass, value.toString());
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user