Merge pull request #10352 from dataease/pr@dev-v2@perf_plugin

perf(X-Pack): 优化插件加载机制
This commit is contained in:
fit2cloud-chenyw 2024-06-18 19:06:56 +08:00 committed by GitHub
commit f699e8a3db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 56 additions and 27 deletions

@ -1 +1 @@
Subproject commit 070ee75a6da1e59e8b021462fe0604cbc04b0f64
Subproject commit 0bfb0e20ead5a4711cb54957003b63388067eb8b

View File

@ -1,7 +1,7 @@
package io.dataease.api.xpack.component;
import io.dataease.api.xpack.component.vo.XpackMenuVO;
import io.dataease.api.xpack.component.vo.XpackPluginsViewVO;
import io.dataease.extensions.view.vo.XpackPluginsViewVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

View File

@ -1,9 +1,14 @@
package io.dataease.api.xpack.plugin;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.dataease.api.xpack.plugin.dto.PluginEditor;
import io.dataease.api.xpack.plugin.vo.PluginVO;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@ -14,4 +19,12 @@ public interface PluginApi {
@GetMapping("/query")
List<PluginVO> query();
@PostMapping("/install")
void install(@RequestPart(value = "file") MultipartFile file);
@PostMapping("/uninstall/{id}")
void uninstall(@PathVariable("id") String id);
void update(@RequestPart("request") PluginEditor request, @RequestPart(value = "file") MultipartFile file);
}

View File

@ -0,0 +1,14 @@
package io.dataease.api.xpack.plugin.dto;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
public class PluginEditor implements Serializable {
@Serial
private static final long serialVersionUID = -1793403914368070138L;
private String id;
}

View File

@ -19,6 +19,7 @@ public class StaticResourceConstants {
public static String CUSTOM_MAP_DIR = ensureSuffix(USER_HOME, FILE_SEPARATOR) + "geo";
public static String APPEARANCE_DIR = ensureSuffix(USER_HOME, FILE_SEPARATOR) + "appearance";
public static String REPORT_DIR = ensureSuffix(USER_HOME, FILE_SEPARATOR) + "report";
public static String PLUGIN_DIR = ensureSuffix(USER_HOME, FILE_SEPARATOR) + "plugin";
public static String MAP_URL = "/map";
public static String GEO_URL = "/geo";

View File

@ -1,6 +1,7 @@
package io.dataease.extensions.view.factory;
import io.dataease.extensions.view.template.PluginsChartTemplate;
import io.dataease.extensions.view.vo.XpackPluginsViewVO;
import java.util.List;
import java.util.Map;
@ -21,7 +22,7 @@ public class PluginsChartFactory {
templateMap.put(key, template);
}
public static List<String> getViewConfigList() {
public static List<XpackPluginsViewVO> getViewConfigList() {
return templateMap.values().stream().map(PluginsChartTemplate::getConfig).toList();
}

View File

@ -3,40 +3,34 @@ package io.dataease.extensions.view.template;
import io.dataease.extensions.view.dto.ChartViewDTO;
import io.dataease.extensions.view.dto.ChartViewFieldDTO;
import io.dataease.extensions.view.dto.DatasetTableFieldDTO;
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 PluginsChartTemplate {
public abstract class PluginsChartTemplate implements DataEasePlugin {
public abstract String getConfig();
@Override
public void loadPlugin() {
XpackPluginsViewVO viewConfig = getConfig();
PluginsChartFactory.loadTemplate(viewConfig.getRender(), viewConfig.getCategory(), this);
}
public XpackPluginsViewVO getConfig() {
DataEasePluginVO pluginInfo = getPluginInfo();
String config = pluginInfo.getConfig();
return JsonUtil.parseObject(config, XpackPluginsViewVO.class);
}
public abstract Map<String, List<ChartViewFieldDTO>> formatChartAxis(ChartViewDTO view);
/*public Map<String, List<ChartViewFieldDTO>> formatChartAxis(ChartViewDTO view) {
Map<String, List<ChartViewFieldDTO>> result = new HashMap<>();
List<ChartViewFieldDTO> xAxisBase = new ArrayList<>(view.getXAxis());
result.put("xAxisBase", xAxisBase);
List<ChartViewFieldDTO> xAxis = new ArrayList<>(view.getXAxis());
result.put("xAxis", xAxis);
List<ChartViewFieldDTO> xAxisExt = new ArrayList<>(view.getXAxisExt());
result.put("xAxisExt", xAxisExt);
List<ChartViewFieldDTO> yAxis = new ArrayList<>(view.getYAxis());
result.put("yAxis", yAxis);
List<ChartViewFieldDTO> extStack = new ArrayList<>(view.getExtStack());
result.put("extStack", extStack);
List<ChartViewFieldDTO> extBubble = new ArrayList<>(view.getExtBubble());
result.put("extBubble", extBubble);
List<ChartViewFieldDTO> drill = new ArrayList<>(view.getDrillFields());
result.put("drill", drill);
List<ChartViewFieldDTO> viewFields = new ArrayList<>(view.getViewFields());
result.put("viewFields", viewFields);
return result;
}*/
public abstract ChartViewDTO calcResult(SQLMeta sqlMeta, List<ChartViewFieldDTO> xaxis, List<ChartViewFieldDTO> yaxis,
List<DatasetTableFieldDTO> allFields, boolean crossDs, Map<Long, String> dsTypeMap);

View File

@ -1,4 +1,4 @@
package io.dataease.api.xpack.component.vo;
package io.dataease.extensions.view.vo;
import lombok.Data;

View File

@ -27,6 +27,12 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>io.dataease</groupId>
<artifactId>dataease-license-sdk</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>