refactor(图表): 插件类型调整

This commit is contained in:
wisonic-s 2024-07-02 16:31:03 +08:00
parent 19b516a341
commit fb2b28c183

View File

@ -2,6 +2,7 @@ package io.dataease.extensions.view.factory;
import io.dataease.exception.DEException; import io.dataease.exception.DEException;
import io.dataease.extensions.view.plugin.AbstractChartPlugin; import io.dataease.extensions.view.plugin.AbstractChartPlugin;
import io.dataease.extensions.view.plugin.DataEaseChartPlugin;
import io.dataease.extensions.view.vo.XpackPluginsViewVO; import io.dataease.extensions.view.vo.XpackPluginsViewVO;
import io.dataease.license.utils.LicenseUtil; import io.dataease.license.utils.LicenseUtil;
import io.dataease.license.utils.LogUtil; import io.dataease.license.utils.LogUtil;
@ -13,7 +14,7 @@ import java.util.concurrent.ConcurrentHashMap;
public class PluginsChartFactory { public class PluginsChartFactory {
private static final Map<String, AbstractChartPlugin> templateMap = new ConcurrentHashMap<>(); private static final Map<String, DataEaseChartPlugin> templateMap = new ConcurrentHashMap<>();
public static AbstractChartPlugin getInstance(String render, String type) { public static AbstractChartPlugin getInstance(String render, String type) {
@ -22,14 +23,14 @@ public class PluginsChartFactory {
return templateMap.get(key); return templateMap.get(key);
} }
public static void loadPlugin(String render, String type, AbstractChartPlugin template) { public static void loadPlugin(String render, String type, DataEaseChartPlugin plugin) {
if (!LicenseUtil.licenseValid()) DEException.throwException("插件功能只对企业版本可用!"); if (!LicenseUtil.licenseValid()) DEException.throwException("插件功能只对企业版本可用!");
String key = render + "_" + type; String key = render + "_" + type;
if (templateMap.containsKey(key)) return; if (templateMap.containsKey(key)) return;
templateMap.put(key, template); templateMap.put(key, plugin);
try { try {
String moduleName = template.getPluginInfo().getModuleName(); String moduleName = plugin.getPluginInfo().getModuleName();
DataEasePluginFactory.loadTemplate(moduleName, template); DataEasePluginFactory.loadTemplate(moduleName, plugin);
} catch (Exception e) { } catch (Exception e) {
LogUtil.error(e.getMessage(), new Throwable(e)); LogUtil.error(e.getMessage(), new Throwable(e));
DEException.throwException(e); DEException.throwException(e);
@ -38,6 +39,6 @@ public class PluginsChartFactory {
public static List<XpackPluginsViewVO> getViewConfigList() { public static List<XpackPluginsViewVO> getViewConfigList() {
if (!LicenseUtil.licenseValid()) DEException.throwException("插件功能只对企业版本可用!"); if (!LicenseUtil.licenseValid()) DEException.throwException("插件功能只对企业版本可用!");
return templateMap.values().stream().map(AbstractChartPlugin::getConfig).toList(); return templateMap.values().stream().map(DataEaseChartPlugin::getConfig).toList();
} }
} }