From 34768211b5f251d005305a29350bedd0c9809851 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Mon, 3 Jun 2024 14:29:25 +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/DeleteDynamicPluginApi.java | 55 ++++++++++++ .../dynamicplugin/GetDynamicPluginApi.java | 57 ++++++++++++ .../dynamicplugin/ListDynamicPluginApi.java | 76 ++++++++++++++++ .../api/dynamicplugin/PluginLoadTestApi.java | 70 +++++++++++++++ .../dynamicplugin/SaveDynamicPluginApi.java | 90 +++++++++++++++++++ 5 files changed, 348 insertions(+) create mode 100644 src/main/java/neatlogic/module/tenant/api/dynamicplugin/DeleteDynamicPluginApi.java create mode 100644 src/main/java/neatlogic/module/tenant/api/dynamicplugin/GetDynamicPluginApi.java create mode 100644 src/main/java/neatlogic/module/tenant/api/dynamicplugin/ListDynamicPluginApi.java create mode 100644 src/main/java/neatlogic/module/tenant/api/dynamicplugin/PluginLoadTestApi.java create mode 100644 src/main/java/neatlogic/module/tenant/api/dynamicplugin/SaveDynamicPluginApi.java diff --git a/src/main/java/neatlogic/module/tenant/api/dynamicplugin/DeleteDynamicPluginApi.java b/src/main/java/neatlogic/module/tenant/api/dynamicplugin/DeleteDynamicPluginApi.java new file mode 100644 index 00000000..add98d87 --- /dev/null +++ b/src/main/java/neatlogic/module/tenant/api/dynamicplugin/DeleteDynamicPluginApi.java @@ -0,0 +1,55 @@ +/* + * 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.tenant.api.dynamicplugin; + +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.common.constvalue.ApiParamType; +import neatlogic.framework.crossover.CrossoverServiceFactory; +import neatlogic.framework.dynamicplugin.crossover.IDynamicPluginCrossoverMapper; +import neatlogic.framework.restful.annotation.*; +import neatlogic.framework.restful.constvalue.OperationTypeEnum; +import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; +import org.springframework.stereotype.Service; + +@Service +@OperationType(type = OperationTypeEnum.DELETE) +public class DeleteDynamicPluginApi extends PrivateApiComponentBase { + + @Override + public String getName() { + return "删除动态插件"; + } + + @Input({ + @Param(name = "id", type = ApiParamType.LONG, isRequired = true, desc = "common.id") + }) + @Output({}) + @Description(desc = "删除动态插件") + @Override + public Object myDoService(JSONObject paramObj) throws Exception { + Long id = paramObj.getLong("id"); + IDynamicPluginCrossoverMapper dynamicPluginCrossoverMapper = CrossoverServiceFactory.getApi(IDynamicPluginCrossoverMapper.class); + dynamicPluginCrossoverMapper.deleteDynamicPluginById(id); + return null; + } + + @Override + public String getToken() { + return "dynamicplugin/delete"; + } +} diff --git a/src/main/java/neatlogic/module/tenant/api/dynamicplugin/GetDynamicPluginApi.java b/src/main/java/neatlogic/module/tenant/api/dynamicplugin/GetDynamicPluginApi.java new file mode 100644 index 00000000..fd92cd42 --- /dev/null +++ b/src/main/java/neatlogic/module/tenant/api/dynamicplugin/GetDynamicPluginApi.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.module.tenant.api.dynamicplugin; + +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.common.constvalue.ApiParamType; +import neatlogic.framework.crossover.CrossoverServiceFactory; +import neatlogic.framework.dynamicplugin.crossover.IDynamicPluginCrossoverMapper; +import neatlogic.framework.dynamicplugin.dto.DynamicPluginVo; +import neatlogic.framework.restful.annotation.*; +import neatlogic.framework.restful.constvalue.OperationTypeEnum; +import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; +import org.springframework.stereotype.Service; + +@Service +@OperationType(type = OperationTypeEnum.SEARCH) +public class GetDynamicPluginApi extends PrivateApiComponentBase { + + @Override + public String getName() { + return "获取动态插件"; + } + + @Input({ + @Param(name = "id", type = ApiParamType.LONG, isRequired = true, desc = "common.id") + }) + @Output({ + @Param(explode = DynamicPluginVo.class, desc = "common.tbodylist") + }) + @Description(desc = "获取动态插件") + @Override + public Object myDoService(JSONObject paramObj) throws Exception { + Long id = paramObj.getLong("id"); + IDynamicPluginCrossoverMapper dynamicPluginCrossoverMapper = CrossoverServiceFactory.getApi(IDynamicPluginCrossoverMapper.class); + return dynamicPluginCrossoverMapper.getDynamicPluginById(id); + } + + @Override + public String getToken() { + return "dynamicplugin/get"; + } +} diff --git a/src/main/java/neatlogic/module/tenant/api/dynamicplugin/ListDynamicPluginApi.java b/src/main/java/neatlogic/module/tenant/api/dynamicplugin/ListDynamicPluginApi.java new file mode 100644 index 00000000..968aac4f --- /dev/null +++ b/src/main/java/neatlogic/module/tenant/api/dynamicplugin/ListDynamicPluginApi.java @@ -0,0 +1,76 @@ +/* + * 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.tenant.api.dynamicplugin; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.common.constvalue.ApiParamType; +import neatlogic.framework.common.dto.BasePageVo; +import neatlogic.framework.crossover.CrossoverServiceFactory; +import neatlogic.framework.dynamicplugin.crossover.IDynamicPluginCrossoverMapper; +import neatlogic.framework.dynamicplugin.crossover.IDynamicPluginCrossoverService; +import neatlogic.framework.dynamicplugin.dto.DynamicPluginVo; +import neatlogic.framework.restful.annotation.*; +import neatlogic.framework.restful.constvalue.OperationTypeEnum; +import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; +import neatlogic.framework.util.TableResultUtil; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +@OperationType(type = OperationTypeEnum.SEARCH) +public class ListDynamicPluginApi extends PrivateApiComponentBase { + + @Override + public String getName() { + return "获取动态插件列表"; + } + + @Input({ + @Param(name = "keyword", type = ApiParamType.STRING, xss = true, desc = "common.keyword"), + @Param(name = "defaultValue", type = ApiParamType.JSONARRAY, desc = "common.defaultvalue"), + @Param(name = "currentPage", type = ApiParamType.INTEGER, desc = "common.currentpage"), + @Param(name = "pageSize", type = ApiParamType.INTEGER, desc = "common.pagesize") + }) + @Output({ + @Param(explode = BasePageVo.class), + @Param(name = "tbodyList", explode = DynamicPluginVo[].class, desc = "common.tbodylist") + }) + @Description(desc = "获取动态插件") + @Override + public Object myDoService(JSONObject paramObj) throws Exception { + IDynamicPluginCrossoverMapper dynamicPluginCrossoverMapper = CrossoverServiceFactory.getApi(IDynamicPluginCrossoverMapper.class); + BasePageVo search = paramObj.toJavaObject(BasePageVo.class); + JSONArray defaultValue = search.getDefaultValue(); + if (CollectionUtils.isNotEmpty(defaultValue)) { + List idList = defaultValue.toJavaList(Long.class); + List tbodyList = dynamicPluginCrossoverMapper.getDynamicPluginListByIdList(idList); + return TableResultUtil.getResult(tbodyList); + } + IDynamicPluginCrossoverService dynamicPluginCrossoverService = CrossoverServiceFactory.getApi(IDynamicPluginCrossoverService.class); + List tbodyList = dynamicPluginCrossoverService.searchDynamicPluginList(search); + return TableResultUtil.getResult(tbodyList, search); + } + + @Override + public String getToken() { + return "dynamicplugin/list"; + } +} diff --git a/src/main/java/neatlogic/module/tenant/api/dynamicplugin/PluginLoadTestApi.java b/src/main/java/neatlogic/module/tenant/api/dynamicplugin/PluginLoadTestApi.java new file mode 100644 index 00000000..74cedec3 --- /dev/null +++ b/src/main/java/neatlogic/module/tenant/api/dynamicplugin/PluginLoadTestApi.java @@ -0,0 +1,70 @@ +/* + * 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.tenant.api.dynamicplugin; + +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.dynamicplugin.PluginClassLoader; +import neatlogic.framework.common.constvalue.ApiParamType; +import neatlogic.framework.file.dao.mapper.FileMapper; +import neatlogic.framework.file.dto.FileVo; +import neatlogic.framework.restful.annotation.*; +import neatlogic.framework.restful.constvalue.OperationTypeEnum; +import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.lang.reflect.Method; + +@Service + +@OperationType(type = OperationTypeEnum.SEARCH) +public class PluginLoadTestApi extends PrivateApiComponentBase { + + @Autowired + private FileMapper fileMapper; + + @Override + public String getName() { + return "测试加载插件"; + } + + @Input({ + @Param(name = "fileId", type = ApiParamType.LONG, desc = ""), + }) + @Output({ + + }) + @Description(desc = "测试加载插件") + @Override + public Object myDoService(JSONObject paramObj) throws Exception { + Long fileId = paramObj.getLong("fileId"); + FileVo file = fileMapper.getFileById(fileId); + String path = file.getPath(); + PluginClassLoader pluginClassLoader = new PluginClassLoader(PluginLoadTestApi.class.getClassLoader()); + Class aClass = pluginClassLoader.loadClass(path); + Object helloWorld = aClass.newInstance(); + Method welcomeMethod = aClass.getMethod("welcome"); + String result = (String) welcomeMethod.invoke(helloWorld); + return result; + } + + @Override + public String getToken() { + return "plugin/load/test"; + } +} diff --git a/src/main/java/neatlogic/module/tenant/api/dynamicplugin/SaveDynamicPluginApi.java b/src/main/java/neatlogic/module/tenant/api/dynamicplugin/SaveDynamicPluginApi.java new file mode 100644 index 00000000..a03a8309 --- /dev/null +++ b/src/main/java/neatlogic/module/tenant/api/dynamicplugin/SaveDynamicPluginApi.java @@ -0,0 +1,90 @@ +/* + * 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.tenant.api.dynamicplugin; + +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.asynchronization.threadlocal.UserContext; +import neatlogic.framework.common.constvalue.ApiParamType; +import neatlogic.framework.crossover.CrossoverServiceFactory; +import neatlogic.framework.dynamicplugin.DynamicPluginManager; +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 neatlogic.framework.restful.annotation.*; +import neatlogic.framework.restful.constvalue.OperationTypeEnum; +import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Objects; + +@Service +@OperationType(type = OperationTypeEnum.UPDATE) +public class SaveDynamicPluginApi extends PrivateApiComponentBase { + + @Resource + private FileMapper fileMapper; + + + + @Override + public String getName() { + return "保存动态插件"; + } + @Input({ + @Param(name = "id", type = ApiParamType.LONG, desc = "common.id"), + @Param(name = "key", type = ApiParamType.STRING, isRequired = true, desc = "common.key"), + @Param(name = "name", type = ApiParamType.STRING, isRequired = true, desc = "common.name"), + @Param(name = "type", type = ApiParamType.STRING, isRequired = true, desc = "common.type"), + @Param(name = "fileId", type = ApiParamType.LONG, isRequired = true, desc = "common.fileid"), + @Param(name = "description", type = ApiParamType.STRING, desc = "common.description") + }) + @Output({ + @Param(name = "id", type = ApiParamType.LONG, isRequired = true, desc = "common.id") + }) + @Description(desc = "保存动态插件") + @Override + public Object myDoService(JSONObject paramObj) throws Exception { + DynamicPluginVo dynamicPlugin = paramObj.toJavaObject(DynamicPluginVo.class); + + FileVo fileVo = fileMapper.getFileById(dynamicPlugin.getFileId()); + if (fileVo == null) { + throw new FileNotFoundException(dynamicPlugin.getFileId()); + } + if (Objects.equals(fileVo.getType(), "dynamicPlugin")) { + + } + Class aClass = DynamicPluginManager.loadPlugin(fileVo); + dynamicPlugin.setClassName(aClass.getName()); + dynamicPlugin.setFileName(fileVo.getName()); + dynamicPlugin.setFcu(UserContext.get().getUserId()); + dynamicPlugin.setLcu(UserContext.get().getUserId()); + IDynamicPluginCrossoverMapper dynamicPluginCrossoverMapper = CrossoverServiceFactory.getApi(IDynamicPluginCrossoverMapper.class); + dynamicPluginCrossoverMapper.insertDynamicPlugin(dynamicPlugin); + JSONObject resultObj = new JSONObject(); + resultObj.put("id", dynamicPlugin.getId()); + return resultObj; + } + + @Override + public String getToken() { + return "dynamicplugin/save"; + } +} -- Gitee From 0cac0d49a3c23cb2b6860ae7b154399e4d502103 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Wed, 5 Jun 2024 14:23:36 +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/DeleteDynamicPluginApi.java | 55 ------------ .../dynamicplugin/GetDynamicPluginApi.java | 57 ------------ .../dynamicplugin/ListDynamicPluginApi.java | 76 ---------------- .../api/dynamicplugin/PluginLoadTestApi.java | 70 --------------- .../dynamicplugin/SaveDynamicPluginApi.java | 90 ------------------- 5 files changed, 348 deletions(-) delete mode 100644 src/main/java/neatlogic/module/tenant/api/dynamicplugin/DeleteDynamicPluginApi.java delete mode 100644 src/main/java/neatlogic/module/tenant/api/dynamicplugin/GetDynamicPluginApi.java delete mode 100644 src/main/java/neatlogic/module/tenant/api/dynamicplugin/ListDynamicPluginApi.java delete mode 100644 src/main/java/neatlogic/module/tenant/api/dynamicplugin/PluginLoadTestApi.java delete mode 100644 src/main/java/neatlogic/module/tenant/api/dynamicplugin/SaveDynamicPluginApi.java diff --git a/src/main/java/neatlogic/module/tenant/api/dynamicplugin/DeleteDynamicPluginApi.java b/src/main/java/neatlogic/module/tenant/api/dynamicplugin/DeleteDynamicPluginApi.java deleted file mode 100644 index add98d87..00000000 --- a/src/main/java/neatlogic/module/tenant/api/dynamicplugin/DeleteDynamicPluginApi.java +++ /dev/null @@ -1,55 +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.tenant.api.dynamicplugin; - -import com.alibaba.fastjson.JSONObject; -import neatlogic.framework.common.constvalue.ApiParamType; -import neatlogic.framework.crossover.CrossoverServiceFactory; -import neatlogic.framework.dynamicplugin.crossover.IDynamicPluginCrossoverMapper; -import neatlogic.framework.restful.annotation.*; -import neatlogic.framework.restful.constvalue.OperationTypeEnum; -import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; -import org.springframework.stereotype.Service; - -@Service -@OperationType(type = OperationTypeEnum.DELETE) -public class DeleteDynamicPluginApi extends PrivateApiComponentBase { - - @Override - public String getName() { - return "删除动态插件"; - } - - @Input({ - @Param(name = "id", type = ApiParamType.LONG, isRequired = true, desc = "common.id") - }) - @Output({}) - @Description(desc = "删除动态插件") - @Override - public Object myDoService(JSONObject paramObj) throws Exception { - Long id = paramObj.getLong("id"); - IDynamicPluginCrossoverMapper dynamicPluginCrossoverMapper = CrossoverServiceFactory.getApi(IDynamicPluginCrossoverMapper.class); - dynamicPluginCrossoverMapper.deleteDynamicPluginById(id); - return null; - } - - @Override - public String getToken() { - return "dynamicplugin/delete"; - } -} diff --git a/src/main/java/neatlogic/module/tenant/api/dynamicplugin/GetDynamicPluginApi.java b/src/main/java/neatlogic/module/tenant/api/dynamicplugin/GetDynamicPluginApi.java deleted file mode 100644 index fd92cd42..00000000 --- a/src/main/java/neatlogic/module/tenant/api/dynamicplugin/GetDynamicPluginApi.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.module.tenant.api.dynamicplugin; - -import com.alibaba.fastjson.JSONObject; -import neatlogic.framework.common.constvalue.ApiParamType; -import neatlogic.framework.crossover.CrossoverServiceFactory; -import neatlogic.framework.dynamicplugin.crossover.IDynamicPluginCrossoverMapper; -import neatlogic.framework.dynamicplugin.dto.DynamicPluginVo; -import neatlogic.framework.restful.annotation.*; -import neatlogic.framework.restful.constvalue.OperationTypeEnum; -import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; -import org.springframework.stereotype.Service; - -@Service -@OperationType(type = OperationTypeEnum.SEARCH) -public class GetDynamicPluginApi extends PrivateApiComponentBase { - - @Override - public String getName() { - return "获取动态插件"; - } - - @Input({ - @Param(name = "id", type = ApiParamType.LONG, isRequired = true, desc = "common.id") - }) - @Output({ - @Param(explode = DynamicPluginVo.class, desc = "common.tbodylist") - }) - @Description(desc = "获取动态插件") - @Override - public Object myDoService(JSONObject paramObj) throws Exception { - Long id = paramObj.getLong("id"); - IDynamicPluginCrossoverMapper dynamicPluginCrossoverMapper = CrossoverServiceFactory.getApi(IDynamicPluginCrossoverMapper.class); - return dynamicPluginCrossoverMapper.getDynamicPluginById(id); - } - - @Override - public String getToken() { - return "dynamicplugin/get"; - } -} diff --git a/src/main/java/neatlogic/module/tenant/api/dynamicplugin/ListDynamicPluginApi.java b/src/main/java/neatlogic/module/tenant/api/dynamicplugin/ListDynamicPluginApi.java deleted file mode 100644 index 968aac4f..00000000 --- a/src/main/java/neatlogic/module/tenant/api/dynamicplugin/ListDynamicPluginApi.java +++ /dev/null @@ -1,76 +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.tenant.api.dynamicplugin; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import neatlogic.framework.common.constvalue.ApiParamType; -import neatlogic.framework.common.dto.BasePageVo; -import neatlogic.framework.crossover.CrossoverServiceFactory; -import neatlogic.framework.dynamicplugin.crossover.IDynamicPluginCrossoverMapper; -import neatlogic.framework.dynamicplugin.crossover.IDynamicPluginCrossoverService; -import neatlogic.framework.dynamicplugin.dto.DynamicPluginVo; -import neatlogic.framework.restful.annotation.*; -import neatlogic.framework.restful.constvalue.OperationTypeEnum; -import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; -import neatlogic.framework.util.TableResultUtil; -import org.apache.commons.collections4.CollectionUtils; -import org.springframework.stereotype.Service; - -import java.util.List; - -@Service -@OperationType(type = OperationTypeEnum.SEARCH) -public class ListDynamicPluginApi extends PrivateApiComponentBase { - - @Override - public String getName() { - return "获取动态插件列表"; - } - - @Input({ - @Param(name = "keyword", type = ApiParamType.STRING, xss = true, desc = "common.keyword"), - @Param(name = "defaultValue", type = ApiParamType.JSONARRAY, desc = "common.defaultvalue"), - @Param(name = "currentPage", type = ApiParamType.INTEGER, desc = "common.currentpage"), - @Param(name = "pageSize", type = ApiParamType.INTEGER, desc = "common.pagesize") - }) - @Output({ - @Param(explode = BasePageVo.class), - @Param(name = "tbodyList", explode = DynamicPluginVo[].class, desc = "common.tbodylist") - }) - @Description(desc = "获取动态插件") - @Override - public Object myDoService(JSONObject paramObj) throws Exception { - IDynamicPluginCrossoverMapper dynamicPluginCrossoverMapper = CrossoverServiceFactory.getApi(IDynamicPluginCrossoverMapper.class); - BasePageVo search = paramObj.toJavaObject(BasePageVo.class); - JSONArray defaultValue = search.getDefaultValue(); - if (CollectionUtils.isNotEmpty(defaultValue)) { - List idList = defaultValue.toJavaList(Long.class); - List tbodyList = dynamicPluginCrossoverMapper.getDynamicPluginListByIdList(idList); - return TableResultUtil.getResult(tbodyList); - } - IDynamicPluginCrossoverService dynamicPluginCrossoverService = CrossoverServiceFactory.getApi(IDynamicPluginCrossoverService.class); - List tbodyList = dynamicPluginCrossoverService.searchDynamicPluginList(search); - return TableResultUtil.getResult(tbodyList, search); - } - - @Override - public String getToken() { - return "dynamicplugin/list"; - } -} diff --git a/src/main/java/neatlogic/module/tenant/api/dynamicplugin/PluginLoadTestApi.java b/src/main/java/neatlogic/module/tenant/api/dynamicplugin/PluginLoadTestApi.java deleted file mode 100644 index 74cedec3..00000000 --- a/src/main/java/neatlogic/module/tenant/api/dynamicplugin/PluginLoadTestApi.java +++ /dev/null @@ -1,70 +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.tenant.api.dynamicplugin; - -import com.alibaba.fastjson.JSONObject; -import neatlogic.framework.dynamicplugin.PluginClassLoader; -import neatlogic.framework.common.constvalue.ApiParamType; -import neatlogic.framework.file.dao.mapper.FileMapper; -import neatlogic.framework.file.dto.FileVo; -import neatlogic.framework.restful.annotation.*; -import neatlogic.framework.restful.constvalue.OperationTypeEnum; -import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.lang.reflect.Method; - -@Service - -@OperationType(type = OperationTypeEnum.SEARCH) -public class PluginLoadTestApi extends PrivateApiComponentBase { - - @Autowired - private FileMapper fileMapper; - - @Override - public String getName() { - return "测试加载插件"; - } - - @Input({ - @Param(name = "fileId", type = ApiParamType.LONG, desc = ""), - }) - @Output({ - - }) - @Description(desc = "测试加载插件") - @Override - public Object myDoService(JSONObject paramObj) throws Exception { - Long fileId = paramObj.getLong("fileId"); - FileVo file = fileMapper.getFileById(fileId); - String path = file.getPath(); - PluginClassLoader pluginClassLoader = new PluginClassLoader(PluginLoadTestApi.class.getClassLoader()); - Class aClass = pluginClassLoader.loadClass(path); - Object helloWorld = aClass.newInstance(); - Method welcomeMethod = aClass.getMethod("welcome"); - String result = (String) welcomeMethod.invoke(helloWorld); - return result; - } - - @Override - public String getToken() { - return "plugin/load/test"; - } -} diff --git a/src/main/java/neatlogic/module/tenant/api/dynamicplugin/SaveDynamicPluginApi.java b/src/main/java/neatlogic/module/tenant/api/dynamicplugin/SaveDynamicPluginApi.java deleted file mode 100644 index a03a8309..00000000 --- a/src/main/java/neatlogic/module/tenant/api/dynamicplugin/SaveDynamicPluginApi.java +++ /dev/null @@ -1,90 +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.tenant.api.dynamicplugin; - -import com.alibaba.fastjson.JSONObject; -import neatlogic.framework.asynchronization.threadlocal.UserContext; -import neatlogic.framework.common.constvalue.ApiParamType; -import neatlogic.framework.crossover.CrossoverServiceFactory; -import neatlogic.framework.dynamicplugin.DynamicPluginManager; -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 neatlogic.framework.restful.annotation.*; -import neatlogic.framework.restful.constvalue.OperationTypeEnum; -import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.util.Objects; - -@Service -@OperationType(type = OperationTypeEnum.UPDATE) -public class SaveDynamicPluginApi extends PrivateApiComponentBase { - - @Resource - private FileMapper fileMapper; - - - - @Override - public String getName() { - return "保存动态插件"; - } - @Input({ - @Param(name = "id", type = ApiParamType.LONG, desc = "common.id"), - @Param(name = "key", type = ApiParamType.STRING, isRequired = true, desc = "common.key"), - @Param(name = "name", type = ApiParamType.STRING, isRequired = true, desc = "common.name"), - @Param(name = "type", type = ApiParamType.STRING, isRequired = true, desc = "common.type"), - @Param(name = "fileId", type = ApiParamType.LONG, isRequired = true, desc = "common.fileid"), - @Param(name = "description", type = ApiParamType.STRING, desc = "common.description") - }) - @Output({ - @Param(name = "id", type = ApiParamType.LONG, isRequired = true, desc = "common.id") - }) - @Description(desc = "保存动态插件") - @Override - public Object myDoService(JSONObject paramObj) throws Exception { - DynamicPluginVo dynamicPlugin = paramObj.toJavaObject(DynamicPluginVo.class); - - FileVo fileVo = fileMapper.getFileById(dynamicPlugin.getFileId()); - if (fileVo == null) { - throw new FileNotFoundException(dynamicPlugin.getFileId()); - } - if (Objects.equals(fileVo.getType(), "dynamicPlugin")) { - - } - Class aClass = DynamicPluginManager.loadPlugin(fileVo); - dynamicPlugin.setClassName(aClass.getName()); - dynamicPlugin.setFileName(fileVo.getName()); - dynamicPlugin.setFcu(UserContext.get().getUserId()); - dynamicPlugin.setLcu(UserContext.get().getUserId()); - IDynamicPluginCrossoverMapper dynamicPluginCrossoverMapper = CrossoverServiceFactory.getApi(IDynamicPluginCrossoverMapper.class); - dynamicPluginCrossoverMapper.insertDynamicPlugin(dynamicPlugin); - JSONObject resultObj = new JSONObject(); - resultObj.put("id", dynamicPlugin.getId()); - return resultObj; - } - - @Override - public String getToken() { - return "dynamicplugin/save"; - } -} -- Gitee