初始化

This commit is contained in:
2026-02-22 18:56:10 +08:00
commit 26677972a6
3112 changed files with 255972 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
package tech.easyflow.common.options;
public interface SysOptionStore {
void save(String key,Object value);
String get(String key);
}

View File

@@ -0,0 +1,54 @@
package tech.easyflow.common.options;
import tech.easyflow.common.util.SpringContextUtil;
import tech.easyflow.common.util.StringUtil;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.stereotype.Component;
@Component
public class SysOptions {
private final SysOptionStore store;
public SysOptions(ObjectProvider<SysOptionStore> storeObjectProvider) {
this.store = storeObjectProvider.getIfAvailable();
}
public static void set(String key, String value) {
getInstance().store.save(key, value);
}
public static String get(String key) {
return getInstance().store.get(key);
}
public static String get(String key, String defaultValue) {
String value = get(key);
return StringUtil.hasText(value) ? value : defaultValue;
}
public static Boolean getAsBoolean(String key) {
String value = get(key);
return StringUtil.hasText(value) ? Boolean.parseBoolean(value) : null;
}
public static Boolean getAsBoolean(String key, Boolean defaultValue) {
Boolean value = getAsBoolean(key);
return value != null ? value : defaultValue;
}
private static SysOptions instance = null;
public static SysOptions getInstance() {
if (instance == null) {
instance = SpringContextUtil.getBean(SysOptions.class);
}
return instance;
}
}