diff --git a/src/main/java/neatlogic/module/tenant/api/database/DeleteDataBaseApi.java b/src/main/java/neatlogic/module/tenant/api/database/DeleteDataBaseApi.java
new file mode 100644
index 0000000000000000000000000000000000000000..d65e666e38936d6f9490cb0a32270376a236d02a
--- /dev/null
+++ b/src/main/java/neatlogic/module/tenant/api/database/DeleteDataBaseApi.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2025 深圳极向量科技有限公司 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.database;
+
+import com.alibaba.fastjson.JSONObject;
+import neatlogic.framework.auth.core.AuthAction;
+import neatlogic.framework.auth.label.DATA_WAREHOUSE_MODIFY;
+import neatlogic.framework.common.constvalue.ApiParamType;
+import neatlogic.framework.datawarehouse.dao.mapper.DatabaseMapper;
+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;
+
+@Service
+@AuthAction(action = DATA_WAREHOUSE_MODIFY.class)
+@OperationType(type = OperationTypeEnum.OPERATE)
+public class DeleteDataBaseApi extends PrivateApiComponentBase {
+
+ @Resource
+ private DatabaseMapper databaseMapper;
+
+ @Override
+ public String getName() {
+ return "nmtad.deletedatabaseapi.getname";
+ }
+
+ @Input({
+ @Param(name = "id", type = ApiParamType.LONG, isRequired = true, desc = "common.id")
+ })
+ @Output({})
+ @Description(desc = "nmtad.deletedatabaseapi.getname")
+ @Override
+ public Object myDoService(JSONObject paramObj) throws Exception {
+ Long id = paramObj.getLong("id");
+ return databaseMapper.deleteDataBaseById(id);
+ }
+
+ @Override
+ public String getToken() {
+ return "database/delete";
+ }
+}
diff --git a/src/main/java/neatlogic/module/tenant/api/database/GetDataBaseApi.java b/src/main/java/neatlogic/module/tenant/api/database/GetDataBaseApi.java
new file mode 100644
index 0000000000000000000000000000000000000000..ee44bd47d68aa84579fe561ea5023d0735bb2910
--- /dev/null
+++ b/src/main/java/neatlogic/module/tenant/api/database/GetDataBaseApi.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2025 深圳极向量科技有限公司 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.database;
+
+import com.alibaba.fastjson.JSONObject;
+import neatlogic.framework.auth.core.AuthAction;
+import neatlogic.framework.auth.label.DATA_WAREHOUSE_MODIFY;
+import neatlogic.framework.common.constvalue.ApiParamType;
+import neatlogic.framework.datawarehouse.dao.mapper.DatabaseMapper;
+import neatlogic.framework.datawarehouse.dto.DatabaseVo;
+import neatlogic.framework.datawarehouse.exceptions.DatabaseNotFoundException;
+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.apache.commons.collections4.CollectionUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+@AuthAction(action = DATA_WAREHOUSE_MODIFY.class)
+@OperationType(type = OperationTypeEnum.OPERATE)
+public class GetDataBaseApi extends PrivateApiComponentBase {
+
+ @Resource
+ private DatabaseMapper databaseMapper;
+
+ @Resource
+ private FileMapper fileMapper;
+
+ @Override
+ public String getName() {
+ return "nmtad.getdatabaseapi.getname";
+ }
+
+ @Input({
+ @Param(name = "id", type = ApiParamType.LONG, isRequired = true, desc = "common.id")
+ })
+ @Output({
+ @Param(explode = DatabaseVo.class, desc = "common.tbodylist")
+ })
+ @Description(desc = "nmtad.getdatabaseapi.getname")
+ @Override
+ public Object myDoService(JSONObject paramObj) throws Exception {
+ Long id = paramObj.getLong("id");
+ DatabaseVo databaseVo = databaseMapper.getDataBaseById(id);
+ if (databaseVo == null) {
+ throw new DatabaseNotFoundException(id);
+ }
+ List fileIdList = databaseVo.getFileIdList();
+ if (CollectionUtils.isNotEmpty(fileIdList)) {
+ List fileList = fileMapper.getFileListByIdList(fileIdList);
+ databaseVo.setFileList(fileList);
+ } else {
+ databaseVo.setFileList(new ArrayList<>());
+ }
+ return databaseVo;
+ }
+
+ @Override
+ public String getToken() {
+ return "database/get";
+ }
+}
diff --git a/src/main/java/neatlogic/module/tenant/api/database/SavaDataBaseApi.java b/src/main/java/neatlogic/module/tenant/api/database/SavaDataBaseApi.java
new file mode 100644
index 0000000000000000000000000000000000000000..df9775e1e558060160d743a5d68ed37391f7aa1a
--- /dev/null
+++ b/src/main/java/neatlogic/module/tenant/api/database/SavaDataBaseApi.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2025 深圳极向量科技有限公司 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.database;
+
+import com.alibaba.fastjson.JSONObject;
+import neatlogic.framework.auth.core.AuthAction;
+import neatlogic.framework.auth.label.DATA_WAREHOUSE_MODIFY;
+import neatlogic.framework.common.constvalue.ApiParamType;
+import neatlogic.framework.datawarehouse.dao.mapper.DatabaseMapper;
+import neatlogic.framework.datawarehouse.dto.DatabaseVo;
+import neatlogic.framework.datawarehouse.exceptions.DatabaseNameRepeatException;
+import neatlogic.framework.dto.FieldValidResultVo;
+import neatlogic.framework.restful.annotation.*;
+import neatlogic.framework.restful.constvalue.OperationTypeEnum;
+import neatlogic.framework.restful.core.IValid;
+import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase;
+import neatlogic.framework.util.SnowflakeUtil;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+
+@Service
+@AuthAction(action = DATA_WAREHOUSE_MODIFY.class)
+@OperationType(type = OperationTypeEnum.OPERATE)
+@Transactional
+public class SavaDataBaseApi extends PrivateApiComponentBase {
+
+ @Resource
+ private DatabaseMapper databaseMapper;
+
+ @Override
+ public String getName() {
+ return "nmtad.savadatabaseapi.getname";
+ }
+
+ @Input({
+ @Param(name = "id", type = ApiParamType.LONG, desc = "common.id"),
+ @Param(name = "name", type = ApiParamType.STRING, isRequired = true, desc = "common.name"),
+ @Param(name = "type", type = ApiParamType.STRING, isRequired = true, desc = "common.type"),
+ @Param(name = "config", type = ApiParamType.JSONOBJECT, isRequired = true, desc = "common.config"),
+ @Param(name = "fileIdList", type = ApiParamType.JSONARRAY, isRequired = true, desc = "common.fileidlist"),
+ })
+ @Output({
+ @Param(name = "id", type = ApiParamType.LONG, isRequired = true, desc = "common.id")
+ })
+ @Description(desc = "nmtad.savadatabaseapi.getname")
+ @Override
+ public Object myDoService(JSONObject paramObj) throws Exception {
+ DatabaseVo dataBaseVo = paramObj.toJavaObject(DatabaseVo.class);
+ Long id = paramObj.getLong("id");
+ if (id == null) {
+ dataBaseVo.setId(SnowflakeUtil.uniqueLong());
+ }
+ databaseMapper.insertDataBase(dataBaseVo);
+ JSONObject resultObj = new JSONObject();
+ resultObj.put("id", dataBaseVo.getId());
+ return resultObj;
+ }
+
+ @Override
+ public String getToken() {
+ return "database/save";
+ }
+
+ public IValid name() {
+ return paramObj -> {
+ DatabaseVo dataBaseVo = paramObj.toJavaObject(DatabaseVo.class);
+ int count = databaseMapper.checkDatabaseNameIsRepeat(dataBaseVo);
+ if (count > 0) {
+ return new FieldValidResultVo(new DatabaseNameRepeatException(dataBaseVo.getName()));
+ }
+ return new FieldValidResultVo();
+ };
+ }
+}
diff --git a/src/main/java/neatlogic/module/tenant/api/database/SearchDataBaseApi.java b/src/main/java/neatlogic/module/tenant/api/database/SearchDataBaseApi.java
new file mode 100644
index 0000000000000000000000000000000000000000..958c97c4e66d54c8d01ccd7c46c029f5a01bbbde
--- /dev/null
+++ b/src/main/java/neatlogic/module/tenant/api/database/SearchDataBaseApi.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2025 深圳极向量科技有限公司 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.database;
+
+import com.alibaba.fastjson.JSONObject;
+import neatlogic.framework.auth.core.AuthAction;
+import neatlogic.framework.auth.label.DATA_WAREHOUSE_MODIFY;
+import neatlogic.framework.common.constvalue.ApiParamType;
+import neatlogic.framework.common.dto.BasePageVo;
+import neatlogic.framework.datawarehouse.dao.mapper.DatabaseMapper;
+import neatlogic.framework.datawarehouse.dto.DatabaseVo;
+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.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+@AuthAction(action = DATA_WAREHOUSE_MODIFY.class)
+@OperationType(type = OperationTypeEnum.OPERATE)
+public class SearchDataBaseApi extends PrivateApiComponentBase {
+
+ @Resource
+ private DatabaseMapper databaseMapper;
+
+ @Override
+ public String getName() {
+ return "nmtad.searchdatabaseapi.getname";
+ }
+
+ @Input({
+ @Param(name = "keyword", type = ApiParamType.STRING, desc = "common.keyword"),
+ @Param(name = "type", type = ApiParamType.STRING, desc = "common.type"),
+ @Param(name = "currentPage", type = ApiParamType.INTEGER, desc = "common.currentpage"),
+ @Param(name = "pageSize", type = ApiParamType.INTEGER, desc = "common.pagesize"),
+ })
+ @Output({
+ @Param(name = "tbodyList", explode = DatabaseVo[].class, desc = "common.tbodylist"),
+ @Param(explode = BasePageVo.class)
+ })
+ @Description(desc = "nmtad.searchdatabaseapi.getname")
+ @Override
+ public Object myDoService(JSONObject paramObj) throws Exception {
+ DatabaseVo searchVo = paramObj.toJavaObject(DatabaseVo.class);
+ List tbodyList = new ArrayList<>();
+ int rowNum = databaseMapper.getDataBaseCount(searchVo);
+ if (rowNum > 0) {
+ searchVo.setRowNum(rowNum);
+ tbodyList = databaseMapper.getDataBaseList(searchVo);
+ }
+ return TableResultUtil.getResult(tbodyList, searchVo);
+ }
+
+ @Override
+ public String getToken() {
+ return "database/search";
+ }
+}
diff --git a/src/main/java/neatlogic/module/tenant/api/database/TestDataBaseApi.java b/src/main/java/neatlogic/module/tenant/api/database/TestDataBaseApi.java
new file mode 100644
index 0000000000000000000000000000000000000000..e254d47a819007dc6ef46885718b6600f218518a
--- /dev/null
+++ b/src/main/java/neatlogic/module/tenant/api/database/TestDataBaseApi.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2025 深圳极向量科技有限公司 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.database;
+
+import com.alibaba.fastjson.JSONObject;
+import neatlogic.framework.auth.core.AuthAction;
+import neatlogic.framework.auth.label.DATA_WAREHOUSE_MODIFY;
+import neatlogic.framework.common.constvalue.ApiParamType;
+import neatlogic.framework.datawarehouse.dto.DatabaseVo;
+import neatlogic.framework.datawarehouse.service.DatabaseService;
+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.net.URLClassLoader;
+import java.sql.Connection;
+
+@Service
+@AuthAction(action = DATA_WAREHOUSE_MODIFY.class)
+@OperationType(type = OperationTypeEnum.OPERATE)
+public class TestDataBaseApi extends PrivateApiComponentBase {
+
+ @Resource
+ private DatabaseService databaseService;
+
+ @Override
+ public String getName() {
+ return "nmtad.testdatabaseapi.getname";
+ }
+
+ @Input({
+ @Param(name = "id", type = ApiParamType.LONG, isRequired = true, desc = "common.id")
+ })
+ @Output({
+ @Param(explode = DatabaseVo.class, desc = "common.tbodylist")
+ })
+ @Description(desc = "nmtad.testdatabaseapi.getname")
+ @Override
+ public Object myDoService(JSONObject paramObj) throws Exception {
+ Long id = paramObj.getLong("id");
+ Connection conn = databaseService.getConnectionByDatabaseId(id);
+ if (conn != null) {
+ ClassLoader classLoader = conn.getClass().getClassLoader();
+ conn.close();
+ if (classLoader instanceof URLClassLoader) {
+ ((URLClassLoader) classLoader).close();
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public String getToken() {
+ return "database/test";
+ }
+}
diff --git a/src/main/java/neatlogic/module/tenant/api/datawarehouse/SaveDataSourceApi.java b/src/main/java/neatlogic/module/tenant/api/datawarehouse/SaveDataSourceApi.java
index c982c946ab320b72905b056b80c275548f5b2999..24a3bf087d923337307b45780e59f7ecb0f845d1 100644
--- a/src/main/java/neatlogic/module/tenant/api/datawarehouse/SaveDataSourceApi.java
+++ b/src/main/java/neatlogic/module/tenant/api/datawarehouse/SaveDataSourceApi.java
@@ -75,7 +75,9 @@ public class SaveDataSourceApi extends PrivateApiComponentBase {
@Param(name = "expireCount", type = ApiParamType.INTEGER, desc = "有效期时间"),
@Param(name = "expireUnit", type = ApiParamType.ENUM, rule = "minute,hour,day", desc = "有效期单位"),
@Param(name = "expireUnit", type = ApiParamType.ENUM, rule = "minute,hour,day", desc = "有效期单位"),
- @Param(name = "dbType", type = ApiParamType.STRING, isRequired = true, desc = "数据库类型")})
+ @Param(name = "dbType", type = ApiParamType.STRING, isRequired = true, desc = "数据库类型"),
+ @Param(name = "databaseId", type = ApiParamType.LONG, desc = "数据库Id")
+ })
@Description(desc = "保存数据仓库数据源接口")
@Override
public Object myDoService(JSONObject jsonObj) throws Exception {