diff --git a/.gitignore b/.gitignore
index 549e00a2a96fa9d7c5dbc9859664a78d980158c2..0adc7c7368a4b1ed588421ca8898bba614870b8c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
HELP.md
+.DS_Store
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
@@ -29,5 +30,7 @@ build/
!**/src/main/**/build/
!**/src/test/**/build/
+test/
+
### VS Code ###
.vscode/
diff --git a/README.md b/README.md
index 98254a893b63658dfb82fb86f6df4e13a1f99a73..c01d8699084f73e8bc1940a168fe9a7f059f8470 100644
--- a/README.md
+++ b/README.md
@@ -81,11 +81,14 @@ java -jar viewer-apis-service.jar --spring.config.location=application.yml
MIT License - 自由修改和商用,但需保留原始版权声明
## ☎ 联系我们
-- Email: your-email@example.com
-- GitHub Issues: https://github.com/your-repo/viewer/issues
+- 欢迎大家提需求和建议[【新建issuses】](https://gitee.com/ThoughtSet/Viewer/issues/new)!(详细描述你的原始需求,我们会帮你提供一些方案,节约大家的成本)
+- **内推项目** 如您觉得项目不错,可推荐到公司,建立长期稳定的商业合作,提供更专业的技术服务。
-## 分支命名规则
-- `feat/*`:新功能开发
-- `fix/*`:问题修复
-- `docs/*`:文档更新
+[//]: # (## 分支命名规则)
+
+[//]: # (- `feat/*`:新功能开发)
+
+[//]: # (- `fix/*`:问题修复)
+
+[//]: # (- `docs/*`:文档更新)
diff --git a/apis/pom.xml b/apis/pom.xml
index b7616825e7a682933a23cb34317190f85b98b5e3..6aa4cd7bc41ed61a44971fc713e47709cc0a8e5b 100644
--- a/apis/pom.xml
+++ b/apis/pom.xml
@@ -35,6 +35,11 @@
xyz.thoughtset.viewer
viewer-modules-ds-jdbc-self
+
+
+ xyz.thoughtset.viewer
+ viewer-modules-ds-http-simple
+
\ No newline at end of file
diff --git a/commons/viewer-common-connector/src/main/java/xyz/thoughtset/viewer/common/connector/entity/bo/Linker.java b/commons/viewer-common-connector/src/main/java/xyz/thoughtset/viewer/common/connector/entity/bo/Linker.java
index 5651e381b82b4c7a8b18f897f9f7b8c7cec9ffb9..16f9dd9fc7ea44c63c4e6f0a6d30c967998ba277 100644
--- a/commons/viewer-common-connector/src/main/java/xyz/thoughtset/viewer/common/connector/entity/bo/Linker.java
+++ b/commons/viewer-common-connector/src/main/java/xyz/thoughtset/viewer/common/connector/entity/bo/Linker.java
@@ -19,16 +19,17 @@ public class Linker {
protected String linkerType;
- public Linker(String title, String driverClassName, Map otherSettings, Boolean reactive) {
+ public Linker(String title, String driverClassName, Map otherSettings, Boolean reactive,String linkerType) {
this.id = title;
this.driverClassName = driverClassName;
this.otherSettings = otherSettings;
this.nativeDriver = Boolean.TRUE;
this.reactive = reactive;
+ this.linkerType = linkerType;
}
- public Linker(String title, String driverClassName) {
- this(title, driverClassName, null, false);
+ public Linker(String title, String driverClassName,String linkerType) {
+ this(title, driverClassName, null, false,linkerType);
}
}
diff --git a/commons/viewer-common-connector/src/main/java/xyz/thoughtset/viewer/common/connector/linker/ConnBuilder.java b/commons/viewer-common-connector/src/main/java/xyz/thoughtset/viewer/common/connector/linker/ConnBuilder.java
index 4881a5078e66d135de62eecabc430523338fea8b..549a065fe8634a02d69843a4ae8eba59219972df 100644
--- a/commons/viewer-common-connector/src/main/java/xyz/thoughtset/viewer/common/connector/linker/ConnBuilder.java
+++ b/commons/viewer-common-connector/src/main/java/xyz/thoughtset/viewer/common/connector/linker/ConnBuilder.java
@@ -18,5 +18,9 @@ public abstract class ConnBuilder {
public abstract Object buildConnect(ConnectorMeta connectorMeta, Properties properties);
+ public Object unloadConnect(ConnectorMeta connectorMeta, Properties properties) {
+ return null;
+ }
+
}
diff --git a/commons/viewer-common-connector/src/main/java/xyz/thoughtset/viewer/common/connector/linker/LinkerHelper.java b/commons/viewer-common-connector/src/main/java/xyz/thoughtset/viewer/common/connector/linker/LinkerHelper.java
index 68cc9a3df66276dac8391ad09cb1c4f8ffefb278..8b5819649926c10573a3e5021c072135b866be65 100644
--- a/commons/viewer-common-connector/src/main/java/xyz/thoughtset/viewer/common/connector/linker/LinkerHelper.java
+++ b/commons/viewer-common-connector/src/main/java/xyz/thoughtset/viewer/common/connector/linker/LinkerHelper.java
@@ -46,6 +46,14 @@ public class LinkerHelper{
return linkerTypeCache.get(linkId);
}
+ public static String getTarExecType(String linkId) {
+ if (!connectorCache.containsKey(linkId)) {
+ log.error("Linker not found for id: {}", linkId);
+ return null;
+ }
+ return connectorCache.get(linkId).dataLinker.getLinkerType();
+ }
+
public static void registerConn(ConnBuilder connBuilder) {
Linker linker = connBuilder.getDataLinker();
registerConnectorToCache(linker.getId(), connBuilder);
diff --git a/commons/viewer-common-core/src/main/java/xyz/thoughtset/viewer/common/core/constants/FolderNameConstant.java b/commons/viewer-common-core/src/main/java/xyz/thoughtset/viewer/common/core/constants/FolderNameConstant.java
index 4d4afeb9e1ccdcacef44fc2e7b699f7ab3e3b069..baf67d3fadd7c564f7324ea8cb9ad6b6bbf131f1 100644
--- a/commons/viewer-common-core/src/main/java/xyz/thoughtset/viewer/common/core/constants/FolderNameConstant.java
+++ b/commons/viewer-common-core/src/main/java/xyz/thoughtset/viewer/common/core/constants/FolderNameConstant.java
@@ -10,4 +10,8 @@ public class FolderNameConstant {
return folderName + File.separator + fileName;
}
+ public static String jarFileAllPath(String jarFilePath) {
+ return folderWithSep(FolderNameConstant.LINKER , jarFilePath);
+ }
+
}
diff --git a/commons/viewer-common-crud/viewer-common-crud-core/src/main/java/xyz/thoughtset/viewer/common/crud/core/service/BaseService.java b/commons/viewer-common-crud/viewer-common-crud-core/src/main/java/xyz/thoughtset/viewer/common/crud/core/service/BaseService.java
index bd27efb035d2945e404e9b879010b1ed95e4f7cf..cbf31e2be7a965d16bf6de504ee6557a4e3bd906 100644
--- a/commons/viewer-common-crud/viewer-common-crud-core/src/main/java/xyz/thoughtset/viewer/common/crud/core/service/BaseService.java
+++ b/commons/viewer-common-crud/viewer-common-crud-core/src/main/java/xyz/thoughtset/viewer/common/crud/core/service/BaseService.java
@@ -2,13 +2,15 @@ package xyz.thoughtset.viewer.common.crud.core.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
+import xyz.thoughtset.viewer.common.core.entity.IdMeta;
import java.util.LinkedHashMap;
import java.util.List;
-public interface BaseService extends IService {
+public interface BaseService extends IService {
public Object createData(LinkedHashMap baseMap);
+
public Object updateData(LinkedHashMap baseMap);
public Object saveData(LinkedHashMap baseMap);
diff --git a/commons/viewer-common-crud/viewer-common-crud-core/src/main/java/xyz/thoughtset/viewer/common/crud/core/service/BaseServiceImpl.java b/commons/viewer-common-crud/viewer-common-crud-core/src/main/java/xyz/thoughtset/viewer/common/crud/core/service/BaseServiceImpl.java
index 1662394dbfdda8fb77d537daaef6414cef3eed73..9825194ed43ab6c9106fc79198b46ba5054279c1 100644
--- a/commons/viewer-common-crud/viewer-common-crud-core/src/main/java/xyz/thoughtset/viewer/common/crud/core/service/BaseServiceImpl.java
+++ b/commons/viewer-common-crud/viewer-common-crud-core/src/main/java/xyz/thoughtset/viewer/common/crud/core/service/BaseServiceImpl.java
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import xyz.thoughtset.viewer.common.core.entity.IdMeta;
import xyz.thoughtset.viewer.common.crud.core.util.MPWrapperUtil;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.SneakyThrows;
@@ -13,7 +14,7 @@ import java.util.LinkedHashMap;
import java.util.List;
@SuppressWarnings({"unchecked","SpringJavaInjectionPointsAutowiringInspection"})
-public class BaseServiceImpl , T> extends ServiceImpl implements BaseService {
+public class BaseServiceImpl , T extends IdMeta> extends ServiceImpl implements BaseService {
@Autowired
protected ObjectMapper mapper;
diff --git a/executor/pom.xml b/executor/pom.xml
index 9c65edd8090eae40c28c52b606a0d261c30b86fa..1c8681a80cfba4e191537945c76560dca22158bc 100644
--- a/executor/pom.xml
+++ b/executor/pom.xml
@@ -12,7 +12,6 @@
executor
pom
- viewer-executor-mybatis
viewer-executor-core
@@ -24,10 +23,10 @@
-
- xyz.thoughtset.viewer
- viewer-modules-ds-core
-
+
+
+
+
\ No newline at end of file
diff --git a/executor/viewer-executor-core/pom.xml b/executor/viewer-executor-core/pom.xml
index 3acfa07a1c948721fa16659dd70243c126675217..530021f5d07e47b30b2f14fe8501c73dcbd33bde 100644
--- a/executor/viewer-executor-core/pom.xml
+++ b/executor/viewer-executor-core/pom.xml
@@ -16,5 +16,11 @@
17
UTF-8
+
+
+ xyz.thoughtset.viewer
+ viewer-common-crud-core
+
+
\ No newline at end of file
diff --git a/executor/viewer-executor-core/src/main/java/xyz/thoughtset/viewer/executor/core/base/AbstractExecutor.java b/executor/viewer-executor-core/src/main/java/xyz/thoughtset/viewer/executor/core/base/AbstractExecutor.java
index 20b1f1f9a29d19ff35030e7d68a3c8cfbd2efcb2..5be09b0d1604945cfb9487a38ba624465ddd3482 100644
--- a/executor/viewer-executor-core/src/main/java/xyz/thoughtset/viewer/executor/core/base/AbstractExecutor.java
+++ b/executor/viewer-executor-core/src/main/java/xyz/thoughtset/viewer/executor/core/base/AbstractExecutor.java
@@ -1,9 +1,10 @@
package xyz.thoughtset.viewer.executor.core.base;
+import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Getter;
+import org.springframework.beans.factory.annotation.Autowired;
import xyz.thoughtset.viewer.executor.core.entity.QueryBody;
import xyz.thoughtset.viewer.executor.core.factory.ExecutorRegistry;
-import xyz.thoughtset.viewer.executor.core.service.QueryBodyService;
import java.util.Map;
@@ -12,6 +13,10 @@ public abstract class AbstractExecutor {
protected final String supportType;
@Getter
protected final boolean innerExecutor;
+ @Autowired
+ protected ObjectMapper objectMapper;
+
+
protected AbstractExecutor(String supportType, boolean innerExecutor){
this.supportType = supportType;
this.innerExecutor = innerExecutor;
diff --git a/executor/viewer-executor-core/src/main/java/xyz/thoughtset/viewer/executor/core/entity/QueryBody.java b/executor/viewer-executor-core/src/main/java/xyz/thoughtset/viewer/executor/core/entity/QueryBody.java
index 6453cd1d9a4c34ab3c35a0bdd5c71694a7315ff1..2b10d1ef75850eb6142b087cb3c07a5952ef3631 100644
--- a/executor/viewer-executor-core/src/main/java/xyz/thoughtset/viewer/executor/core/entity/QueryBody.java
+++ b/executor/viewer-executor-core/src/main/java/xyz/thoughtset/viewer/executor/core/entity/QueryBody.java
@@ -20,6 +20,7 @@ public class QueryBody extends BaseMeta {
protected String dsId;
@TableField(condition = SqlCondition.LIKE)
protected String query;
+// protected String type;
@TableField(exist = false)
private List params;
diff --git a/executor/viewer-executor-core/src/main/java/xyz/thoughtset/viewer/executor/core/factory/ExecutorRegistry.java b/executor/viewer-executor-core/src/main/java/xyz/thoughtset/viewer/executor/core/factory/ExecutorRegistry.java
index 6d21f8e295ec2be9b781c7e8578f84c7bbb6ed6c..024cc12081524d2c46390e26fb5305c10b25c30f 100644
--- a/executor/viewer-executor-core/src/main/java/xyz/thoughtset/viewer/executor/core/factory/ExecutorRegistry.java
+++ b/executor/viewer-executor-core/src/main/java/xyz/thoughtset/viewer/executor/core/factory/ExecutorRegistry.java
@@ -12,13 +12,13 @@ import java.util.concurrent.ConcurrentHashMap;
public class ExecutorRegistry {
private static AbstractExecutor DEFAULT = null;
private static final ConcurrentHashMap Executor_Map = new ConcurrentHashMap<>();
- @Getter
- private static final LinkedHashSet Executor_Keys = new LinkedHashSet<>();
+// @Getter
+// private static final LinkedHashSet Executor_Keys = new LinkedHashSet<>();
public static void register(AbstractExecutor executor) {
if (DEFAULT==null) DEFAULT = executor;
Executor_Map.put(executor.getSupportType(), executor);
- Executor_Keys.add(executor.getSupportType());
+// Executor_Keys.add(executor.getSupportType());
}
public static AbstractExecutor findExecutor(String supportType){
diff --git a/executor/viewer-executor-mybatis/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/executor/viewer-executor-mybatis/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
deleted file mode 100644
index 54d7e552e54b41853993688ccee118c73b695ac7..0000000000000000000000000000000000000000
--- a/executor/viewer-executor-mybatis/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
+++ /dev/null
@@ -1 +0,0 @@
-xyz.thoughtset.viewer.executor.mybatis.MybatisExecutorAutoConfiguration
\ No newline at end of file
diff --git a/modules/viewer-modules-ds/pom.xml b/modules/viewer-modules-ds/pom.xml
index e001f9ca057e045ff084f75491622eee78b3d331..102c6b986fc592ff116938d74e53e65d4ad01eb2 100644
--- a/modules/viewer-modules-ds/pom.xml
+++ b/modules/viewer-modules-ds/pom.xml
@@ -14,6 +14,8 @@
viewer-modules-ds-core
viewer-modules-ds-jdbc
+ viewer-modules-ds-http
+ viewer-modules-ds-command
diff --git a/executor/viewer-executor-mybatis/pom.xml b/modules/viewer-modules-ds/viewer-modules-ds-command/pom.xml
similarity index 82%
rename from executor/viewer-executor-mybatis/pom.xml
rename to modules/viewer-modules-ds/viewer-modules-ds-command/pom.xml
index 556a6f126256143262b6042015cbe19b6f4c9fee..ae79c6b5db798e8796332ec935e4b7addd4160d4 100644
--- a/executor/viewer-executor-mybatis/pom.xml
+++ b/modules/viewer-modules-ds/viewer-modules-ds-command/pom.xml
@@ -5,11 +5,11 @@
4.0.0
xyz.thoughtset.viewer
- executor
+ viewer-modules-ds
${revision}
- viewer-executor-mybatis
+ viewer-modules-ds-command
17
@@ -20,7 +20,7 @@
xyz.thoughtset.viewer
- viewer-executor-core
+ viewer-modules-ds-core
diff --git a/executor/viewer-executor-mybatis/src/main/java/xyz/thoughtset/viewer/executor/mybatis/MybatisExecutorAutoConfiguration.java b/modules/viewer-modules-ds/viewer-modules-ds-command/src/main/java/xyz/thoughtset/viewer/modules/ds/command/DsCmdAutoConfiguration.java
similarity index 73%
rename from executor/viewer-executor-mybatis/src/main/java/xyz/thoughtset/viewer/executor/mybatis/MybatisExecutorAutoConfiguration.java
rename to modules/viewer-modules-ds/viewer-modules-ds-command/src/main/java/xyz/thoughtset/viewer/modules/ds/command/DsCmdAutoConfiguration.java
index a1722063ebb66a957e7dc6b28cf22d25e93a519d..1d67bb3b0b0864bfaa31a1efca272a9f0504eecb 100644
--- a/executor/viewer-executor-mybatis/src/main/java/xyz/thoughtset/viewer/executor/mybatis/MybatisExecutorAutoConfiguration.java
+++ b/modules/viewer-modules-ds/viewer-modules-ds-command/src/main/java/xyz/thoughtset/viewer/modules/ds/command/DsCmdAutoConfiguration.java
@@ -1,4 +1,4 @@
-package xyz.thoughtset.viewer.executor.mybatis;
+package xyz.thoughtset.viewer.modules.ds.command;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
@@ -7,5 +7,5 @@ import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan
@EnableConfigurationProperties
-public class MybatisExecutorAutoConfiguration {
-}
\ No newline at end of file
+public class DsCmdAutoConfiguration {
+}
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-command/src/main/java/xyz/thoughtset/viewer/modules/ds/command/executor/CommandExecutor.java b/modules/viewer-modules-ds/viewer-modules-ds-command/src/main/java/xyz/thoughtset/viewer/modules/ds/command/executor/CommandExecutor.java
new file mode 100644
index 0000000000000000000000000000000000000000..0de68df9ac762cb366c463c09b4ab1f920bc72b8
--- /dev/null
+++ b/modules/viewer-modules-ds/viewer-modules-ds-command/src/main/java/xyz/thoughtset/viewer/modules/ds/command/executor/CommandExecutor.java
@@ -0,0 +1,41 @@
+package xyz.thoughtset.viewer.modules.ds.command.executor;
+
+import lombok.SneakyThrows;
+import org.apache.ibatis.mapping.BoundSql;
+import org.apache.ibatis.mapping.SqlSource;
+import org.apache.ibatis.parsing.XNode;
+import org.apache.ibatis.parsing.XPathParser;
+import org.apache.ibatis.reflection.ParamNameResolver;
+import org.apache.ibatis.scripting.xmltags.XMLScriptBuilder;
+import org.apache.ibatis.session.Configuration;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
+import xyz.thoughtset.viewer.executor.core.base.AbstractExecutor;
+import xyz.thoughtset.viewer.executor.core.entity.QueryBody;
+import xyz.thoughtset.viewer.modules.ds.core.factory.ConnectFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Component
+public class CommandExecutor extends AbstractExecutor {
+ @Autowired
+ protected ConnectFactory connectFactory;
+ public CommandExecutor() {
+ super(null, true);
+ }
+ private final Configuration configuration = new Configuration();
+ private final String head_xml = "";
+ private final String tail_xml = "";
+
+ @Override
+ protected Object exec(QueryBody queryBody, Map param) {
+ return null;
+// return doQuery(queryBody.getQuery(),param, connectFactory.buildConnect(queryBody.getDsId(), BaseReq.class));
+ }
+
+
+
+
+}
diff --git a/executor/viewer-executor-mybatis/src/main/resources/META-INF/spring.factories b/modules/viewer-modules-ds/viewer-modules-ds-command/src/main/resources/META-INF/spring.factories
similarity index 62%
rename from executor/viewer-executor-mybatis/src/main/resources/META-INF/spring.factories
rename to modules/viewer-modules-ds/viewer-modules-ds-command/src/main/resources/META-INF/spring.factories
index eb37a7b53d0f11cd35f3db752bb8be04249ea599..d7d832d6c0e663113aa3e75f87f20351a44f65bb 100644
--- a/executor/viewer-executor-mybatis/src/main/resources/META-INF/spring.factories
+++ b/modules/viewer-modules-ds/viewer-modules-ds-command/src/main/resources/META-INF/spring.factories
@@ -1 +1 @@
-org.springframework.boot.autoconfigure.EnableAutoConfiguration=xyz.thoughtset.viewer.executor.mybatis
\ No newline at end of file
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=xyz.thoughtset.viewer.modules.ds.command
\ No newline at end of file
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-command/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/modules/viewer-modules-ds/viewer-modules-ds-command/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
new file mode 100644
index 0000000000000000000000000000000000000000..892106370eebfd4feb6e468778e0abc03749f755
--- /dev/null
+++ b/modules/viewer-modules-ds/viewer-modules-ds-command/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -0,0 +1 @@
+xyz.thoughtset.viewer.modules.ds.command.DsCmdAutoConfiguration
\ No newline at end of file
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-core/pom.xml b/modules/viewer-modules-ds/viewer-modules-ds-core/pom.xml
index 4109b154c78976b19577605eba0bf81bc43c8bd0..c93e585a08b6ce96b6e9575546e18663f4209d5d 100644
--- a/modules/viewer-modules-ds/viewer-modules-ds-core/pom.xml
+++ b/modules/viewer-modules-ds/viewer-modules-ds-core/pom.xml
@@ -17,4 +17,12 @@
UTF-8
+
+
+
+ xyz.thoughtset.viewer
+ viewer-executor-core
+
+
+
\ No newline at end of file
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-core/src/main/java/xyz/thoughtset/viewer/modules/ds/core/factory/ConnectFactory.java b/modules/viewer-modules-ds/viewer-modules-ds-core/src/main/java/xyz/thoughtset/viewer/modules/ds/core/factory/ConnectFactory.java
index 72cc300369f38d4215a2ca580133414afa105039..fc0e855e99800a7e5857fe3507e3b5ec63a4920f 100644
--- a/modules/viewer-modules-ds/viewer-modules-ds-core/src/main/java/xyz/thoughtset/viewer/modules/ds/core/factory/ConnectFactory.java
+++ b/modules/viewer-modules-ds/viewer-modules-ds-core/src/main/java/xyz/thoughtset/viewer/modules/ds/core/factory/ConnectFactory.java
@@ -29,6 +29,9 @@ public class ConnectFactory {
private DsConfigDao dsConfigDao;
private ConcurrentHashMap DS_CACHE = new ConcurrentHashMap<>();
+ public T buildConnect(String dsId,Class targetType) {
+ return (T) buildConnect(dsId);
+ }
public Object buildConnect(String dsId) {
Object result = DS_CACHE.get(dsId);
@@ -54,7 +57,7 @@ public class ConnectFactory {
return result;
}
- private ConnBuilder findConnBuilder(DsConfig ds){
+ public ConnBuilder findConnBuilder(DsConfig ds){
ConnBuilder connBuilder = LinkerHelper.getConnBuilder(ds);
if (Objects.nonNull(connBuilder)){
return connBuilder;
diff --git a/executor/viewer-executor-core/src/main/java/xyz/thoughtset/viewer/executor/core/factory/ExecutorManager.java b/modules/viewer-modules-ds/viewer-modules-ds-core/src/main/java/xyz/thoughtset/viewer/modules/ds/core/factory/ExecutorManager.java
similarity index 71%
rename from executor/viewer-executor-core/src/main/java/xyz/thoughtset/viewer/executor/core/factory/ExecutorManager.java
rename to modules/viewer-modules-ds/viewer-modules-ds-core/src/main/java/xyz/thoughtset/viewer/modules/ds/core/factory/ExecutorManager.java
index 66348bb28fc64a61ecf036cfca4b26d4bbf35904..6ba51d024a31977ddd343031c67c52509bfcfd6a 100644
--- a/executor/viewer-executor-core/src/main/java/xyz/thoughtset/viewer/executor/core/factory/ExecutorManager.java
+++ b/modules/viewer-modules-ds/viewer-modules-ds-core/src/main/java/xyz/thoughtset/viewer/modules/ds/core/factory/ExecutorManager.java
@@ -1,15 +1,22 @@
-package xyz.thoughtset.viewer.executor.core.factory;
+package xyz.thoughtset.viewer.modules.ds.core.factory;
import cn.hutool.core.convert.Convert;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import xyz.thoughtset.viewer.common.connector.entity.bo.Linker;
+import xyz.thoughtset.viewer.common.connector.linker.ConnBuilder;
+import xyz.thoughtset.viewer.common.connector.linker.LinkerBuilder;
+import xyz.thoughtset.viewer.common.connector.linker.LinkerHelper;
import xyz.thoughtset.viewer.executor.core.base.AbstractExecutor;
import xyz.thoughtset.viewer.executor.core.base.DataContext;
import xyz.thoughtset.viewer.executor.core.constants.TypeConstants;
import xyz.thoughtset.viewer.executor.core.entity.QueryBody;
import xyz.thoughtset.viewer.executor.core.entity.QueryParam;
+import xyz.thoughtset.viewer.executor.core.factory.ExecutorRegistry;
import xyz.thoughtset.viewer.executor.core.service.QueryBodyService;
+import xyz.thoughtset.viewer.modules.ds.core.dao.DsConfigDao;
+import xyz.thoughtset.viewer.modules.ds.core.entity.DsConfig;
import java.util.HashMap;
import java.util.LinkedHashSet;
@@ -23,6 +30,10 @@ import java.util.stream.Collectors;
public class ExecutorManager {
@Autowired
private QueryBodyService queryBodyService;
+ @Autowired
+ private DsConfigDao dsConfigDao;
+ @Autowired
+ private ConnectFactory connectFactory;
public Object execute(String bodyId, Map tmpParam){
QueryBody queryBody = queryBodyService.getById(bodyId);
@@ -41,7 +52,9 @@ public class ExecutorManager {
paramsMap.put(queryParam.getTitle(),
Convert.convert(TypeConstants.TYPE_MAP.get(queryParam.getDataType()),value));
}
- AbstractExecutor executor = ExecutorRegistry.findExecutor(queryBody.getDsId());
+ DsConfig dsConfig = dsConfigDao.selectById(queryBody.getDsId());
+ ConnBuilder connBuilder = connectFactory.findConnBuilder(dsConfig);
+ AbstractExecutor executor = ExecutorRegistry.findExecutor(connBuilder.getDataLinker().getLinkerType());
return executor.execute(queryBody,paramsMap);
}
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-core/src/main/java/xyz/thoughtset/viewer/modules/ds/core/service/LinkerConfigServiceImpl.java b/modules/viewer-modules-ds/viewer-modules-ds-core/src/main/java/xyz/thoughtset/viewer/modules/ds/core/service/LinkerConfigServiceImpl.java
index ce1a59965a991e65e105223d40c67573d17bb01b..50e2c24f771c9d3a03487c1f1b59d344840dad3d 100644
--- a/modules/viewer-modules-ds/viewer-modules-ds-core/src/main/java/xyz/thoughtset/viewer/modules/ds/core/service/LinkerConfigServiceImpl.java
+++ b/modules/viewer-modules-ds/viewer-modules-ds-core/src/main/java/xyz/thoughtset/viewer/modules/ds/core/service/LinkerConfigServiceImpl.java
@@ -10,7 +10,7 @@ import xyz.thoughtset.viewer.modules.ds.core.entity.LinkerConfig;
import java.util.LinkedHashMap;
import java.util.Objects;
-@Service("linkerConfigService")
+@Service
@Transactional
public class LinkerConfigServiceImpl extends BaseServiceImpl implements LinkerConfigService{
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-http/pom.xml b/modules/viewer-modules-ds/viewer-modules-ds-http/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..642e3a0383c45be7a9c45af32b1d3dfea111b147
--- /dev/null
+++ b/modules/viewer-modules-ds/viewer-modules-ds-http/pom.xml
@@ -0,0 +1,32 @@
+
+
+ 4.0.0
+
+ xyz.thoughtset.viewer
+ viewer-modules-ds
+ ${revision}
+
+
+ viewer-modules-ds-http
+ pom
+
+ viewer-modules-ds-http-core
+ viewer-modules-ds-http-simple
+
+
+
+ 17
+ 17
+ UTF-8
+
+
+
+
+ xyz.thoughtset.viewer
+ viewer-modules-ds-core
+
+
+
+
\ No newline at end of file
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/pom.xml b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..3919da3160624b2862700fea8f624fe51221996e
--- /dev/null
+++ b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/pom.xml
@@ -0,0 +1,21 @@
+
+
+ 4.0.0
+
+ xyz.thoughtset.viewer
+ viewer-modules-ds-http
+ ${revision}
+
+
+ viewer-modules-ds-http-core
+
+
+ 17
+ 17
+ UTF-8
+
+
+
+
\ No newline at end of file
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/java/xyz/thoughtset/viewer/modules/ds/http/core/DsHttpCoreAutoConfiguration.java b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/java/xyz/thoughtset/viewer/modules/ds/http/core/DsHttpCoreAutoConfiguration.java
new file mode 100644
index 0000000000000000000000000000000000000000..c66dd5fbf738e951ca59b89efe5e55a99238ecda
--- /dev/null
+++ b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/java/xyz/thoughtset/viewer/modules/ds/http/core/DsHttpCoreAutoConfiguration.java
@@ -0,0 +1,11 @@
+package xyz.thoughtset.viewer.modules.ds.http.core;
+
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@ComponentScan
+@EnableConfigurationProperties
+public class DsHttpCoreAutoConfiguration {
+}
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/java/xyz/thoughtset/viewer/modules/ds/http/core/constant/RequireAttrConstant.java b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/java/xyz/thoughtset/viewer/modules/ds/http/core/constant/RequireAttrConstant.java
new file mode 100644
index 0000000000000000000000000000000000000000..aad2dde199d81e9464d6c833d13f80672154ba4f
--- /dev/null
+++ b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/java/xyz/thoughtset/viewer/modules/ds/http/core/constant/RequireAttrConstant.java
@@ -0,0 +1,8 @@
+package xyz.thoughtset.viewer.modules.ds.http.core.constant;
+
+public class RequireAttrConstant {
+ public static final String USE_FORMAT_URL = "formatUrl";
+ public static final Boolean USE_FORMAT_URL_DEFAULT = Boolean.TRUE;
+
+ public static final String USE_FORMAT_BODY = "formatBody";
+}
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/java/xyz/thoughtset/viewer/modules/ds/http/core/constant/SupportTypeConstant.java b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/java/xyz/thoughtset/viewer/modules/ds/http/core/constant/SupportTypeConstant.java
new file mode 100644
index 0000000000000000000000000000000000000000..7dbc3bd7610dadebdda8666e7c7d633f9aa1640e
--- /dev/null
+++ b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/java/xyz/thoughtset/viewer/modules/ds/http/core/constant/SupportTypeConstant.java
@@ -0,0 +1,5 @@
+package xyz.thoughtset.viewer.modules.ds.http.core.constant;
+
+public class SupportTypeConstant {
+ public static final String SUPPORT_TYPE = "HTTP";
+}
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/java/xyz/thoughtset/viewer/modules/ds/http/core/enums/OkHttp3BuilderEnum.java b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/java/xyz/thoughtset/viewer/modules/ds/http/core/enums/OkHttp3BuilderEnum.java
new file mode 100644
index 0000000000000000000000000000000000000000..b109c7d7bfb20d8647d29f884ed35e2eee8ed2ab
--- /dev/null
+++ b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/java/xyz/thoughtset/viewer/modules/ds/http/core/enums/OkHttp3BuilderEnum.java
@@ -0,0 +1,58 @@
+package xyz.thoughtset.viewer.modules.ds.http.core.enums;
+
+import lombok.Getter;
+
+import java.util.Map;
+
+public enum OkHttp3BuilderEnum {
+ MAX_IDLE_CONNECTIONS("maxIdleConnections"),
+ KEEP_ALIVE_DURATION("keepAliveDuration"),
+ PROXY_HOST("proxyHost"),
+ PROXY_PORT("proxyPort"),
+ PROXY_TYPE("proxyType","HTTP"),
+ CONNECT_TIMEOUT("connectTimeout"),
+ READ_TIMEOUT("readTimeout"),
+ WRITE_TIMEOUT("writeTimeout"),
+ ENABLE_VERIFY_SSL("verifySSL","true");
+
+ @Getter
+ private final String title;
+ private final String defaultValue;
+ private final boolean autoLoad;
+
+ OkHttp3BuilderEnum(String title) {
+ this(title,null);
+ }
+ OkHttp3BuilderEnum(String title,String defaultValue) {
+ this(title,null,false);
+ }
+ OkHttp3BuilderEnum(String title,String defaultValue,boolean autoLoad) {
+ this.title = title;
+ this.defaultValue = defaultValue;
+ this.autoLoad = autoLoad;
+ }
+
+ public static Object getVal(Map map, OkHttp3BuilderEnum builderEnum) {
+ Object value = map.get(builderEnum.title);
+ if (value == null) {
+ value = builderEnum.defaultValue;
+ }
+ return value;
+ }
+
+ public static String getStrVal(Map map, OkHttp3BuilderEnum builderEnum) {
+ return (String) getVal(map, builderEnum);
+ }
+
+ public static Integer getIntVal(Map map, OkHttp3BuilderEnum builderEnum) {
+ Object value = getVal(map, builderEnum);
+ return value == null ? null : value instanceof Integer? (Integer) value :Integer.valueOf((String)value);
+ }
+
+ public static Long getLongVal(Map map, OkHttp3BuilderEnum builderEnum) {
+ Object value = getVal(map, builderEnum);
+ return value == null ? null : value instanceof Long? (Long) value :Long.valueOf((String)value);
+ }
+
+
+}
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/java/xyz/thoughtset/viewer/modules/ds/http/core/executor/HttpReqExecutor.java b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/java/xyz/thoughtset/viewer/modules/ds/http/core/executor/HttpReqExecutor.java
new file mode 100644
index 0000000000000000000000000000000000000000..aa6a35b396feacc3b97bf9e18d9075982deae248
--- /dev/null
+++ b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/java/xyz/thoughtset/viewer/modules/ds/http/core/executor/HttpReqExecutor.java
@@ -0,0 +1,85 @@
+package xyz.thoughtset.viewer.modules.ds.http.core.executor;
+
+import lombok.SneakyThrows;
+import org.apache.ibatis.mapping.BoundSql;
+import org.apache.ibatis.mapping.SqlSource;
+import org.apache.ibatis.parsing.XNode;
+import org.apache.ibatis.parsing.XPathParser;
+import org.apache.ibatis.reflection.ParamNameResolver;
+import org.apache.ibatis.scripting.xmltags.XMLScriptBuilder;
+import org.apache.ibatis.session.Configuration;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
+import org.springframework.web.util.UriComponentsBuilder;
+import xyz.thoughtset.viewer.executor.core.base.AbstractExecutor;
+import xyz.thoughtset.viewer.executor.core.entity.QueryBody;
+import xyz.thoughtset.viewer.modules.ds.core.factory.ConnectFactory;
+import xyz.thoughtset.viewer.modules.ds.http.core.constant.RequireAttrConstant;
+import xyz.thoughtset.viewer.modules.ds.http.core.constant.SupportTypeConstant;
+import xyz.thoughtset.viewer.modules.ds.http.core.req.BaseReq;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Component
+public class HttpReqExecutor extends AbstractExecutor {
+ @Autowired
+ protected ConnectFactory connectFactory;
+ public HttpReqExecutor() {
+ super(SupportTypeConstant.SUPPORT_TYPE, true);
+ }
+ private final Configuration configuration = new Configuration();
+ private final String head_xml = "";
+ private final String tail_xml = "";
+
+ @Override
+ protected Object exec(QueryBody queryBody, Map param) {
+ return doQuery(queryBody.getQuery(),param, connectFactory.buildConnect(queryBody.getDsId(), BaseReq.class));
+ }
+
+
+ @SneakyThrows
+ public Object doQuery(String sqlText, Object param, BaseReq baseReq) {
+ sqlText = sqlText.trim().replaceAll("&", "&");
+ //todo:优化点直接使用DocumentBuilderFactory进行创建
+ XPathParser parser = new XPathParser(head_xml+sqlText+tail_xml);
+ XNode rootNode = parser.evalNode("/root");
+ XNode xNode = rootNode.evalNode("http|get|post");
+ XNode payloadNode = rootNode.evalNode("/payload");
+ Boolean useFormatUrl = xNode.getBooleanAttribute(RequireAttrConstant.USE_FORMAT_URL, RequireAttrConstant.USE_FORMAT_URL_DEFAULT);
+ //#{
+ XMLScriptBuilder builder = new XMLScriptBuilder(configuration, xNode, null);
+ SqlSource sqlSource = builder.parseScriptNode();
+ Object parameterObject = ParamNameResolver.wrapToMapIfCollection(param, null);
+ BoundSql boundSql = sqlSource.getBoundSql(parameterObject);
+ String reqUrl = boundSql.getSql().trim()
+ .replaceAll("\\s*","")
+ .replace("?&","?");
+ if (reqUrl.endsWith("?")){
+ reqUrl = reqUrl.substring(reqUrl.length()-1,reqUrl.length());
+ }
+ String payload = null;
+ if (payloadNode!=null){
+ payload = new XMLScriptBuilder(configuration, payloadNode, null)
+ .parseScriptNode().getBoundSql(parameterObject).getSql().trim()
+ .replaceAll("\\s*","");
+ }
+ String resultJson = null;
+ switch (xNode.getName().toLowerCase()){
+ case "post":
+ resultJson = baseReq.doPost(reqUrl, useFormatUrl, payload);
+ break;
+ case "get":
+ default:
+ resultJson = baseReq.doGet(reqUrl, useFormatUrl);
+ }
+// List result = new ArrayList();
+// result.add(StringUtils.hasText(resultJson) ? objectMapper.readValue(resultJson, Map.class) : new HashMap<>());
+ return StringUtils.hasText(resultJson) ? objectMapper.readValue(resultJson, Map.class) : new HashMap<>();
+ }
+
+
+
+
+}
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/java/xyz/thoughtset/viewer/modules/ds/http/core/linker/HttpConnBuilder.java b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/java/xyz/thoughtset/viewer/modules/ds/http/core/linker/HttpConnBuilder.java
new file mode 100644
index 0000000000000000000000000000000000000000..23443253b739897240b6849f367e4079e00b7c18
--- /dev/null
+++ b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/java/xyz/thoughtset/viewer/modules/ds/http/core/linker/HttpConnBuilder.java
@@ -0,0 +1,129 @@
+package xyz.thoughtset.viewer.modules.ds.http.core.linker;
+
+
+import lombok.SneakyThrows;
+import okhttp3.ConnectionPool;
+import okhttp3.OkHttpClient;
+import xyz.thoughtset.viewer.common.connector.entity.bo.ConnectorMeta;
+import xyz.thoughtset.viewer.common.connector.entity.bo.Linker;
+import xyz.thoughtset.viewer.common.connector.linker.ConnBuilder;
+import xyz.thoughtset.viewer.modules.ds.http.core.enums.OkHttp3BuilderEnum;
+import xyz.thoughtset.viewer.modules.ds.http.core.req.SyncHttpReq;
+
+import javax.net.ssl.*;
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.security.KeyStore;
+import java.security.SecureRandom;
+import java.security.cert.X509Certificate;
+import java.util.Objects;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+public abstract class HttpConnBuilder extends ConnBuilder {
+ private static final Properties EMPTY_PROP = new Properties();
+
+ public HttpConnBuilder(Linker dataLinker) {
+ super(dataLinker);
+ }
+
+ @SneakyThrows
+ @Override
+ public Object buildConnect(ConnectorMeta connectorMeta, Properties properties){
+ if (properties == null) {
+ properties = EMPTY_PROP;
+ }
+ Object connections = properties.get(OkHttp3BuilderEnum.MAX_IDLE_CONNECTIONS.getTitle());
+ OkHttpClient.Builder builder = new OkHttpClient.Builder();
+ if (Objects.nonNull(connections)){
+ if (connections instanceof String){
+ connections = Integer.parseInt((String) connections);
+ }
+ if(((Integer) connections) < 3){
+ connections = 3;
+ }
+ Object keepAliveDuration = properties.get(OkHttp3BuilderEnum.KEEP_ALIVE_DURATION.getTitle());
+ if(Objects.isNull(keepAliveDuration)){
+ keepAliveDuration = 5L;
+ }else {
+ if (keepAliveDuration instanceof String){
+ keepAliveDuration = Long.parseLong((String) keepAliveDuration);
+ }
+ }
+ if(((Long) keepAliveDuration) < 2L){
+ connections = 2L;
+ }
+ builder.connectionPool(
+ new ConnectionPool(
+ (Integer) connections,
+ (Long) keepAliveDuration,
+ TimeUnit.MINUTES));
+ }
+ if (!Boolean.valueOf(OkHttp3BuilderEnum.getStrVal(properties, OkHttp3BuilderEnum.ENABLE_VERIFY_SSL))) {
+ builder.hostnameVerifier((hostname, session) -> true);
+ X509TrustManager myTrustManager = new X509TrustManager() {
+ @Override
+ public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws java.security.cert.CertificateException {
+
+ }
+ @Override
+ public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws java.security.cert.CertificateException {
+ }
+ @Override
+ public X509Certificate[] getAcceptedIssuers() {
+ return new X509Certificate[0];
+ }
+ };
+ SSLContext sslCtx = SSLContext.getInstance("TLS");
+ sslCtx.init(null, new TrustManager[] { myTrustManager }, new SecureRandom());
+ builder.sslSocketFactory(sslCtx.getSocketFactory(),myTrustManager);
+ }
+ Integer connectTimeout = OkHttp3BuilderEnum.getIntVal(properties, OkHttp3BuilderEnum.CONNECT_TIMEOUT);
+ Integer readTimeout = OkHttp3BuilderEnum.getIntVal(properties, OkHttp3BuilderEnum.READ_TIMEOUT);
+ Integer writeTimeout = OkHttp3BuilderEnum.getIntVal(properties, OkHttp3BuilderEnum.WRITE_TIMEOUT);
+ if (connectTimeout != null && connectTimeout > 0) {
+ builder.connectTimeout(connectTimeout, TimeUnit.SECONDS);
+ }
+ if (readTimeout != null && readTimeout > 0) {
+ builder.readTimeout(readTimeout, TimeUnit.SECONDS);
+ }
+ if (writeTimeout != null && writeTimeout > 0 && writeTimeout < 60 * 1000 * 10L
+ && writeTimeout > readTimeout + 5L) {
+ builder.writeTimeout(writeTimeout, TimeUnit.SECONDS);
+ }
+ String proxyHost = OkHttp3BuilderEnum.getStrVal(properties, OkHttp3BuilderEnum.PROXY_HOST);
+ Integer proxyPort = OkHttp3BuilderEnum.getIntVal(properties, OkHttp3BuilderEnum.PROXY_PORT);
+ if (proxyHost != null && !proxyHost.isEmpty() && proxyPort != null) {
+ if (proxyPort < 1 || proxyPort > 65535) {
+ throw new IllegalArgumentException("Invalid proxy port: " + proxyPort);
+ }
+ if (proxyHost.length() > 255) {
+ throw new IllegalArgumentException("Invalid proxy host: " + proxyHost);
+ }
+ if (proxyHost.contains(":")) {
+ throw new IllegalArgumentException("Invalid proxy host: " + proxyHost);
+ }
+ Proxy.Type type = Proxy.Type.HTTP;
+ if (OkHttp3BuilderEnum.getStrVal(properties, OkHttp3BuilderEnum.PROXY_TYPE).equalsIgnoreCase("SOCKS")) {
+ type = Proxy.Type.SOCKS;
+ }
+ Proxy proxy = new Proxy(type, new InetSocketAddress(proxyHost, proxyPort));
+ builder.proxy(proxy);
+ }
+
+ return new SyncHttpReq(true,connectorMeta.getUrl(),builder.build());
+ }
+
+
+// private Authenticator getProxyAuthenticator(String username, String password) {
+// return (route, response) -> {
+// String credential = okhttp3.Credentials.basic(username, password);
+// return response.request().newBuilder()
+// .header("Proxy-Authorization", credential)
+// .build();
+// };
+// }
+
+ protected abstract OkHttpClient.Builder addInterceptor(OkHttpClient.Builder builder, ConnectorMeta connectorMeta, Properties properties);
+
+}
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/java/xyz/thoughtset/viewer/modules/ds/http/core/req/BaseReq.java b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/java/xyz/thoughtset/viewer/modules/ds/http/core/req/BaseReq.java
new file mode 100644
index 0000000000000000000000000000000000000000..04f253a4d1d60091921c43a09bd5427e39c3f62a
--- /dev/null
+++ b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/java/xyz/thoughtset/viewer/modules/ds/http/core/req/BaseReq.java
@@ -0,0 +1,58 @@
+package xyz.thoughtset.viewer.modules.ds.http.core.req;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import okhttp3.OkHttpClient;
+import org.springframework.web.util.UriComponentsBuilder;
+
+@Data
+@AllArgsConstructor
+public abstract class BaseReq {
+ protected boolean wasHttp;
+ protected String baseUrl;
+ protected OkHttpClient okHttpClient;
+
+ protected String buildUrl(String url,boolean formatUrl) {
+ String fullUrl;
+ if (url == null) {
+ if (baseUrl != null) {
+ fullUrl = baseUrl;
+ } else {
+ throw new NullPointerException("在设置 BaseUrl 之前,您必须指定具体路径才能发起请求!");
+ }
+ } else {
+ url = url.trim();
+ boolean isFullPath = url.startsWith("https://")
+ || url.startsWith("http://")
+ || url.startsWith("wss://")
+ || url.startsWith("ws://");
+ if (isFullPath) {
+ fullUrl = url;
+ } else if (baseUrl != null) {
+ fullUrl = baseUrl + url;
+ } else {
+ throw new NullPointerException("在设置 BaseUrl 之前,您必须使用全路径URL发起请求,当前URL为:'" + url + "'");
+ }
+ }
+ if (wasHttp && fullUrl.startsWith("http")) {
+ fullUrl = fullUrl.replaceFirst("http", "ws");
+ }
+ if (!wasHttp && fullUrl.startsWith("ws")) {
+ fullUrl = fullUrl.replaceFirst("ws", "http");
+ }
+
+
+ if (formatUrl) {
+ UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromUriString(fullUrl);
+ return uriBuilder.toUriString();
+ } else {
+ return fullUrl;
+ }
+
+ }
+
+
+ public abstract String doGet(String url,boolean formatUrl);
+ public abstract String doPost(String url,boolean formatUrl,String jsonStr);
+
+}
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/java/xyz/thoughtset/viewer/modules/ds/http/core/req/SyncHttpReq.java b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/java/xyz/thoughtset/viewer/modules/ds/http/core/req/SyncHttpReq.java
new file mode 100644
index 0000000000000000000000000000000000000000..b91a3963696d4c77395282cf3b118293f7b0691b
--- /dev/null
+++ b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/java/xyz/thoughtset/viewer/modules/ds/http/core/req/SyncHttpReq.java
@@ -0,0 +1,58 @@
+package xyz.thoughtset.viewer.modules.ds.http.core.req;
+
+import lombok.SneakyThrows;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+import okhttp3.Response;
+import org.springframework.http.MediaType;
+
+import java.io.IOException;
+
+
+
+public class SyncHttpReq extends BaseReq{
+
+ public SyncHttpReq(boolean wasHttp, String baseUrl, OkHttpClient okHttpClient) {
+ super(wasHttp, baseUrl, okHttpClient);
+ }
+
+
+ @Override
+ public String doGet(String url,boolean formatUrl) {
+ Request request = new Request.Builder()
+ .url(buildUrl(url,formatUrl))
+ .get()
+ .build();
+ return exeReq(request);
+ }
+
+ @Override
+ public String doPost(String url,boolean formatUrl,String jsonStr) {
+ RequestBody body = null;
+ if (jsonStr != null) {
+ body = RequestBody.create(
+ jsonStr,
+ okhttp3.MediaType.parse(MediaType.APPLICATION_JSON_VALUE)
+ );
+ }
+ Request request = new Request.Builder()
+ .url(buildUrl(url,formatUrl))
+ .post(body) // 这里可以添加请求体
+ .build();
+ return exeReq(request);
+ }
+
+ @SneakyThrows
+ private String exeReq(Request request){
+ try (Response response = okHttpClient.newCall(request).execute()) {
+ if (!response.isSuccessful()) {
+ throw new IOException("Unexpected code " + response);
+ }
+ // 解析响应
+ return response.body().string();
+ }
+ }
+
+
+}
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/resources/META-INF/spring.factories b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/resources/META-INF/spring.factories
new file mode 100644
index 0000000000000000000000000000000000000000..f02c75c8162f372e37c4f2d5350bdd9b25943e46
--- /dev/null
+++ b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/resources/META-INF/spring.factories
@@ -0,0 +1 @@
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=xyz.thoughtset.viewer.modules.ds.http.core
\ No newline at end of file
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
new file mode 100644
index 0000000000000000000000000000000000000000..a2522736429306bee1d1c97ba106a4ece4b7a4a1
--- /dev/null
+++ b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -0,0 +1 @@
+xyz.thoughtset.viewer.modules.ds.http.core.DsHttpCoreAutoConfiguration
\ No newline at end of file
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-simple/pom.xml b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-simple/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..cb7cfbdd1b769e1fffe4480ecf5902eb6886f78d
--- /dev/null
+++ b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-simple/pom.xml
@@ -0,0 +1,28 @@
+
+
+ 4.0.0
+
+ xyz.thoughtset.viewer
+ viewer-modules-ds-http
+ ${revision}
+
+
+ viewer-modules-ds-http-simple
+
+
+ 17
+ 17
+ UTF-8
+
+
+
+
+
+ xyz.thoughtset.viewer
+ viewer-modules-ds-http-core
+
+
+
+
\ No newline at end of file
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-simple/src/main/java/xyz/thoughtset/viewer/modules/ds/http/simple/DsHttpSimpleAutoConfiguration.java b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-simple/src/main/java/xyz/thoughtset/viewer/modules/ds/http/simple/DsHttpSimpleAutoConfiguration.java
new file mode 100644
index 0000000000000000000000000000000000000000..c58585a7c4c274b9e00958f45fa0244c6a9a3016
--- /dev/null
+++ b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-simple/src/main/java/xyz/thoughtset/viewer/modules/ds/http/simple/DsHttpSimpleAutoConfiguration.java
@@ -0,0 +1,11 @@
+package xyz.thoughtset.viewer.modules.ds.http.simple;
+
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@ComponentScan
+@EnableConfigurationProperties
+public class DsHttpSimpleAutoConfiguration {
+}
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-simple/src/main/java/xyz/thoughtset/viewer/modules/ds/http/simple/interceptor/SelfInterceptorLoad.java b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-simple/src/main/java/xyz/thoughtset/viewer/modules/ds/http/simple/interceptor/SelfInterceptorLoad.java
new file mode 100644
index 0000000000000000000000000000000000000000..b43e4c6469b258b15c3646fd2a9982a6530ec678
--- /dev/null
+++ b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-simple/src/main/java/xyz/thoughtset/viewer/modules/ds/http/simple/interceptor/SelfInterceptorLoad.java
@@ -0,0 +1,10 @@
+package xyz.thoughtset.viewer.modules.ds.http.simple.interceptor;
+
+import okhttp3.Interceptor;
+
+import java.util.List;
+import java.util.Properties;
+
+public interface SelfInterceptorLoad {
+ List buildInterceptors(String baseUrl, String ak, String sk, Properties properties);
+}
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-simple/src/main/java/xyz/thoughtset/viewer/modules/ds/http/simple/linker/ManualHttpReqBuilder.java b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-simple/src/main/java/xyz/thoughtset/viewer/modules/ds/http/simple/linker/ManualHttpReqBuilder.java
new file mode 100644
index 0000000000000000000000000000000000000000..a6ee05e6d98ef7b01dd855fb7fceeefcd7e01308
--- /dev/null
+++ b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-simple/src/main/java/xyz/thoughtset/viewer/modules/ds/http/simple/linker/ManualHttpReqBuilder.java
@@ -0,0 +1,45 @@
+package xyz.thoughtset.viewer.modules.ds.http.simple.linker;
+
+
+import lombok.SneakyThrows;
+import okhttp3.Interceptor;
+import okhttp3.OkHttpClient;
+import xyz.thoughtset.viewer.common.connector.entity.bo.ConnectorMeta;
+import xyz.thoughtset.viewer.common.connector.entity.bo.Linker;
+import xyz.thoughtset.viewer.common.core.constants.FolderNameConstant;
+import xyz.thoughtset.viewer.modules.ds.http.core.linker.HttpConnBuilder;
+import xyz.thoughtset.viewer.modules.ds.http.simple.interceptor.SelfInterceptorLoad;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.List;
+import java.util.Properties;
+
+//@Component
+public class ManualHttpReqBuilder extends HttpConnBuilder {
+ public ManualHttpReqBuilder(Linker dataLinker) {
+ super(dataLinker);
+ }
+
+ @SneakyThrows
+ @Override
+ protected OkHttpClient.Builder addInterceptor(OkHttpClient.Builder builder,
+ ConnectorMeta connectorMeta, Properties properties) {
+ URLClassLoader urlClassLoader = new URLClassLoader(
+ new URL[]{new URL(FolderNameConstant.jarFileAllPath(dataLinker.getJarFilePath()))},
+ Thread.currentThread().getContextClassLoader());
+ Class clazz = urlClassLoader.loadClass(dataLinker.getDriverClassName());
+ SelfInterceptorLoad interceptor = (SelfInterceptorLoad) clazz.newInstance();
+ List interceptors = interceptor.buildInterceptors(
+ connectorMeta.getUrl(),
+ connectorMeta.getAk(),
+ connectorMeta.getSk(),
+ properties);
+ if (interceptors != null && !interceptors.isEmpty()) {
+ for (Interceptor interceptorEle : interceptors) {
+ builder.addInterceptor(interceptorEle);
+ }
+ }
+ return builder;
+ }
+}
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-simple/src/main/java/xyz/thoughtset/viewer/modules/ds/http/simple/linker/ManualHttpReqLinkerBuilder.java b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-simple/src/main/java/xyz/thoughtset/viewer/modules/ds/http/simple/linker/ManualHttpReqLinkerBuilder.java
new file mode 100644
index 0000000000000000000000000000000000000000..0a436fa8a12147055146b148fea68d60771d11ce
--- /dev/null
+++ b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-simple/src/main/java/xyz/thoughtset/viewer/modules/ds/http/simple/linker/ManualHttpReqLinkerBuilder.java
@@ -0,0 +1,24 @@
+package xyz.thoughtset.viewer.modules.ds.http.simple.linker;
+
+
+import lombok.Getter;
+import org.springframework.stereotype.Component;
+import xyz.thoughtset.viewer.common.connector.entity.bo.Linker;
+import xyz.thoughtset.viewer.common.connector.linker.ConnBuilder;
+import xyz.thoughtset.viewer.common.connector.linker.LinkerBuilder;
+import xyz.thoughtset.viewer.modules.ds.http.core.constant.SupportTypeConstant;
+
+@Component
+@Getter
+public class ManualHttpReqLinkerBuilder extends LinkerBuilder {
+ public ManualHttpReqLinkerBuilder() {
+ super(SupportTypeConstant.SUPPORT_TYPE);
+ }
+
+ @Override
+ public ConnBuilder buildConnBuilder(Linker linker) {
+ return new ManualHttpReqBuilder(linker);
+ }
+
+
+}
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-simple/src/main/java/xyz/thoughtset/viewer/modules/ds/http/simple/linker/SimpleHttpReqBuilder.java b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-simple/src/main/java/xyz/thoughtset/viewer/modules/ds/http/simple/linker/SimpleHttpReqBuilder.java
new file mode 100644
index 0000000000000000000000000000000000000000..e82edea53cdf756ffba5990e9ae17eac277f6c8b
--- /dev/null
+++ b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-simple/src/main/java/xyz/thoughtset/viewer/modules/ds/http/simple/linker/SimpleHttpReqBuilder.java
@@ -0,0 +1,28 @@
+package xyz.thoughtset.viewer.modules.ds.http.simple.linker;
+
+
+import okhttp3.OkHttpClient;
+import org.springframework.stereotype.Component;
+import xyz.thoughtset.viewer.common.connector.entity.bo.ConnectorMeta;
+import xyz.thoughtset.viewer.common.connector.entity.bo.Linker;
+import xyz.thoughtset.viewer.modules.ds.http.core.linker.HttpConnBuilder;
+import xyz.thoughtset.viewer.modules.ds.http.core.constant.SupportTypeConstant;
+
+import java.util.Properties;
+
+@Component
+public class SimpleHttpReqBuilder extends HttpConnBuilder {
+ public SimpleHttpReqBuilder() {
+ super(new Linker(
+ "SimpleHttpReq",
+ null,
+ SupportTypeConstant.SUPPORT_TYPE
+ ));
+ }
+
+
+ @Override
+ protected OkHttpClient.Builder addInterceptor(OkHttpClient.Builder builder, ConnectorMeta connectorMeta, Properties properties) {
+ return builder;
+ }
+}
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-simple/src/main/resources/META-INF/spring.factories b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-simple/src/main/resources/META-INF/spring.factories
new file mode 100644
index 0000000000000000000000000000000000000000..677f87d12db7d66ddef4dd26158a161472734f3f
--- /dev/null
+++ b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-simple/src/main/resources/META-INF/spring.factories
@@ -0,0 +1 @@
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=xyz.thoughtset.viewer.modules.ds.http.simple
\ No newline at end of file
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-simple/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-simple/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
new file mode 100644
index 0000000000000000000000000000000000000000..d44179a5051ab73ec6906e21ef5afb579eef2053
--- /dev/null
+++ b/modules/viewer-modules-ds/viewer-modules-ds-http/viewer-modules-ds-http-simple/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -0,0 +1 @@
+xyz.thoughtset.viewer.modules.ds.http.simple.DsHttpSimpleAutoConfiguration
\ No newline at end of file
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-jdbc/viewer-modules-ds-jdbc-core/pom.xml b/modules/viewer-modules-ds/viewer-modules-ds-jdbc/viewer-modules-ds-jdbc-core/pom.xml
index 4309ebeda60f37f30521234f2eafd01a844f0de4..19e6921b837587a11185dad84edb15484c125bcf 100644
--- a/modules/viewer-modules-ds/viewer-modules-ds-jdbc/viewer-modules-ds-jdbc-core/pom.xml
+++ b/modules/viewer-modules-ds/viewer-modules-ds-jdbc/viewer-modules-ds-jdbc-core/pom.xml
@@ -17,4 +17,5 @@
UTF-8
+
\ No newline at end of file
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-jdbc/viewer-modules-ds-jdbc-core/src/main/java/xyz/thoughtset/viewer/modules/ds/jdbc/core/constant/SupportTypeConstant.java b/modules/viewer-modules-ds/viewer-modules-ds-jdbc/viewer-modules-ds-jdbc-core/src/main/java/xyz/thoughtset/viewer/modules/ds/jdbc/core/constant/SupportTypeConstant.java
new file mode 100644
index 0000000000000000000000000000000000000000..5098ec10984e9d01b6a6538ff90024fe4e9e9f89
--- /dev/null
+++ b/modules/viewer-modules-ds/viewer-modules-ds-jdbc/viewer-modules-ds-jdbc-core/src/main/java/xyz/thoughtset/viewer/modules/ds/jdbc/core/constant/SupportTypeConstant.java
@@ -0,0 +1,6 @@
+package xyz.thoughtset.viewer.modules.ds.jdbc.core.constant;
+
+public class SupportTypeConstant {
+ public static final String SUPPORT_TYPE = "jdbc";
+ public static final String MYSQL = "mysql";
+}
diff --git a/executor/viewer-executor-mybatis/src/main/java/xyz/thoughtset/viewer/executor/mybatis/factory/MybatisTypeQueryExecutor.java b/modules/viewer-modules-ds/viewer-modules-ds-jdbc/viewer-modules-ds-jdbc-core/src/main/java/xyz/thoughtset/viewer/modules/ds/jdbc/core/factory/MybatisSqlQueryExecutor.java
similarity index 90%
rename from executor/viewer-executor-mybatis/src/main/java/xyz/thoughtset/viewer/executor/mybatis/factory/MybatisTypeQueryExecutor.java
rename to modules/viewer-modules-ds/viewer-modules-ds-jdbc/viewer-modules-ds-jdbc-core/src/main/java/xyz/thoughtset/viewer/modules/ds/jdbc/core/factory/MybatisSqlQueryExecutor.java
index 63109da69624c9da6b9325166a5f16f5d47a8fdb..2b6fed4e8ef5501967b57b50b41eadaa0e5b25e4 100644
--- a/executor/viewer-executor-mybatis/src/main/java/xyz/thoughtset/viewer/executor/mybatis/factory/MybatisTypeQueryExecutor.java
+++ b/modules/viewer-modules-ds/viewer-modules-ds-jdbc/viewer-modules-ds-jdbc-core/src/main/java/xyz/thoughtset/viewer/modules/ds/jdbc/core/factory/MybatisSqlQueryExecutor.java
@@ -1,4 +1,4 @@
-package xyz.thoughtset.viewer.executor.mybatis.factory;
+package xyz.thoughtset.viewer.modules.ds.jdbc.core.factory;
import lombok.SneakyThrows;
import org.apache.ibatis.mapping.BoundSql;
@@ -15,13 +15,11 @@ import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.TypeException;
import org.apache.ibatis.type.TypeHandler;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;
import xyz.thoughtset.viewer.executor.core.base.AbstractExecutor;
-import xyz.thoughtset.viewer.executor.core.base.DataContext;
import xyz.thoughtset.viewer.executor.core.entity.QueryBody;
-import xyz.thoughtset.viewer.executor.core.service.QueryBodyService;
-import xyz.thoughtset.viewer.modules.ds.core.service.DsConfigService;
+import xyz.thoughtset.viewer.modules.ds.core.factory.ConnectFactory;
+import xyz.thoughtset.viewer.modules.ds.jdbc.core.constant.SupportTypeConstant;
import javax.sql.DataSource;
import java.sql.*;
@@ -31,21 +29,20 @@ import java.util.List;
import java.util.Map;
@Component
-public class MybatisTypeQueryExecutor extends AbstractExecutor {
+public class MybatisSqlQueryExecutor extends AbstractExecutor {
+ @Autowired
+ protected ConnectFactory connectFactory;
- public MybatisTypeQueryExecutor() {
- super("MybatisType", true);
-// this.dsConfigService = dsConfigService;
+ public MybatisSqlQueryExecutor() {
+ super(SupportTypeConstant.SUPPORT_TYPE, true);
}
private final Configuration configuration = new Configuration();
- @Autowired
- private DsConfigService dsConfigService;
@Override
protected Object exec(QueryBody queryBody, Map param) {
- return doQuery(queryBody.getQuery(),param,dsConfigService.buildDataSource(queryBody.getDsId()));
+ return doQuery(queryBody.getQuery(),param, connectFactory.buildConnect(queryBody.getDsId(),DataSource.class));
}
@@ -76,6 +73,8 @@ public class MybatisTypeQueryExecutor extends AbstractExecutor {
}
list.add(resultMap);
}
+ }catch (Exception e){
+ e.printStackTrace();
}
// org.apache.ibatis.executor.SimpleExecutor
// Executor executor = new SimpleExecutor();
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-jdbc/viewer-modules-ds-jdbc-mysql/src/main/java/xyz/thoughtset/viewer/modules/ds/jdbc/mysql/config/MysqlDsConfig.java b/modules/viewer-modules-ds/viewer-modules-ds-jdbc/viewer-modules-ds-jdbc-mysql/src/main/java/xyz/thoughtset/viewer/modules/ds/jdbc/mysql/config/MysqlDsConfig.java
index 26d2cbb2ed72d4ef18d33ea84e11aa5b4dfa21ce..ee9e3d5604a51458b7f614c85faf640d0e6a7b8b 100644
--- a/modules/viewer-modules-ds/viewer-modules-ds-jdbc/viewer-modules-ds-jdbc-mysql/src/main/java/xyz/thoughtset/viewer/modules/ds/jdbc/mysql/config/MysqlDsConfig.java
+++ b/modules/viewer-modules-ds/viewer-modules-ds-jdbc/viewer-modules-ds-jdbc-mysql/src/main/java/xyz/thoughtset/viewer/modules/ds/jdbc/mysql/config/MysqlDsConfig.java
@@ -3,6 +3,8 @@ package xyz.thoughtset.viewer.modules.ds.jdbc.mysql.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import xyz.thoughtset.viewer.common.connector.entity.bo.Linker;
+import xyz.thoughtset.viewer.modules.ds.jdbc.core.constant.SupportTypeConstant;
+import xyz.thoughtset.viewer.modules.ds.jdbc.core.factory.MybatisSqlQueryExecutor;
import xyz.thoughtset.viewer.modules.ds.jdbc.core.linker.JdbcConnBuilder;
@Configuration
@@ -12,7 +14,8 @@ public class MysqlDsConfig {
public JdbcConnBuilder mysqlConnBuilder() {
Linker dataLinker = new Linker(
"mysql",
- "com.mysql.cj.jdbc.Driver"
+ "com.mysql.cj.jdbc.Driver",
+ SupportTypeConstant.SUPPORT_TYPE
);
return new JdbcConnBuilder(dataLinker);
}
diff --git a/modules/viewer-modules-ds/viewer-modules-ds-jdbc/viewer-modules-ds-jdbc-self/src/main/java/xyz/thoughtset/viewer/modules/ds/jdbc/self/linker/ManualJdbcLinkerBuilder.java b/modules/viewer-modules-ds/viewer-modules-ds-jdbc/viewer-modules-ds-jdbc-self/src/main/java/xyz/thoughtset/viewer/modules/ds/jdbc/self/linker/ManualJdbcLinkerBuilder.java
index eafe57270ef39c7aff67e47702c340263d7b3347..e578230e070e7ff8b0608e53aebd1dbc664526df 100644
--- a/modules/viewer-modules-ds/viewer-modules-ds-jdbc/viewer-modules-ds-jdbc-self/src/main/java/xyz/thoughtset/viewer/modules/ds/jdbc/self/linker/ManualJdbcLinkerBuilder.java
+++ b/modules/viewer-modules-ds/viewer-modules-ds-jdbc/viewer-modules-ds-jdbc-self/src/main/java/xyz/thoughtset/viewer/modules/ds/jdbc/self/linker/ManualJdbcLinkerBuilder.java
@@ -7,12 +7,14 @@ import xyz.thoughtset.viewer.common.connector.entity.bo.Linker;
import xyz.thoughtset.viewer.common.connector.linker.ConnBuilder;
import xyz.thoughtset.viewer.common.connector.linker.LinkerBuilder;
import xyz.thoughtset.viewer.common.connector.linker.LinkerHelper;
+import xyz.thoughtset.viewer.modules.ds.jdbc.core.constant.SupportTypeConstant;
+import xyz.thoughtset.viewer.modules.ds.jdbc.core.factory.MybatisSqlQueryExecutor;
@Component
@Getter
public class ManualJdbcLinkerBuilder extends LinkerBuilder {
public ManualJdbcLinkerBuilder() {
- super("jdbc");
+ super(SupportTypeConstant.SUPPORT_TYPE);
}
@Override
diff --git a/modules/viewer-modules-step/pom.xml b/modules/viewer-modules-step/pom.xml
index 6817d320b6a9de9e475745f1ecdad42ec5f941e8..c4872b0aa32c5f1598234d5e9e60f78b416b4735 100644
--- a/modules/viewer-modules-step/pom.xml
+++ b/modules/viewer-modules-step/pom.xml
@@ -26,10 +26,6 @@
-
- xyz.thoughtset.viewer
- viewer-executor-mybatis
-
\ No newline at end of file
diff --git a/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/executor/SimpleBlockExecutor.java b/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/executor/SimpleBlockExecutor.java
index 5f1638c98e48bd7bc27a33fc6f27c7c7c02d170a..0ef8748a5177ac518410fa89bf12d662cfe8bdb9 100644
--- a/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/executor/SimpleBlockExecutor.java
+++ b/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/executor/SimpleBlockExecutor.java
@@ -7,15 +7,12 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
-import xyz.thoughtset.viewer.executor.core.factory.ExecutorManager;
+import xyz.thoughtset.viewer.modules.ds.core.factory.ExecutorManager;
import xyz.thoughtset.viewer.modules.step.entity.BlockParam;
import xyz.thoughtset.viewer.modules.step.entity.QueryBlock;
import xyz.thoughtset.viewer.modules.step.service.QueryBlockService;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
@Component
public class SimpleBlockExecutor {
@@ -32,10 +29,19 @@ public class SimpleBlockExecutor {
List blocks = queryBlockService.listByPId(apiId);
for (QueryBlock block : blocks) {
Object queryResult = blockQuery(block,contentMap);
+ String key = block.getTitle();
+ Object val = queryResult;
if (block.resultWasSingle() && !ObjectUtils.isEmpty(queryResult)){
- queryResult = ((List)queryResult).get(0);
+ if (val instanceof List){
+ val = ((List)queryResult).get(0);
+ }
+ }else{
+ if (!(val instanceof Collection)){
+ val = new ArrayList<>();
+ ((ArrayList) val).add(queryResult);
+ }
}
- contentMap.put(block.getTitle(),queryResult);
+ contentMap.put(key,val);
}
return contentMap;
@@ -67,7 +73,7 @@ public class SimpleBlockExecutor {
// return simpleQueryExecutor.doQuery(queryBody.getQuery(),tmpParamsMap,queryBody.getDsId());
// }
- private List blockQuery(QueryBlock block,Map contentMap){
+ private Object blockQuery(QueryBlock block,Map contentMap){
Map tmpParamsMap = new HashMap();
List blockParams = queryBlockService.blockParams(block.getId());
if (Objects.nonNull(blockParams)){
@@ -84,7 +90,7 @@ public class SimpleBlockExecutor {
tmpParamsMap.put(blockParam.getQpId(),value);
}
}
- return (List) executorManager.execute(block.getBodyId(),tmpParamsMap);
+ return executorManager.execute(block.getBodyId(),tmpParamsMap);
}
diff --git a/pom.xml b/pom.xml
index 63ba05dcad07f1bb50bcc1dfc6d778cd22cfaf0f..9067546740d7ce859484631631e889f16b942a68 100644
--- a/pom.xml
+++ b/pom.xml
@@ -48,6 +48,7 @@
33.1.0-jre
1.76
1.1.0
+ 4.11.0
@@ -124,6 +125,12 @@
bcprov-jdk18on
${bouncycastle.version}
+
+
+ com.squareup.okhttp3
+ okhttp
+ ${okhttp3.version}
+
@@ -215,10 +222,14 @@
viewer-common-envvar
${revision}
-
xyz.thoughtset.viewer
- viewer-executor-mybatis
+ viewer-modules-ds-http-core
+ ${revision}
+
+
+ xyz.thoughtset.viewer
+ viewer-modules-ds-http-simple
${revision}