refactor(scenic): 重构景区配置相关代码

- 为 FeignClient 添加 contextId 属性,提高服务调用的可读性
- 更新 ScenicIntegrationService 中的接口调用方式
- 修改 ScenicConfigEntity 和 ScenicConfigResp 中的字段类型
-重构 ScenicRepository 中的配置解析逻辑,使用 ConfigValueUtil 工具类
This commit is contained in:
2025-08-26 14:17:26 +08:00
parent 5871beb84e
commit f0aeb27566
10 changed files with 448 additions and 113 deletions

View File

@@ -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<String, Object> 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<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;
}
}
}