From 5ad6d4974f4a782ac09efdaf3aab39303275b2bb Mon Sep 17 00:00:00 2001
From: "1437892690@qq.com" <1437892690@qq.com>
Date: Mon, 3 Jun 2024 14:25:39 +0800
Subject: [PATCH 1/2] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF-?=
=?UTF-8?q?=E5=85=A8=E5=B1=80=E6=95=B0=E6=8D=AE=E8=BD=AC=E6=8D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
#[1170943454445568]后端-全局数据转换 http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1170943454445568
---
.../dynamicplugin/DynamicPluginManager.java | 82 ++++++++
.../dynamicplugin/IDynamicPluginHandler.java | 25 +++
.../dynamicplugin/PluginClassLoader.java | 57 ++++++
.../IDynamicPluginCrossoverMapper.java | 43 ++++
.../IDynamicPluginCrossoverService.java | 29 +++
.../dynamicplugin/dto/DynamicPluginVo.java | 153 +++++++++++++++
.../dynamicplugin/DynamicPluginMapper.java | 43 ++++
.../dynamicplugin/DynamicPluginMapper.xml | 184 ++++++++++++++++++
.../service/DynamicPluginService.java | 28 +++
.../service/DynamicPluginServiceImpl.java | 50 +++++
.../LoadDynamicPluginStartupHandler.java | 109 +++++++++++
11 files changed, 803 insertions(+)
create mode 100644 src/main/java/neatlogic/framework/dynamicplugin/DynamicPluginManager.java
create mode 100644 src/main/java/neatlogic/framework/dynamicplugin/IDynamicPluginHandler.java
create mode 100644 src/main/java/neatlogic/framework/dynamicplugin/PluginClassLoader.java
create mode 100644 src/main/java/neatlogic/framework/dynamicplugin/crossover/IDynamicPluginCrossoverMapper.java
create mode 100644 src/main/java/neatlogic/framework/dynamicplugin/crossover/IDynamicPluginCrossoverService.java
create mode 100644 src/main/java/neatlogic/framework/dynamicplugin/dto/DynamicPluginVo.java
create mode 100644 src/main/java/neatlogic/module/framework/dao/mapper/dynamicplugin/DynamicPluginMapper.java
create mode 100644 src/main/java/neatlogic/module/framework/dao/mapper/dynamicplugin/DynamicPluginMapper.xml
create mode 100644 src/main/java/neatlogic/module/framework/dynamicplugin/service/DynamicPluginService.java
create mode 100644 src/main/java/neatlogic/module/framework/dynamicplugin/service/DynamicPluginServiceImpl.java
create mode 100644 src/main/java/neatlogic/module/framework/dynamicplugin/startup/LoadDynamicPluginStartupHandler.java
diff --git a/src/main/java/neatlogic/framework/dynamicplugin/DynamicPluginManager.java b/src/main/java/neatlogic/framework/dynamicplugin/DynamicPluginManager.java
new file mode 100644
index 000000000..4419525ad
--- /dev/null
+++ b/src/main/java/neatlogic/framework/dynamicplugin/DynamicPluginManager.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package neatlogic.framework.dynamicplugin;
+
+import neatlogic.framework.crossover.CrossoverServiceFactory;
+import neatlogic.framework.dynamicplugin.crossover.IDynamicPluginCrossoverMapper;
+import neatlogic.framework.dynamicplugin.dto.DynamicPluginVo;
+import neatlogic.framework.exception.file.FileNotFoundException;
+import neatlogic.framework.file.dao.mapper.FileMapper;
+import neatlogic.framework.file.dto.FileVo;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.Map;
+
+@Service
+public class DynamicPluginManager {
+
+ private static FileMapper fileMapper;
+
+ @Resource
+ public void setFileMapper(FileMapper _fileMapper) {
+ fileMapper = _fileMapper;
+ }
+
+ private final static Map> fileId2ClassMap = new HashMap<>();
+
+ public static Class> getClassByDynamicPluginId(Long dynamicPluginId) throws Exception {
+ IDynamicPluginCrossoverMapper dynamicPluginCrossoverMapper = CrossoverServiceFactory.getApi(IDynamicPluginCrossoverMapper.class);
+ DynamicPluginVo dynamicPlugin = dynamicPluginCrossoverMapper.getDynamicPluginById(dynamicPluginId);
+ Class> aClass = getClassByFileId(dynamicPlugin.getFileId());
+ return aClass;
+ }
+
+ public static Class> getClassByDynamicPluginKey(Long dynamicPluginKey) throws Exception {
+ IDynamicPluginCrossoverMapper dynamicPluginCrossoverMapper = CrossoverServiceFactory.getApi(IDynamicPluginCrossoverMapper.class);
+ DynamicPluginVo dynamicPlugin = dynamicPluginCrossoverMapper.getDynamicPluginById(dynamicPluginKey);
+ Class> aClass = getClassByFileId(dynamicPlugin.getFileId());
+ return aClass;
+ }
+
+ public static Class> getClassByFileId(Long fileId) throws Exception {
+ Class> aClass = fileId2ClassMap.get(fileId);
+ if (aClass == null) {
+ FileVo fileVo = fileMapper.getFileById(fileId);
+ if (fileVo == null) {
+ throw new FileNotFoundException(fileId);
+ }
+ return loadPlugin(fileVo);
+ }
+ return aClass;
+ }
+
+ public static Class> loadPlugin(FileVo fileVo) throws ClassNotFoundException {
+ PluginClassLoader pluginClassLoader = new PluginClassLoader(DynamicPluginManager.class.getClassLoader());
+ Class> aClass = pluginClassLoader.loadClass(fileVo.getPath());
+ if (aClass != null) {
+ fileId2ClassMap.put(fileVo.getId(), aClass);
+ }
+ return aClass;
+ }
+
+ public static boolean removePlugin(Long fileId) {
+ return fileId2ClassMap.remove(fileId) != null;
+ }
+}
diff --git a/src/main/java/neatlogic/framework/dynamicplugin/IDynamicPluginHandler.java b/src/main/java/neatlogic/framework/dynamicplugin/IDynamicPluginHandler.java
new file mode 100644
index 000000000..0f851146f
--- /dev/null
+++ b/src/main/java/neatlogic/framework/dynamicplugin/IDynamicPluginHandler.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package neatlogic.framework.dynamicplugin;
+
+import com.alibaba.fastjson.JSONObject;
+
+public interface IDynamicPluginHandler {
+
+ Object handle(JSONObject paramObj) throws Throwable;
+}
diff --git a/src/main/java/neatlogic/framework/dynamicplugin/PluginClassLoader.java b/src/main/java/neatlogic/framework/dynamicplugin/PluginClassLoader.java
new file mode 100644
index 000000000..1a5777267
--- /dev/null
+++ b/src/main/java/neatlogic/framework/dynamicplugin/PluginClassLoader.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package neatlogic.framework.dynamicplugin;
+
+import neatlogic.framework.common.util.FileUtil;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+public class PluginClassLoader extends ClassLoader {
+
+ public PluginClassLoader(ClassLoader parent) {
+ super(parent);
+ }
+
+ @Override
+ protected Class> findClass(String name) throws ClassNotFoundException {
+ System.out.println("name = " + name);
+ byte[] classBytes = this.readClassBytes(name);
+ if (classBytes.length == 0) {
+ throw new ClassNotFoundException("Can not load the class " + name);
+ }
+ return this.defineClass(null, classBytes, 0, classBytes.length);
+ }
+
+
+ private byte[] readClassBytes(String name) throws ClassNotFoundException {
+ try (InputStream in = FileUtil.getData(name);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ) {
+ byte[] buffer = new byte[1024];
+ int length;
+ while ((length = in.read(buffer)) != -1) {
+ baos.write(buffer, 0, length);
+ }
+ baos.flush();
+ return baos.toByteArray();
+ } catch (Exception e) {
+ throw new ClassNotFoundException("The class " + name + " not found.", e);
+ }
+ }
+}
diff --git a/src/main/java/neatlogic/framework/dynamicplugin/crossover/IDynamicPluginCrossoverMapper.java b/src/main/java/neatlogic/framework/dynamicplugin/crossover/IDynamicPluginCrossoverMapper.java
new file mode 100644
index 000000000..4d1b85a4d
--- /dev/null
+++ b/src/main/java/neatlogic/framework/dynamicplugin/crossover/IDynamicPluginCrossoverMapper.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package neatlogic.framework.dynamicplugin.crossover;
+
+import neatlogic.framework.common.dto.BasePageVo;
+import neatlogic.framework.crossover.ICrossoverService;
+import neatlogic.framework.dynamicplugin.dto.DynamicPluginVo;
+
+import java.util.List;
+
+public interface IDynamicPluginCrossoverMapper extends ICrossoverService {
+
+ List getDynamicPluginList();
+
+ DynamicPluginVo getDynamicPluginById(Long id);
+
+ DynamicPluginVo getDynamicPluginByKey(String key);
+
+ List getDynamicPluginListByIdList(List idList);
+
+ int getDynamicPluginCount(BasePageVo search);
+
+ List searchDynamicPluginList(BasePageVo search);
+
+ int insertDynamicPlugin(DynamicPluginVo dynamicPluginVo);
+
+ int deleteDynamicPluginById(Long id);
+}
diff --git a/src/main/java/neatlogic/framework/dynamicplugin/crossover/IDynamicPluginCrossoverService.java b/src/main/java/neatlogic/framework/dynamicplugin/crossover/IDynamicPluginCrossoverService.java
new file mode 100644
index 000000000..27aebd585
--- /dev/null
+++ b/src/main/java/neatlogic/framework/dynamicplugin/crossover/IDynamicPluginCrossoverService.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package neatlogic.framework.dynamicplugin.crossover;
+
+import neatlogic.framework.common.dto.BasePageVo;
+import neatlogic.framework.crossover.ICrossoverService;
+import neatlogic.framework.dynamicplugin.dto.DynamicPluginVo;
+
+import java.util.List;
+
+public interface IDynamicPluginCrossoverService extends ICrossoverService {
+
+ List searchDynamicPluginList(BasePageVo search);
+}
diff --git a/src/main/java/neatlogic/framework/dynamicplugin/dto/DynamicPluginVo.java b/src/main/java/neatlogic/framework/dynamicplugin/dto/DynamicPluginVo.java
new file mode 100644
index 000000000..b6b62078e
--- /dev/null
+++ b/src/main/java/neatlogic/framework/dynamicplugin/dto/DynamicPluginVo.java
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package neatlogic.framework.dynamicplugin.dto;
+
+import java.util.Date;
+public class DynamicPluginVo {
+
+ private Long id;
+ private String key;
+ private String name;
+ private String type;
+
+ private Integer isActive;
+ private String className;
+ private Long fileId;
+ private String fileName;
+
+ private String description;
+ private String error;
+
+
+ private String fcu;
+ private Date fcd;
+ private String lcu;
+ private Date lcd;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ public Long getFileId() {
+ return fileId;
+ }
+
+ public void setFileId(Long fileId) {
+ this.fileId = fileId;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
+ public String getFcu() {
+ return fcu;
+ }
+
+ public void setFcu(String fcu) {
+ this.fcu = fcu;
+ }
+
+ public Date getFcd() {
+ return fcd;
+ }
+
+ public void setFcd(Date fcd) {
+ this.fcd = fcd;
+ }
+
+ public String getLcu() {
+ return lcu;
+ }
+
+ public void setLcu(String lcu) {
+ this.lcu = lcu;
+ }
+
+ public Date getLcd() {
+ return lcd;
+ }
+
+ public void setLcd(Date lcd) {
+ this.lcd = lcd;
+ }
+
+ public Integer getIsActive() {
+ return isActive;
+ }
+
+ public void setIsActive(Integer isActive) {
+ this.isActive = isActive;
+ }
+
+ public String getError() {
+ return error;
+ }
+
+ public void setError(String error) {
+ this.error = error;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+}
diff --git a/src/main/java/neatlogic/module/framework/dao/mapper/dynamicplugin/DynamicPluginMapper.java b/src/main/java/neatlogic/module/framework/dao/mapper/dynamicplugin/DynamicPluginMapper.java
new file mode 100644
index 000000000..3a524be49
--- /dev/null
+++ b/src/main/java/neatlogic/module/framework/dao/mapper/dynamicplugin/DynamicPluginMapper.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package neatlogic.module.framework.dao.mapper.dynamicplugin;
+
+import neatlogic.framework.common.dto.BasePageVo;
+import neatlogic.framework.dynamicplugin.crossover.IDynamicPluginCrossoverMapper;
+import neatlogic.framework.dynamicplugin.dto.DynamicPluginVo;
+
+import java.util.List;
+
+public interface DynamicPluginMapper extends IDynamicPluginCrossoverMapper {
+
+ List getDynamicPluginList();
+
+ DynamicPluginVo getDynamicPluginById(Long id);
+
+ DynamicPluginVo getDynamicPluginByKey(String key);
+
+ List getDynamicPluginListByIdList(List idList);
+
+ int getDynamicPluginCount(BasePageVo search);
+
+ List searchDynamicPluginList(BasePageVo search);
+
+ int insertDynamicPlugin(DynamicPluginVo dynamicPluginVo);
+
+ int deleteDynamicPluginById(Long id);
+}
diff --git a/src/main/java/neatlogic/module/framework/dao/mapper/dynamicplugin/DynamicPluginMapper.xml b/src/main/java/neatlogic/module/framework/dao/mapper/dynamicplugin/DynamicPluginMapper.xml
new file mode 100644
index 000000000..0c144c4f5
--- /dev/null
+++ b/src/main/java/neatlogic/module/framework/dao/mapper/dynamicplugin/DynamicPluginMapper.xml
@@ -0,0 +1,184 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ INSERT INTO `dynamic_plugin` (
+ `id`,
+ `key`,
+ `name`,
+ `type`,
+ `is_active`,
+ `class_name`,
+ `file_id`,
+ `file_name`,
+ `description`,
+ `error`,
+ `fcu`,
+ `fcd`,
+ `lcu`,
+ `lcd`
+ )
+ VALUES
+ (
+ #{id},
+ #{key},
+ #{name},
+ #{type},
+ #{isActive},
+ #{className},
+ #{fileId},
+ #{fileName},
+ #{description},
+ #{error},
+ #{fcu},
+ NOW(),
+ #{lcu},
+ NOW()
+ )
+ ON DUPLICATE KEY UPDATE
+ `is_active` = #{isActive},
+ `class_name` = #{className},
+ `file_id` = #{fileId},
+ `file_name` = #{fileName},
+ `description` = #{description},
+ `error` = #{error},
+ `lcu` = #{lcu},
+ `lcd` = NOW()
+
+
+
+ DELETE FROM `dynamic_plugin` WHERE `id` = #{value}
+
+
\ No newline at end of file
diff --git a/src/main/java/neatlogic/module/framework/dynamicplugin/service/DynamicPluginService.java b/src/main/java/neatlogic/module/framework/dynamicplugin/service/DynamicPluginService.java
new file mode 100644
index 000000000..12fced959
--- /dev/null
+++ b/src/main/java/neatlogic/module/framework/dynamicplugin/service/DynamicPluginService.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package neatlogic.module.framework.dynamicplugin.service;
+
+import neatlogic.framework.common.dto.BasePageVo;
+import neatlogic.framework.dynamicplugin.dto.DynamicPluginVo;
+
+import java.util.List;
+
+public interface DynamicPluginService {
+
+ List searchDynamicPluginList(BasePageVo search);
+}
diff --git a/src/main/java/neatlogic/module/framework/dynamicplugin/service/DynamicPluginServiceImpl.java b/src/main/java/neatlogic/module/framework/dynamicplugin/service/DynamicPluginServiceImpl.java
new file mode 100644
index 000000000..b95f338ea
--- /dev/null
+++ b/src/main/java/neatlogic/module/framework/dynamicplugin/service/DynamicPluginServiceImpl.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package neatlogic.module.framework.dynamicplugin.service;
+
+import neatlogic.framework.common.dto.BasePageVo;
+import neatlogic.framework.dynamicplugin.crossover.IDynamicPluginCrossoverService;
+import neatlogic.framework.dynamicplugin.dto.DynamicPluginVo;
+import neatlogic.module.framework.dao.mapper.dynamicplugin.DynamicPluginMapper;
+import org.apache.commons.collections4.CollectionUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+@Service
+public class DynamicPluginServiceImpl implements DynamicPluginService, IDynamicPluginCrossoverService {
+
+ @Resource
+ private DynamicPluginMapper dynamicPluginMapper;
+
+ @Override
+ public List searchDynamicPluginList(BasePageVo search) {
+ List tbodyList = dynamicPluginMapper.searchDynamicPluginList(search);
+ if (Objects.equals(search.getRowNum(), 0) && (CollectionUtils.isNotEmpty(tbodyList) || search.getCurrentPage() > 1)) {
+ int rowNum = dynamicPluginMapper.getDynamicPluginCount(search);
+ if (rowNum == 0) {
+ return new ArrayList<>();
+ }
+ search.setRowNum(rowNum);
+ }
+ return tbodyList;
+ }
+}
diff --git a/src/main/java/neatlogic/module/framework/dynamicplugin/startup/LoadDynamicPluginStartupHandler.java b/src/main/java/neatlogic/module/framework/dynamicplugin/startup/LoadDynamicPluginStartupHandler.java
new file mode 100644
index 000000000..1db95e8f4
--- /dev/null
+++ b/src/main/java/neatlogic/module/framework/dynamicplugin/startup/LoadDynamicPluginStartupHandler.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package neatlogic.module.framework.dynamicplugin.startup;
+
+import neatlogic.framework.common.dto.BasePageVo;
+import neatlogic.framework.dynamicplugin.DynamicPluginManager;
+import neatlogic.framework.dynamicplugin.dto.DynamicPluginVo;
+import neatlogic.framework.exception.file.FileNotFoundException;
+import neatlogic.framework.file.dao.mapper.FileMapper;
+import neatlogic.framework.file.dto.FileVo;
+import neatlogic.framework.startup.StartupBase;
+import neatlogic.module.framework.dao.mapper.dynamicplugin.DynamicPluginMapper;
+import neatlogic.module.framework.dynamicplugin.service.DynamicPluginService;
+import org.apache.commons.collections4.CollectionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Component
+public class LoadDynamicPluginStartupHandler extends StartupBase {
+
+ private Logger logger = LoggerFactory.getLogger(LoadDynamicPluginStartupHandler.class);
+ @Resource
+ private DynamicPluginService dynamicPluginService;
+
+ @Resource
+ private DynamicPluginMapper dynamicPluginMapper;
+
+ @Resource
+ private FileMapper fileMapper;
+
+ @Override
+ public String getName() {
+ return "";
+ }
+
+ @Override
+ public int executeForAllTenant() {
+ List allDynamicPluginList = new ArrayList<>();
+ int currentPage = 1;
+ int pageSize = 100;
+ BasePageVo search = new BasePageVo();
+ search.setPageSize(pageSize);
+ do {
+ search.setCurrentPage(currentPage);
+ List dynamicPluginList = dynamicPluginService.searchDynamicPluginList(search);
+ allDynamicPluginList.addAll(dynamicPluginList);
+ currentPage++;
+ } while(currentPage > search.getPageCount());
+
+ Map fileMap = new HashMap<>();
+ if (CollectionUtils.isNotEmpty(allDynamicPluginList)) {
+ List fileIdList = allDynamicPluginList.stream().map(DynamicPluginVo::getFileId).collect(Collectors.toList());
+ List fileList = fileMapper.getFileListByIdList(fileIdList);
+ fileList.stream().collect(Collectors.toMap(e -> e.getId(), e -> e));
+ }
+ List needUpdateDynamicPluginList = new ArrayList<>();
+ for (DynamicPluginVo dynamicPluginVo : allDynamicPluginList) {
+ try {
+ FileVo fileVo = fileMap.get(dynamicPluginVo.getFileId());
+ if (fileVo == null) {
+ throw new FileNotFoundException(dynamicPluginVo.getFileId());
+ }
+ Class> aClass = DynamicPluginManager.getClassByFileId(fileVo.getId());
+ if (aClass == null) {
+ DynamicPluginManager.loadPlugin(fileVo);
+ }
+ } catch (Exception e) {
+ dynamicPluginVo.setIsActive(0);
+ dynamicPluginVo.setError(e.getMessage());
+ needUpdateDynamicPluginList.add(dynamicPluginVo);
+ logger.error(e.getMessage(), e);
+ }
+ }
+ if (CollectionUtils.isNotEmpty(needUpdateDynamicPluginList)) {
+ for (DynamicPluginVo dynamicPluginVo : needUpdateDynamicPluginList) {
+ dynamicPluginMapper.insertDynamicPlugin(dynamicPluginVo);
+ }
+ }
+ return 1;
+ }
+
+ @Override
+ public int sort() {
+ return 12;
+ }
+}
--
Gitee
From 810b5b12fc5fbac9f6aea3b148db7ccde3b65bb6 Mon Sep 17 00:00:00 2001
From: "1437892690@qq.com" <1437892690@qq.com>
Date: Wed, 5 Jun 2024 14:40:51 +0800
Subject: [PATCH 2/2] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF-?=
=?UTF-8?q?=E5=85=A8=E5=B1=80=E6=95=B0=E6=8D=AE=E8=BD=AC=E6=8D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
#[1170943454445568]后端-全局数据转换 http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1170943454445568
---
.../dynamicplugin/DynamicPluginManager.java | 82 --------
.../dynamicplugin/IDynamicPluginHandler.java | 25 ---
.../dynamicplugin/PluginClassLoader.java | 57 ------
.../IDynamicPluginCrossoverMapper.java | 43 ----
.../IDynamicPluginCrossoverService.java | 29 ---
.../dynamicplugin/dto/DynamicPluginVo.java | 153 ---------------
.../dynamicplugin/DynamicPluginMapper.java | 43 ----
.../dynamicplugin/DynamicPluginMapper.xml | 184 ------------------
.../service/DynamicPluginService.java | 28 ---
.../service/DynamicPluginServiceImpl.java | 50 -----
.../LoadDynamicPluginStartupHandler.java | 109 -----------
11 files changed, 803 deletions(-)
delete mode 100644 src/main/java/neatlogic/framework/dynamicplugin/DynamicPluginManager.java
delete mode 100644 src/main/java/neatlogic/framework/dynamicplugin/IDynamicPluginHandler.java
delete mode 100644 src/main/java/neatlogic/framework/dynamicplugin/PluginClassLoader.java
delete mode 100644 src/main/java/neatlogic/framework/dynamicplugin/crossover/IDynamicPluginCrossoverMapper.java
delete mode 100644 src/main/java/neatlogic/framework/dynamicplugin/crossover/IDynamicPluginCrossoverService.java
delete mode 100644 src/main/java/neatlogic/framework/dynamicplugin/dto/DynamicPluginVo.java
delete mode 100644 src/main/java/neatlogic/module/framework/dao/mapper/dynamicplugin/DynamicPluginMapper.java
delete mode 100644 src/main/java/neatlogic/module/framework/dao/mapper/dynamicplugin/DynamicPluginMapper.xml
delete mode 100644 src/main/java/neatlogic/module/framework/dynamicplugin/service/DynamicPluginService.java
delete mode 100644 src/main/java/neatlogic/module/framework/dynamicplugin/service/DynamicPluginServiceImpl.java
delete mode 100644 src/main/java/neatlogic/module/framework/dynamicplugin/startup/LoadDynamicPluginStartupHandler.java
diff --git a/src/main/java/neatlogic/framework/dynamicplugin/DynamicPluginManager.java b/src/main/java/neatlogic/framework/dynamicplugin/DynamicPluginManager.java
deleted file mode 100644
index 4419525ad..000000000
--- a/src/main/java/neatlogic/framework/dynamicplugin/DynamicPluginManager.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package neatlogic.framework.dynamicplugin;
-
-import neatlogic.framework.crossover.CrossoverServiceFactory;
-import neatlogic.framework.dynamicplugin.crossover.IDynamicPluginCrossoverMapper;
-import neatlogic.framework.dynamicplugin.dto.DynamicPluginVo;
-import neatlogic.framework.exception.file.FileNotFoundException;
-import neatlogic.framework.file.dao.mapper.FileMapper;
-import neatlogic.framework.file.dto.FileVo;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.util.HashMap;
-import java.util.Map;
-
-@Service
-public class DynamicPluginManager {
-
- private static FileMapper fileMapper;
-
- @Resource
- public void setFileMapper(FileMapper _fileMapper) {
- fileMapper = _fileMapper;
- }
-
- private final static Map> fileId2ClassMap = new HashMap<>();
-
- public static Class> getClassByDynamicPluginId(Long dynamicPluginId) throws Exception {
- IDynamicPluginCrossoverMapper dynamicPluginCrossoverMapper = CrossoverServiceFactory.getApi(IDynamicPluginCrossoverMapper.class);
- DynamicPluginVo dynamicPlugin = dynamicPluginCrossoverMapper.getDynamicPluginById(dynamicPluginId);
- Class> aClass = getClassByFileId(dynamicPlugin.getFileId());
- return aClass;
- }
-
- public static Class> getClassByDynamicPluginKey(Long dynamicPluginKey) throws Exception {
- IDynamicPluginCrossoverMapper dynamicPluginCrossoverMapper = CrossoverServiceFactory.getApi(IDynamicPluginCrossoverMapper.class);
- DynamicPluginVo dynamicPlugin = dynamicPluginCrossoverMapper.getDynamicPluginById(dynamicPluginKey);
- Class> aClass = getClassByFileId(dynamicPlugin.getFileId());
- return aClass;
- }
-
- public static Class> getClassByFileId(Long fileId) throws Exception {
- Class> aClass = fileId2ClassMap.get(fileId);
- if (aClass == null) {
- FileVo fileVo = fileMapper.getFileById(fileId);
- if (fileVo == null) {
- throw new FileNotFoundException(fileId);
- }
- return loadPlugin(fileVo);
- }
- return aClass;
- }
-
- public static Class> loadPlugin(FileVo fileVo) throws ClassNotFoundException {
- PluginClassLoader pluginClassLoader = new PluginClassLoader(DynamicPluginManager.class.getClassLoader());
- Class> aClass = pluginClassLoader.loadClass(fileVo.getPath());
- if (aClass != null) {
- fileId2ClassMap.put(fileVo.getId(), aClass);
- }
- return aClass;
- }
-
- public static boolean removePlugin(Long fileId) {
- return fileId2ClassMap.remove(fileId) != null;
- }
-}
diff --git a/src/main/java/neatlogic/framework/dynamicplugin/IDynamicPluginHandler.java b/src/main/java/neatlogic/framework/dynamicplugin/IDynamicPluginHandler.java
deleted file mode 100644
index 0f851146f..000000000
--- a/src/main/java/neatlogic/framework/dynamicplugin/IDynamicPluginHandler.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package neatlogic.framework.dynamicplugin;
-
-import com.alibaba.fastjson.JSONObject;
-
-public interface IDynamicPluginHandler {
-
- Object handle(JSONObject paramObj) throws Throwable;
-}
diff --git a/src/main/java/neatlogic/framework/dynamicplugin/PluginClassLoader.java b/src/main/java/neatlogic/framework/dynamicplugin/PluginClassLoader.java
deleted file mode 100644
index 1a5777267..000000000
--- a/src/main/java/neatlogic/framework/dynamicplugin/PluginClassLoader.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package neatlogic.framework.dynamicplugin;
-
-import neatlogic.framework.common.util.FileUtil;
-
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-
-public class PluginClassLoader extends ClassLoader {
-
- public PluginClassLoader(ClassLoader parent) {
- super(parent);
- }
-
- @Override
- protected Class> findClass(String name) throws ClassNotFoundException {
- System.out.println("name = " + name);
- byte[] classBytes = this.readClassBytes(name);
- if (classBytes.length == 0) {
- throw new ClassNotFoundException("Can not load the class " + name);
- }
- return this.defineClass(null, classBytes, 0, classBytes.length);
- }
-
-
- private byte[] readClassBytes(String name) throws ClassNotFoundException {
- try (InputStream in = FileUtil.getData(name);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ) {
- byte[] buffer = new byte[1024];
- int length;
- while ((length = in.read(buffer)) != -1) {
- baos.write(buffer, 0, length);
- }
- baos.flush();
- return baos.toByteArray();
- } catch (Exception e) {
- throw new ClassNotFoundException("The class " + name + " not found.", e);
- }
- }
-}
diff --git a/src/main/java/neatlogic/framework/dynamicplugin/crossover/IDynamicPluginCrossoverMapper.java b/src/main/java/neatlogic/framework/dynamicplugin/crossover/IDynamicPluginCrossoverMapper.java
deleted file mode 100644
index 4d1b85a4d..000000000
--- a/src/main/java/neatlogic/framework/dynamicplugin/crossover/IDynamicPluginCrossoverMapper.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package neatlogic.framework.dynamicplugin.crossover;
-
-import neatlogic.framework.common.dto.BasePageVo;
-import neatlogic.framework.crossover.ICrossoverService;
-import neatlogic.framework.dynamicplugin.dto.DynamicPluginVo;
-
-import java.util.List;
-
-public interface IDynamicPluginCrossoverMapper extends ICrossoverService {
-
- List getDynamicPluginList();
-
- DynamicPluginVo getDynamicPluginById(Long id);
-
- DynamicPluginVo getDynamicPluginByKey(String key);
-
- List getDynamicPluginListByIdList(List idList);
-
- int getDynamicPluginCount(BasePageVo search);
-
- List searchDynamicPluginList(BasePageVo search);
-
- int insertDynamicPlugin(DynamicPluginVo dynamicPluginVo);
-
- int deleteDynamicPluginById(Long id);
-}
diff --git a/src/main/java/neatlogic/framework/dynamicplugin/crossover/IDynamicPluginCrossoverService.java b/src/main/java/neatlogic/framework/dynamicplugin/crossover/IDynamicPluginCrossoverService.java
deleted file mode 100644
index 27aebd585..000000000
--- a/src/main/java/neatlogic/framework/dynamicplugin/crossover/IDynamicPluginCrossoverService.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package neatlogic.framework.dynamicplugin.crossover;
-
-import neatlogic.framework.common.dto.BasePageVo;
-import neatlogic.framework.crossover.ICrossoverService;
-import neatlogic.framework.dynamicplugin.dto.DynamicPluginVo;
-
-import java.util.List;
-
-public interface IDynamicPluginCrossoverService extends ICrossoverService {
-
- List searchDynamicPluginList(BasePageVo search);
-}
diff --git a/src/main/java/neatlogic/framework/dynamicplugin/dto/DynamicPluginVo.java b/src/main/java/neatlogic/framework/dynamicplugin/dto/DynamicPluginVo.java
deleted file mode 100644
index b6b62078e..000000000
--- a/src/main/java/neatlogic/framework/dynamicplugin/dto/DynamicPluginVo.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package neatlogic.framework.dynamicplugin.dto;
-
-import java.util.Date;
-public class DynamicPluginVo {
-
- private Long id;
- private String key;
- private String name;
- private String type;
-
- private Integer isActive;
- private String className;
- private Long fileId;
- private String fileName;
-
- private String description;
- private String error;
-
-
- private String fcu;
- private Date fcd;
- private String lcu;
- private Date lcd;
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getKey() {
- return key;
- }
-
- public void setKey(String key) {
- this.key = key;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getClassName() {
- return className;
- }
-
- public void setClassName(String className) {
- this.className = className;
- }
-
- public Long getFileId() {
- return fileId;
- }
-
- public void setFileId(Long fileId) {
- this.fileId = fileId;
- }
-
- public String getFileName() {
- return fileName;
- }
-
- public void setFileName(String fileName) {
- this.fileName = fileName;
- }
-
- public String getFcu() {
- return fcu;
- }
-
- public void setFcu(String fcu) {
- this.fcu = fcu;
- }
-
- public Date getFcd() {
- return fcd;
- }
-
- public void setFcd(Date fcd) {
- this.fcd = fcd;
- }
-
- public String getLcu() {
- return lcu;
- }
-
- public void setLcu(String lcu) {
- this.lcu = lcu;
- }
-
- public Date getLcd() {
- return lcd;
- }
-
- public void setLcd(Date lcd) {
- this.lcd = lcd;
- }
-
- public Integer getIsActive() {
- return isActive;
- }
-
- public void setIsActive(Integer isActive) {
- this.isActive = isActive;
- }
-
- public String getError() {
- return error;
- }
-
- public void setError(String error) {
- this.error = error;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-}
diff --git a/src/main/java/neatlogic/module/framework/dao/mapper/dynamicplugin/DynamicPluginMapper.java b/src/main/java/neatlogic/module/framework/dao/mapper/dynamicplugin/DynamicPluginMapper.java
deleted file mode 100644
index 3a524be49..000000000
--- a/src/main/java/neatlogic/module/framework/dao/mapper/dynamicplugin/DynamicPluginMapper.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package neatlogic.module.framework.dao.mapper.dynamicplugin;
-
-import neatlogic.framework.common.dto.BasePageVo;
-import neatlogic.framework.dynamicplugin.crossover.IDynamicPluginCrossoverMapper;
-import neatlogic.framework.dynamicplugin.dto.DynamicPluginVo;
-
-import java.util.List;
-
-public interface DynamicPluginMapper extends IDynamicPluginCrossoverMapper {
-
- List getDynamicPluginList();
-
- DynamicPluginVo getDynamicPluginById(Long id);
-
- DynamicPluginVo getDynamicPluginByKey(String key);
-
- List getDynamicPluginListByIdList(List idList);
-
- int getDynamicPluginCount(BasePageVo search);
-
- List searchDynamicPluginList(BasePageVo search);
-
- int insertDynamicPlugin(DynamicPluginVo dynamicPluginVo);
-
- int deleteDynamicPluginById(Long id);
-}
diff --git a/src/main/java/neatlogic/module/framework/dao/mapper/dynamicplugin/DynamicPluginMapper.xml b/src/main/java/neatlogic/module/framework/dao/mapper/dynamicplugin/DynamicPluginMapper.xml
deleted file mode 100644
index 0c144c4f5..000000000
--- a/src/main/java/neatlogic/module/framework/dao/mapper/dynamicplugin/DynamicPluginMapper.xml
+++ /dev/null
@@ -1,184 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- INSERT INTO `dynamic_plugin` (
- `id`,
- `key`,
- `name`,
- `type`,
- `is_active`,
- `class_name`,
- `file_id`,
- `file_name`,
- `description`,
- `error`,
- `fcu`,
- `fcd`,
- `lcu`,
- `lcd`
- )
- VALUES
- (
- #{id},
- #{key},
- #{name},
- #{type},
- #{isActive},
- #{className},
- #{fileId},
- #{fileName},
- #{description},
- #{error},
- #{fcu},
- NOW(),
- #{lcu},
- NOW()
- )
- ON DUPLICATE KEY UPDATE
- `is_active` = #{isActive},
- `class_name` = #{className},
- `file_id` = #{fileId},
- `file_name` = #{fileName},
- `description` = #{description},
- `error` = #{error},
- `lcu` = #{lcu},
- `lcd` = NOW()
-
-
-
- DELETE FROM `dynamic_plugin` WHERE `id` = #{value}
-
-
\ No newline at end of file
diff --git a/src/main/java/neatlogic/module/framework/dynamicplugin/service/DynamicPluginService.java b/src/main/java/neatlogic/module/framework/dynamicplugin/service/DynamicPluginService.java
deleted file mode 100644
index 12fced959..000000000
--- a/src/main/java/neatlogic/module/framework/dynamicplugin/service/DynamicPluginService.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package neatlogic.module.framework.dynamicplugin.service;
-
-import neatlogic.framework.common.dto.BasePageVo;
-import neatlogic.framework.dynamicplugin.dto.DynamicPluginVo;
-
-import java.util.List;
-
-public interface DynamicPluginService {
-
- List searchDynamicPluginList(BasePageVo search);
-}
diff --git a/src/main/java/neatlogic/module/framework/dynamicplugin/service/DynamicPluginServiceImpl.java b/src/main/java/neatlogic/module/framework/dynamicplugin/service/DynamicPluginServiceImpl.java
deleted file mode 100644
index b95f338ea..000000000
--- a/src/main/java/neatlogic/module/framework/dynamicplugin/service/DynamicPluginServiceImpl.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package neatlogic.module.framework.dynamicplugin.service;
-
-import neatlogic.framework.common.dto.BasePageVo;
-import neatlogic.framework.dynamicplugin.crossover.IDynamicPluginCrossoverService;
-import neatlogic.framework.dynamicplugin.dto.DynamicPluginVo;
-import neatlogic.module.framework.dao.mapper.dynamicplugin.DynamicPluginMapper;
-import org.apache.commons.collections4.CollectionUtils;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-
-@Service
-public class DynamicPluginServiceImpl implements DynamicPluginService, IDynamicPluginCrossoverService {
-
- @Resource
- private DynamicPluginMapper dynamicPluginMapper;
-
- @Override
- public List searchDynamicPluginList(BasePageVo search) {
- List tbodyList = dynamicPluginMapper.searchDynamicPluginList(search);
- if (Objects.equals(search.getRowNum(), 0) && (CollectionUtils.isNotEmpty(tbodyList) || search.getCurrentPage() > 1)) {
- int rowNum = dynamicPluginMapper.getDynamicPluginCount(search);
- if (rowNum == 0) {
- return new ArrayList<>();
- }
- search.setRowNum(rowNum);
- }
- return tbodyList;
- }
-}
diff --git a/src/main/java/neatlogic/module/framework/dynamicplugin/startup/LoadDynamicPluginStartupHandler.java b/src/main/java/neatlogic/module/framework/dynamicplugin/startup/LoadDynamicPluginStartupHandler.java
deleted file mode 100644
index 1db95e8f4..000000000
--- a/src/main/java/neatlogic/module/framework/dynamicplugin/startup/LoadDynamicPluginStartupHandler.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package neatlogic.module.framework.dynamicplugin.startup;
-
-import neatlogic.framework.common.dto.BasePageVo;
-import neatlogic.framework.dynamicplugin.DynamicPluginManager;
-import neatlogic.framework.dynamicplugin.dto.DynamicPluginVo;
-import neatlogic.framework.exception.file.FileNotFoundException;
-import neatlogic.framework.file.dao.mapper.FileMapper;
-import neatlogic.framework.file.dto.FileVo;
-import neatlogic.framework.startup.StartupBase;
-import neatlogic.module.framework.dao.mapper.dynamicplugin.DynamicPluginMapper;
-import neatlogic.module.framework.dynamicplugin.service.DynamicPluginService;
-import org.apache.commons.collections4.CollectionUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-@Component
-public class LoadDynamicPluginStartupHandler extends StartupBase {
-
- private Logger logger = LoggerFactory.getLogger(LoadDynamicPluginStartupHandler.class);
- @Resource
- private DynamicPluginService dynamicPluginService;
-
- @Resource
- private DynamicPluginMapper dynamicPluginMapper;
-
- @Resource
- private FileMapper fileMapper;
-
- @Override
- public String getName() {
- return "";
- }
-
- @Override
- public int executeForAllTenant() {
- List allDynamicPluginList = new ArrayList<>();
- int currentPage = 1;
- int pageSize = 100;
- BasePageVo search = new BasePageVo();
- search.setPageSize(pageSize);
- do {
- search.setCurrentPage(currentPage);
- List dynamicPluginList = dynamicPluginService.searchDynamicPluginList(search);
- allDynamicPluginList.addAll(dynamicPluginList);
- currentPage++;
- } while(currentPage > search.getPageCount());
-
- Map fileMap = new HashMap<>();
- if (CollectionUtils.isNotEmpty(allDynamicPluginList)) {
- List fileIdList = allDynamicPluginList.stream().map(DynamicPluginVo::getFileId).collect(Collectors.toList());
- List fileList = fileMapper.getFileListByIdList(fileIdList);
- fileList.stream().collect(Collectors.toMap(e -> e.getId(), e -> e));
- }
- List needUpdateDynamicPluginList = new ArrayList<>();
- for (DynamicPluginVo dynamicPluginVo : allDynamicPluginList) {
- try {
- FileVo fileVo = fileMap.get(dynamicPluginVo.getFileId());
- if (fileVo == null) {
- throw new FileNotFoundException(dynamicPluginVo.getFileId());
- }
- Class> aClass = DynamicPluginManager.getClassByFileId(fileVo.getId());
- if (aClass == null) {
- DynamicPluginManager.loadPlugin(fileVo);
- }
- } catch (Exception e) {
- dynamicPluginVo.setIsActive(0);
- dynamicPluginVo.setError(e.getMessage());
- needUpdateDynamicPluginList.add(dynamicPluginVo);
- logger.error(e.getMessage(), e);
- }
- }
- if (CollectionUtils.isNotEmpty(needUpdateDynamicPluginList)) {
- for (DynamicPluginVo dynamicPluginVo : needUpdateDynamicPluginList) {
- dynamicPluginMapper.insertDynamicPlugin(dynamicPluginVo);
- }
- }
- return 1;
- }
-
- @Override
- public int sort() {
- return 12;
- }
-}
--
Gitee