|
10 | 10 | import org.lowcoder.domain.plugin.client.dto.GetPluginDynamicConfigRequestDTO;
|
11 | 11 | import org.lowcoder.infra.js.NodeServerClient;
|
12 | 12 | import org.lowcoder.infra.js.NodeServerHelper;
|
| 13 | +import org.lowcoder.sdk.config.CommonConfig; |
13 | 14 | import org.lowcoder.sdk.config.CommonConfigHelper;
|
14 | 15 | import org.lowcoder.sdk.exception.ServerException;
|
15 | 16 | import org.lowcoder.sdk.models.DatasourceTestResult;
|
@@ -48,6 +49,7 @@ public class DatasourcePluginClient implements NodeServerClient {
|
48 | 49 | .build();
|
49 | 50 |
|
50 | 51 | private final CommonConfigHelper commonConfigHelper;
|
| 52 | + private final CommonConfig commonConfig; |
51 | 53 | private final NodeServerHelper nodeServerHelper;
|
52 | 54 | private final EncryptionService encryptionService;
|
53 | 55 |
|
@@ -134,13 +136,23 @@ public Mono<QueryExecutionResult> executeQuery(String pluginName, Object queryDs
|
134 | 136 | "dataSourceConfig", datasourceConfig
|
135 | 137 | );
|
136 | 138 | String json = OBJECT_MAPPER.writeValueAsString(body);
|
137 |
| - String encrypted = encryptionService.encryptStringForNodeServer(json); |
138 |
| - return WEB_CLIENT |
| 139 | + |
| 140 | + boolean encryptionEnabled = commonConfig.getJsExecutor().isEncrypted(); |
| 141 | + String payload; |
| 142 | + WebClient.RequestBodySpec requestSpec = WEB_CLIENT |
139 | 143 | .post()
|
140 | 144 | .uri(nodeServerHelper.createUri(RUN_PLUGIN_QUERY))
|
141 |
| - .header(HttpHeaders.ACCEPT_LANGUAGE, language) |
142 |
| - .header("X-Encrypted", "true") // Optional: custom header to indicate encryption |
143 |
| - .bodyValue(encrypted) |
| 145 | + .header(HttpHeaders.ACCEPT_LANGUAGE, language); |
| 146 | + |
| 147 | + if (encryptionEnabled) { |
| 148 | + payload = encryptionService.encryptStringForNodeServer(json); |
| 149 | + requestSpec = requestSpec.header("X-Encrypted", "true"); |
| 150 | + } else { |
| 151 | + payload = json; |
| 152 | + } |
| 153 | + |
| 154 | + return requestSpec |
| 155 | + .bodyValue(payload) |
144 | 156 | .exchangeToMono(response -> {
|
145 | 157 | if (response.statusCode().is2xxSuccessful()) {
|
146 | 158 | return response.bodyToMono(Map.class)
|
|
0 commit comments