From d494a260a3a23dfcdda6eb2bb8bc8013d7cd3079 Mon Sep 17 00:00:00 2001 From: wisonic-s Date: Tue, 2 Jul 2024 15:56:03 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E5=9B=BE=E8=A1=A8):=20=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E7=B1=BB=E5=9E=8B=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../view/plugin/AbstractChartPlugin.java | 33 +++---------------- .../view/plugin/DataEaseChartPlugin.java | 30 +++++++++++++++++ 2 files changed, 34 insertions(+), 29 deletions(-) create mode 100644 sdk/extensions/extensions-view/src/main/java/io/dataease/extensions/view/plugin/DataEaseChartPlugin.java diff --git a/sdk/extensions/extensions-view/src/main/java/io/dataease/extensions/view/plugin/AbstractChartPlugin.java b/sdk/extensions/extensions-view/src/main/java/io/dataease/extensions/view/plugin/AbstractChartPlugin.java index c15228c0e3..ff79521fe4 100644 --- a/sdk/extensions/extensions-view/src/main/java/io/dataease/extensions/view/plugin/AbstractChartPlugin.java +++ b/sdk/extensions/extensions-view/src/main/java/io/dataease/extensions/view/plugin/AbstractChartPlugin.java @@ -1,39 +1,13 @@ package io.dataease.extensions.view.plugin; -import io.dataease.exception.DEException; import io.dataease.extensions.datasource.provider.Provider; import io.dataease.extensions.view.dto.*; -import io.dataease.extensions.view.factory.PluginsChartFactory; import io.dataease.extensions.view.model.SQLMeta; -import io.dataease.extensions.view.vo.XpackPluginsViewVO; -import io.dataease.license.utils.JsonUtil; -import io.dataease.plugins.template.DataEasePlugin; -import io.dataease.plugins.vo.DataEasePluginVO; import java.util.List; import java.util.Map; -public abstract class AbstractChartPlugin implements DataEasePlugin { - - @Override - public void loadPlugin() { - XpackPluginsViewVO viewConfig = getConfig(); - PluginsChartFactory.loadPlugin(viewConfig.getRender(), viewConfig.getChartValue(), this); - } - - - public XpackPluginsViewVO getConfig() { - DataEasePluginVO pluginInfo = null; - try { - pluginInfo = getPluginInfo(); - } catch (Exception e) { - DEException.throwException(e); - } - String config = pluginInfo.getConfig(); - XpackPluginsViewVO vo = JsonUtil.parseObject(config, XpackPluginsViewVO.class); - vo.setIcon(pluginInfo.getIcon()); - return vo; - } +public abstract class AbstractChartPlugin { /** * 处理视图需要用到的轴字段,大部分图表都聚合成两个字段,X 和 Y。 @@ -72,8 +46,9 @@ public abstract class AbstractChartPlugin implements DataEasePlugin { /** * 构建视图,将计算结果处理成最终视图。 - * @param view 原视图对象 - * @param calcResult 计算结果 + * + * @param view 原视图对象 + * @param calcResult 计算结果 * @param formatResult 轴字段处理结果 * @param filterResult 过滤条件处理结果 * @return 返回前端的视图,建议数据放在 data 中,过滤条件放在 filter 中,其他字段可自行添加,可参考主工程。 diff --git a/sdk/extensions/extensions-view/src/main/java/io/dataease/extensions/view/plugin/DataEaseChartPlugin.java b/sdk/extensions/extensions-view/src/main/java/io/dataease/extensions/view/plugin/DataEaseChartPlugin.java new file mode 100644 index 0000000000..97dcfd1ac2 --- /dev/null +++ b/sdk/extensions/extensions-view/src/main/java/io/dataease/extensions/view/plugin/DataEaseChartPlugin.java @@ -0,0 +1,30 @@ +package io.dataease.extensions.view.plugin; + +import io.dataease.exception.DEException; +import io.dataease.extensions.view.factory.PluginsChartFactory; +import io.dataease.extensions.view.vo.XpackPluginsViewVO; +import io.dataease.license.utils.JsonUtil; +import io.dataease.plugins.template.DataEasePlugin; +import io.dataease.plugins.vo.DataEasePluginVO; + +public abstract class DataEaseChartPlugin extends AbstractChartPlugin implements DataEasePlugin { + + @Override + public void loadPlugin() { + XpackPluginsViewVO viewConfig = getConfig(); + PluginsChartFactory.loadPlugin(viewConfig.getRender(), viewConfig.getChartValue(), this); + } + + public XpackPluginsViewVO getConfig() { + DataEasePluginVO pluginInfo = null; + try { + pluginInfo = getPluginInfo(); + } catch (Exception e) { + DEException.throwException(e); + } + String config = pluginInfo.getConfig(); + XpackPluginsViewVO vo = JsonUtil.parseObject(config, XpackPluginsViewVO.class); + vo.setIcon(pluginInfo.getIcon()); + return vo; + } +}