新增计算模块接口

This commit is contained in:
谷成伟 2024-11-07 14:16:48 +08:00
parent bd25f3bbbf
commit 74eed15299
2 changed files with 12 additions and 10 deletions

View File

@ -1,5 +1,6 @@
package com.das.modules.calc.service; package com.das.modules.calc.service;
import cn.hutool.core.codec.Base64Encoder;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.das.modules.cache.service.CacheService; import com.das.modules.cache.service.CacheService;
import com.das.modules.calc.domain.entity.CalcModule; import com.das.modules.calc.domain.entity.CalcModule;
@ -23,6 +24,8 @@ import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.StringReader; import java.io.StringReader;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -217,7 +220,7 @@ public class CalcService {
public String getScriptContent(String moduleName) throws IOException { public String getScriptContent(String moduleName) throws IOException {
CalcModule calcModule = calcModuleMapper.selectById(moduleName); CalcModule calcModule = calcModuleMapper.selectById(moduleName);
if (calcModule != null) { if (calcModule != null) {
return calcModule.getScript(); return Base64Encoder.encode(calcModule.getScript(), StandardCharsets.UTF_8);
} }
throw new IOException("无效的模块名"); throw new IOException("无效的模块名");
} }

View File

@ -105,12 +105,12 @@ POST 请求接口
POST 请求接口 POST 请求接口
> /api/node/delete > /api/node/module/active
请求参数 请求参数
```json ```json
{ {
"id": "73535240297775104" "moduleName": "WindFarmStatistics"
} }
``` ```
返回报文 返回报文
@ -119,30 +119,29 @@ POST 请求接口
{ {
"code": 200, "code": 200,
"success": true, "success": true,
"msg": "操作成功" "msg": "激活成功"
} }
``` ```
### 1.1.5 配置下发 ### 1.1.5 配置下发
POST 请求接口 POST 请求接口
> /api/node/configUpdate > /api/node/module/deactive
请求参数 请求参数
```json ```json
{
"moduleName": "WindFarmStatistics"
}
``` ```
返回报文 返回报文
```json ```json
{ {
"code": 200, "code": 200,
"success": true, "success": true,
"msg": "操作成功" "msg": "禁用成功"
} }
```
## 1.2 链路相关接口 ## 1.2 链路相关接口