🎨 优化策略定义逻辑.

This commit is contained in:
lijiahangmax
2024-12-29 13:11:09 +08:00
parent 6606d2ca76
commit 6b14c2ef9c
11 changed files with 57 additions and 32 deletions

View File

@@ -23,7 +23,7 @@
package org.dromara.visor.module.infra.enums;
import lombok.Getter;
import org.dromara.visor.framework.common.handler.data.GenericsDataDefinition;
import org.dromara.visor.framework.common.handler.data.GenericsStrategyDefinition;
import org.dromara.visor.framework.common.handler.data.model.GenericsDataModel;
import org.dromara.visor.framework.common.handler.data.strategy.GenericsDataStrategy;
import org.dromara.visor.module.infra.handler.preference.strategy.SystemPreferenceStrategy;
@@ -37,7 +37,7 @@ import org.dromara.visor.module.infra.handler.preference.strategy.TerminalPrefer
* @since 2023/10/8 11:31
*/
@Getter
public enum PreferenceTypeEnum implements GenericsDataDefinition {
public enum PreferenceTypeEnum implements GenericsStrategyDefinition {
/**
* 系统偏好

View File

@@ -24,7 +24,7 @@ package org.dromara.visor.module.infra.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.dromara.visor.framework.common.handler.data.GenericsDataDefinition;
import org.dromara.visor.framework.common.handler.data.GenericsStrategyDefinition;
import org.dromara.visor.framework.common.handler.data.model.GenericsDataModel;
import org.dromara.visor.framework.common.handler.data.strategy.GenericsDataStrategy;
import org.dromara.visor.module.infra.handler.setting.strategy.SftpSystemSettingStrategy;
@@ -38,7 +38,7 @@ import org.dromara.visor.module.infra.handler.setting.strategy.SftpSystemSetting
*/
@Getter
@AllArgsConstructor
public enum SystemSettingTypeEnum implements GenericsDataDefinition {
public enum SystemSettingTypeEnum implements GenericsStrategyDefinition {
/**
* SFTP 配置

View File

@@ -164,9 +164,7 @@ public class PreferenceServiceImpl implements PreferenceService {
public Map<String, Object> getDefaultPreferenceByType(String type, List<String> items) {
PreferenceTypeEnum preferenceType = Valid.valid(PreferenceTypeEnum::of, type);
// 获取默认值
Map<String, Object> defaultModel = preferenceType.getStrategy()
.getDefault()
.toMap();
Map<String, Object> defaultModel = preferenceType.getDefault().toMap();
Map<String, Object> result = Maps.newMap();
if (Lists.isEmpty(items)) {
defaultModel.forEach((k, v) -> result.put(k, defaultModel.get(k)));
@@ -240,9 +238,7 @@ public class PreferenceServiceImpl implements PreferenceService {
// 初始化
if (Maps.isEmpty(config)) {
// 获取默认值
Map<String, Object> defaultConfig = type.getStrategy()
.getDefault()
.toMap();
Map<String, Object> defaultConfig = type.getDefault().toMap();
config = Maps.map(defaultConfig, Function.identity(), Refs::json);
// 插入默认值
List<PreferenceDO> entities = config

View File

@@ -148,9 +148,7 @@ public class SystemSettingServiceImpl implements SystemSettingService {
// 初始化
if (Maps.isEmpty(settings)) {
// 获取默认值
Map<String, Object> defaultConfig = settingType.getStrategy()
.getDefault()
.toMap();
Map<String, Object> defaultConfig = settingType.getDefault().toMap();
settings = Maps.map(defaultConfig, Function.identity(), Refs::json);
// 插入默认值
List<SystemSettingDO> entities = settings