diff --git a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md new file mode 100644 index 0000000000000000000000000000000000000000..6199c1ecbaf8edc09d26aa41ecf9780bbccf38df --- /dev/null +++ b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md @@ -0,0 +1,12 @@ +### 相关的Issue + + +### 原因(目的、解决的问题等) + + +### 描述(做了什么,变更了什么) + + +### 测试用例(新增、改动、可能影响的功能) + + diff --git a/apis/pom.xml b/apis/pom.xml index 6aa4cd7bc41ed61a44971fc713e47709cc0a8e5b..0f830491a391489395074b116c615c1b4a459bf1 100644 --- a/apis/pom.xml +++ b/apis/pom.xml @@ -23,10 +23,18 @@ + + xyz.thoughtset.viewer + viewer-executor-blocks + xyz.thoughtset.viewer viewer-modules-api + + xyz.thoughtset.viewer + viewer-modules-fun + xyz.thoughtset.viewer viewer-modules-ds-jdbc-mysql diff --git a/apis/viewer-apis-client/src/main/java/xyz/thoughtset/viewer/apis/client/controller/ApiController.java b/apis/viewer-apis-client/src/main/java/xyz/thoughtset/viewer/apis/client/controller/ApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..1947d802de9230d916c0b2533db729ad2508c5fd --- /dev/null +++ b/apis/viewer-apis-client/src/main/java/xyz/thoughtset/viewer/apis/client/controller/ApiController.java @@ -0,0 +1,31 @@ +package xyz.thoughtset.viewer.apis.client.controller; + + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.*; +import xyz.thoughtset.viewer.common.api.controller.BaseController; +import xyz.thoughtset.viewer.common.crud.api.controller.CrudController; +import xyz.thoughtset.viewer.modules.api.service.ApiInfoService; +import xyz.thoughtset.viewer.modules.step.service.BlockInfoService; +import xyz.thoughtset.viewer.modules.step.service.QueryBlockService; + +import java.util.List; + +@RestController +@RequestMapping +public class ApiController extends BaseController { + @Autowired + private ApiInfoService apiInfoService; + + + @GetMapping(value = "/publishApi") + public void publishApi(@RequestParam String apiId){ + apiInfoService.publishApi(apiId); + } + @GetMapping(value = "/unpublishedApi") + public void unpublishedApi(@RequestParam String apiId){ + apiInfoService.unpublishedApi(apiId); + } + +} diff --git a/apis/viewer-apis-client/src/main/java/xyz/thoughtset/viewer/apis/client/controller/DataTypeApi.java b/apis/viewer-apis-client/src/main/java/xyz/thoughtset/viewer/apis/client/controller/DataTypeApi.java index b3f3542c3606b707f53724c88040592bb97b99b2..637a55498a97bc7437988763db4954ac5fdbdc16 100644 --- a/apis/viewer-apis-client/src/main/java/xyz/thoughtset/viewer/apis/client/controller/DataTypeApi.java +++ b/apis/viewer-apis-client/src/main/java/xyz/thoughtset/viewer/apis/client/controller/DataTypeApi.java @@ -46,7 +46,7 @@ public class DataTypeApi extends BaseController { @GetMapping("/getEnvVars") public Object getEnvVars(@RequestParam String varId){ - return envVarsService.getEnvVars(varId); + return envVarsService.selectDetail(varId); } } diff --git a/apis/viewer-apis-client/src/main/java/xyz/thoughtset/viewer/apis/client/controller/FileApi.java b/apis/viewer-apis-client/src/main/java/xyz/thoughtset/viewer/apis/client/controller/FileApi.java index 980b2ebc100321e72ece8656fd49f8dd5bcecfd2..2a0f71aa964b68d90acd348c049b517f93191402 100644 --- a/apis/viewer-apis-client/src/main/java/xyz/thoughtset/viewer/apis/client/controller/FileApi.java +++ b/apis/viewer-apis-client/src/main/java/xyz/thoughtset/viewer/apis/client/controller/FileApi.java @@ -14,8 +14,8 @@ public class FileApi extends BaseController { @Autowired private ExportDataInfoService exportDataInfoService; - @GetMapping("/template") - public Object template(){ + @GetMapping("/templates") + public Object templates(){ return exportDataInfoService.templateFiles(); } diff --git a/apis/viewer-apis-client/src/main/java/xyz/thoughtset/viewer/apis/client/controller/QueryBlockController.java b/apis/viewer-apis-client/src/main/java/xyz/thoughtset/viewer/apis/client/controller/QueryBlockController.java index 044a9d2753cc197c845b77baf552c11842880e6e..99a942e085fbb1e833e011aa2b8982f87c8c6c8d 100644 --- a/apis/viewer-apis-client/src/main/java/xyz/thoughtset/viewer/apis/client/controller/QueryBlockController.java +++ b/apis/viewer-apis-client/src/main/java/xyz/thoughtset/viewer/apis/client/controller/QueryBlockController.java @@ -5,6 +5,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import xyz.thoughtset.viewer.common.crud.api.controller.CrudController; +import xyz.thoughtset.viewer.modules.step.service.BlockInfoService; import xyz.thoughtset.viewer.modules.step.service.QueryBlockService; import java.util.List; @@ -12,7 +13,8 @@ import java.util.List; @RestController @RequestMapping("/qb/") public class QueryBlockController extends CrudController { - + @Autowired + private BlockInfoService blockInfoService; @Autowired private QueryBlockService queryBlockService; @@ -21,6 +23,9 @@ public class QueryBlockController extends CrudController { public Object sort(@RequestBody List items){ return queryBlockService.saveBlockOrder(items); } - + @PostMapping(value = "sort2" , produces = MediaType.APPLICATION_JSON_VALUE) + public Object sort2(@RequestBody List items){ + return blockInfoService.saveBlockOrder(items); + } } diff --git a/apis/viewer-apis-client/src/main/java/xyz/thoughtset/viewer/apis/client/controller/TestFunQueryController.java b/apis/viewer-apis-client/src/main/java/xyz/thoughtset/viewer/apis/client/controller/TestFunQueryController.java new file mode 100644 index 0000000000000000000000000000000000000000..a7a3685b56a27d1585c94de67d5a27ea5463a106 --- /dev/null +++ b/apis/viewer-apis-client/src/main/java/xyz/thoughtset/viewer/apis/client/controller/TestFunQueryController.java @@ -0,0 +1,80 @@ +package xyz.thoughtset.viewer.apis.client.controller; + + +import cn.idev.excel.ExcelWriter; +import cn.idev.excel.FastExcel; +import cn.idev.excel.write.metadata.WriteSheet; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import xyz.thoughtset.viewer.common.core.constants.FolderNameConstant; +import xyz.thoughtset.viewer.executor.blocks.executor.BlockExecutorManager; +import xyz.thoughtset.viewer.modules.api.controller.BaseApiController; +import xyz.thoughtset.viewer.modules.api.entity.ApiInfo; +import xyz.thoughtset.viewer.modules.api.service.ApiInfoService; +import xyz.thoughtset.viewer.modules.excel.entity.ExportDataInfo; + +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.LinkedHashMap; +import java.util.Map; + +@RestController +@RequestMapping("/t/") +public class TestFunQueryController extends BaseApiController { + @Autowired + protected BlockExecutorManager blockExecutorManager; + + @GetMapping(value = "{subject}") + @ResponseBody + public Object query(@RequestParam(required = false) LinkedHashMap searchMap + , @PathVariable("subject") String subject) { + return blockExecutorManager.execBlocks(subject, searchMap); + } + + + @GetMapping(value = "e/{subject}") + @ResponseBody + public void excel(@RequestParam(required = false) LinkedHashMap searchMap + , @PathVariable("subject") String subject, HttpServletResponse response) { + ExportDataInfo exportDataInfo = exportDataService.getById(subject); + if (exportDataInfo == null) { + throw new NullPointerException("exportData not found"); + } + Map data = (Map) query(searchMap, exportDataInfo.getBodyId()); + String fileName = exportDataInfo.getFileName(); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); +// String fileName = URLEncoder.encode("测试", "UTF-8").replaceAll("\\+", "%20"); + response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); + + try ( + InputStream templateStream = new FileInputStream( + FolderNameConstant.folderWithSep(FolderNameConstant.TEMPLATE,exportDataInfo.getTemplateId())); + ExcelWriter writer = + FastExcel.write(response.getOutputStream()) + .withTemplate(templateStream).build()) { + WriteSheet writeSheet = FastExcel.writerSheet().build(); + + for (Map.Entry entry : data.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + writer.fill(value, writeSheet); + } + // 填充列表数据,开启 forceNewRow +// FillConfig config = FillConfig.builder().forceNewRow(true).build(); +// writer.fill(data, config, writeSheet); + + // 填充普通变量 +// Map map = new HashMap<>(); +// map.put("date", "2024年11月20日"); +// map.put("total", 1000); +// writer.fill(map, writeSheet); + writer.finish(); + }catch (Exception e) { + throw new RuntimeException(e.getMessage(), e); + } + } + + +} diff --git a/apis/viewer-apis-client/src/main/resources/db/schema.sql b/apis/viewer-apis-client/src/main/resources/db/schema.sql index b66ec7efae33da961edf60e090f02eba78bb41e1..dff5f57e4316ab5775150e1dc705beeeb029e877 100644 --- a/apis/viewer-apis-client/src/main/resources/db/schema.sql +++ b/apis/viewer-apis-client/src/main/resources/db/schema.sql @@ -38,6 +38,49 @@ CREATE TABLE IF NOT EXISTS ApiParam( -- -- CREATE INDEX IF NOT EXISTS idx_pid ON ApiParam (pid); -- CREATE INDEX IF NOT EXISTS idx_order_up ON ApiParam (orderNum ASC, updatedAt DESC); +CREATE TABLE IF NOT EXISTS `blockbodyele` ( + `id` varchar(32) NOT NULL, + `title` varchar(32) DEFAULT NULL, + `pid` varchar(32) DEFAULT NULL, + `groupId` varchar(32) DEFAULT NULL, + `remark` text, + `orderNum` int(11) DEFAULT '0', + `createdAt` datetime NOT NULL, + `updatedAt` datetime NOT NULL, + `statesCode` int(11) DEFAULT '200', + `paramsPayload` text, + `type` varchar(32) DEFAULT NULL, + `eleId` varchar(32) DEFAULT NULL, + `valnum` varchar(8) DEFAULT '', + PRIMARY KEY (`id`) +); +CREATE TABLE IF NOT EXISTS `blockinfo` ( + `id` varchar(32) NOT NULL, + `title` varchar(32) DEFAULT NULL, + `pid` varchar(32) DEFAULT NULL, + `groupId` varchar(32) DEFAULT NULL, + `remark` text, + `orderNum` int(11) DEFAULT '0', + `createdAt` datetime NOT NULL, + `updatedAt` datetime NOT NULL, + `statesCode` int(11) DEFAULT '200', + `dataStr` text, + `single` bit(1) DEFAULT NULL, + `cacheId` varchar(32) DEFAULT NULL, + `bodyType` varchar(32) DEFAULT NULL, + PRIMARY KEY (`id`) +); + +CREATE TABLE IF NOT EXISTS `blockparam` ( + `id` varchar(32) NOT NULL, + `pid` varchar(32) DEFAULT NULL, + `groupId` varchar(32) DEFAULT NULL, + `createdAt` datetime NOT NULL, + `updatedAt` datetime NOT NULL, + `qpId` varchar(32) DEFAULT NULL, + `dataExp` text, + PRIMARY KEY (`id`) +); CREATE TABLE IF NOT EXISTS DsConfig ( id varchar(32) NOT NULL, @@ -57,7 +100,38 @@ CREATE TABLE IF NOT EXISTS DsConfig ( otherSettings text, PRIMARY KEY (id) ) ; --- DROP TABLE IF EXISTS QueryParam; + +CREATE TABLE IF NOT EXISTS `envvars` ( + `id` varchar(32) NOT NULL, + `title` varchar(32) NULL DEFAULT NULL, + `pid` varchar(32) NULL DEFAULT NULL, + `groupId` varchar(32) NULL DEFAULT NULL, + `remark` text NULL, + `orderNum` int(11) NULL DEFAULT 0, + `createdAt` datetime(0) NOT NULL, + `updatedAt` datetime(0) NOT NULL, + `statesCode` int(11) NULL DEFAULT 200, + `type` varchar(32) NULL DEFAULT NULL, + `topic` text NULL, + `payload` text NULL, + PRIMARY KEY (`id`) +); + +CREATE TABLE IF NOT EXISTS `excinfo`( + `id` varchar(32) NOT NULL, + `pid` varchar(32) NULL DEFAULT NULL, + `groupId` varchar(32) NULL DEFAULT NULL, + `createdAt` datetime(0) NOT NULL, + `updatedAt` datetime(0) NOT NULL, + `statesCode` int(11) NULL DEFAULT 200, + `apiId` varchar(32) NULL DEFAULT NULL, + `blockId` varchar(32) NULL DEFAULT NULL, + `errMsg` text NULL, + `paramStr` text NULL, + `errType` text NULL, + PRIMARY KEY (`id`) +); + CREATE TABLE IF NOT EXISTS QueryParam( id varchar(32) NOT NULL, title varchar(32) DEFAULT NULL, @@ -100,6 +174,7 @@ CREATE TABLE IF NOT EXISTS QueryBlock ( statesCode INT DEFAULT 200 , bodyId varchar(32), single BIT, + cacheId varchar(32), PRIMARY KEY (id) ) ; @@ -132,18 +207,78 @@ CREATE TABLE IF NOT EXISTS LinkerConfig ( PRIMARY KEY (`id`) ) ; -CREATE TABLE IF NOT EXISTS queryparam ( +CREATE TABLE IF NOT EXISTS `exportdatainfo` ( + `id` varchar(32) NOT NULL, + `title` varchar(32) NULL DEFAULT NULL, + `pid` varchar(32) NULL DEFAULT NULL, + `groupId` varchar(32) NULL DEFAULT NULL, + `remark` text NULL, + `orderNum` int(11) NULL DEFAULT NULL, + `createdAt` datetime(0) NOT NULL, + `updatedAt` datetime(0) NOT NULL, + `statesCode` int(11) NULL DEFAULT 200, + `bodyId` varchar(32) NULL DEFAULT NULL, + `templateId` varchar(32) NULL DEFAULT NULL, + `fileName` varchar(32) NULL DEFAULT NULL, + PRIMARY KEY (`id`) +); + +CREATE TABLE IF NOT EXISTS `funinfo` ( + `id` varchar(32) NOT NULL, + `title` varchar(32) NULL DEFAULT NULL, + `pid` varchar(32) NULL DEFAULT NULL, + `groupId` varchar(32) NULL DEFAULT NULL, + `remark` text NULL, + `orderNum` int(11) NULL DEFAULT NULL, + `createdAt` datetime(0) NOT NULL, + `updatedAt` datetime(0) NOT NULL, + `statesCode` int(11) NULL DEFAULT 200, + `cacheTime` int(11) NULL DEFAULT NULL, + PRIMARY KEY (`id`) +); + +CREATE TABLE IF NOT EXISTS `funparam` ( + `id` varchar(32) NOT NULL, + `title` varchar(32) NULL DEFAULT NULL, + `pid` varchar(32) NULL DEFAULT NULL, + `groupId` varchar(32) NULL DEFAULT NULL, + `remark` text NULL, + `orderNum` int(11) NULL DEFAULT 0, + `createdAt` datetime(0) NOT NULL, + `updatedAt` datetime(0) NOT NULL, + `statesCode` int(11) NULL DEFAULT 200, + `dataType` varchar(32) NULL DEFAULT NULL, + `defaultVal` varchar(32) NULL DEFAULT NULL, + `paramType` int(11) NULL DEFAULT NULL, + PRIMARY KEY (`id`) +); + +-- ---------------------------- +-- Table structure for loginfo +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `loginfo` ( + `id` varchar(32) NOT NULL, + `pid` varchar(32) DEFAULT NULL, + `groupId` varchar(32) NULL DEFAULT NULL, + `createdAt` datetime(0) NOT NULL, + `updatedAt` datetime(0) NOT NULL, + `type` varchar(32), + `active` varchar(32), + `data` text NULL, + PRIMARY KEY (`id`) +); + +CREATE TABLE IF NOT EXISTS `datarel` ( `id` varchar(32) NOT NULL, - `title` varchar(32) DEFAULT NULL, `pid` varchar(32) DEFAULT NULL, `groupId` varchar(32) DEFAULT NULL, - `remark` text NULL, - `orderNum` int(11) DEFAULT 0, - `createdAt` datetime(0) NOT NULL, - `updatedAt` datetime(0) NOT NULL, - `statesCode` int(11) DEFAULT 200, - `dataType` varchar(32) NOT NULL, - `defaultVal` varchar(32) DEFAULT NULL, + `orderNum` int(11) DEFAULT '0', + `createdAt` datetime NOT NULL, + `updatedAt` datetime NOT NULL, + `topic` varchar(32), + `rel` varchar(32), + `source` varchar(32), + `target` varchar(32), + `dataExp` text, PRIMARY KEY (`id`) ) - diff --git a/apis/viewer-apis-client/src/main/resources/static/html/index.html b/apis/viewer-apis-client/src/main/resources/static/html/index.html index 236b3edf9207fa5f007757c24f667f32c2c7c606..c983671f4c704e7d626a1ba6fad04ac832e2b707 100644 --- a/apis/viewer-apis-client/src/main/resources/static/html/index.html +++ b/apis/viewer-apis-client/src/main/resources/static/html/index.html @@ -14,6 +14,7 @@ + @@ -36,6 +40,7 @@ // 如果想用 browserHistory 请切换下这处代码, 其他不用变 // const history = History.createBrowserHistory(); const history = History.createHashHistory(); + // let amisLib = amisRequire('amis'); const app = { type: 'app', @@ -193,6 +198,10 @@ location: state.location || state }); }); + + // amisLib.registerFilter('parseJSONStr', function (jsonStr) { + // return parseJSONStr(jsonStr); + // }); })(); diff --git a/apis/viewer-apis-client/src/main/resources/static/html/pages/ApiInfo.json b/apis/viewer-apis-client/src/main/resources/static/html/pages/ApiInfo.json index 4bbbf420e6cc30976cca174cf99295d398a21b79..4f1db582e3dd102b3dd62d06231da8cc6f65dd51 100644 --- a/apis/viewer-apis-client/src/main/resources/static/html/pages/ApiInfo.json +++ b/apis/viewer-apis-client/src/main/resources/static/html/pages/ApiInfo.json @@ -1,12 +1,17 @@ { "type": "page", + "id": "u:2100b771c123", + "asideResizor": false, + "pullRefresh": { + "disabled": true + }, "regions": [ "body" ], "body": [ { - "type": "crud2", "id": "u:d6b3f2f118a6", + "type": "crud2", "mode": "table2", "dsType": "api", "syncLocation": true, @@ -16,14 +21,6 @@ "url": "/q/findList/apiInfo", "method": "get" }, - "quickSaveItemApi": { - "url": "/c/save/queryBody", - "method": "post", - "requestAdaptor": "", - "adaptor": "", - "messages": {}, - "dataType": "json" - }, "filter": { "type": "form", "title": "条件查询", @@ -54,9 +51,54 @@ } ], "actions": [ + { + "type": "dropdown-button", + "label": "下拉按钮", + "id": "u:7124850e755a", + "buttons": [ + { + "type": "button", + "label": "快速创建", + "onEvent": { + "click": { + "actions": [ + { + "ignoreError": false, + "actionType": "drawer", + "drawer": { + "$ref": "modal-ref-1" + } + } + ] + } + }, + "id": "u:88dcfbedb928" + }, + { + "type": "button", + "label": "普通创建", + "onEvent": { + "click": { + "actions": [ + { + "ignoreError": false, + "actionType": "drawer", + "drawer": { + "$ref": "modal-ref-2" + } + } + ] + } + }, + "id": "u:c4377c4316bc" + } + ], + "trigger": "hover" + }, { "type": "button", "label": "新增", + "id": "u:48f65763bc82", "onEvent": { "click": { "actions": [ @@ -70,7 +112,7 @@ ] } }, - "id": "u:48f65763bc82" + "visible": false }, { "type": "reset", @@ -88,61 +130,7 @@ "feat": "Insert" }, "headerToolbar": [], - "footerToolbar": [ - { - "type": "flex", - "direction": "row", - "justify": "flex-start", - "alignItems": "stretch", - "style": { - "position": "static", - "flexWrap": "nowrap" - }, - "items": [ - { - "type": "container", - "align": "left", - "body": [], - "wrapperBody": false, - "style": { - "flexGrow": 1, - "flex": "1 1 auto", - "position": "static", - "display": "flex", - "flexBasis": "auto", - "flexDirection": "row", - "flexWrap": "nowrap", - "alignItems": "stretch", - "justifyContent": "flex-start" - }, - "id": "u:b76ccc02db9a" - }, - { - "type": "container", - "align": "right", - "body": [], - "wrapperBody": false, - "style": { - "flexGrow": 1, - "flex": "1 1 auto", - "position": "static", - "display": "flex", - "flexDirection": "row", - "flexWrap": "nowrap", - "alignItems": "stretch", - "justifyContent": "flex-end" - }, - "id": "u:29066429e821", - "isFixedHeight": false - } - ], - "id": "u:c31243274210", - "isFixedHeight": false, - "isFixedWidth": false, - "visible": false, - "hidden": true - } - ], + "footerToolbar": [], "columns": [ { "type": "tpl", @@ -156,11 +144,11 @@ }, { "type": "tpl", - "title": "title", + "title": "标题", "name": "title", "id": "u:7b5904fba5cc", "placeholder": "-", - "width": "30%" + "width": "20%" }, { "type": "tpl", @@ -169,22 +157,30 @@ "id": "u:8360797d9693", "placeholder": "", "copyable": true, - "tpl": "${CONCATENATE(\"eq/\",id)}", + "tpl": "${IF(ISEMPTY(url),CONCATENATE(\"eq/\",id),url)}", "wrapperComponent": "", "onEvent": { "click": { "weight": 0, "actions": [] } - } + }, + "width": "20%" }, { "type": "tpl", - "title": "updatedAt", - "name": "updatedAt", + "title": "备注", + "name": "remark", + "id": "u:7a288a5d9778", + "placeholder": "-" + }, + { + "type": "tpl", + "title": "更新日期", "id": "u:0c07bb68b2d3", - "placeholder": "-", - "width": "16%" + "width": "15%", + "name": "updatedAt", + "placeholder": "-" }, { "type": "operation", @@ -209,15 +205,35 @@ ] } }, - "id": "u:89db420d516e" + "id": "u:89db420d516e", + "visibleOn": "${OR(ISEMPTY(queryType),queryType<10)}" }, { "type": "button", + "label": "编辑", + "level": "link", + "behavior": "Edit", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "drawer", + "drawer": { + "$ref": "modal-ref-2" + } + } + ] + } + }, + "id": "u:146f701b277c", + "visibleOn": "${AND(queryType>10,queryType<20)}" + }, + { "label": "删除", - "behavior": "Delete", - "className": "m-r-xs text-danger", "level": "link", - "confirmText": "确认要删除数据", + "id": "u:a573a1548749", + "type": "button", + "behavior": "Delete", "onEvent": { "click": { "actions": [ @@ -245,11 +261,96 @@ ] } }, - "id": "u:a573a1548749" + "className": "m-r-xs text-danger", + "confirmText": "确认要删除数据", + "visibleOn": "${OR(queryType<11,AND(statesCode != 200,queryType>10,queryType<20))}" + }, + { + "type": "button", + "label": "启用", + "onEvent": { + "click": { + "actions": [ + { + "ignoreError": false, + "outputVar": "responseResult", + "actionType": "ajax", + "options": {}, + "api": { + "url": "publishApi", + "method": "get", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "data": { + "apiId": "${id}" + } + } + }, + { + "componentId": "u:d6b3f2f118a6", + "ignoreError": false, + "actionType": "reload" + } + ] + } + }, + "id": "u:570016330e03", + "level": "success", + "block": false, + "size": "xs", + "hidden": false, + "visibleOn": "${AND(statesCode != 200,AND(queryType>10,queryType<20))}" + }, + { + "type": "button", + "label": "停用", + "onEvent": { + "click": { + "actions": [ + { + "ignoreError": false, + "outputVar": "responseResult", + "actionType": "ajax", + "options": {}, + "api": { + "url": "unpublishedApi", + "method": "get", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "data": { + "apiId": "${id}" + } + } + }, + { + "componentId": "u:d6b3f2f118a6", + "ignoreError": false, + "actionType": "reload" + } + ] + } + }, + "id": "u:33df5e1baa8f", + "level": "warning", + "block": false, + "size": "xs", + "confirmText": "停用后接口将无法访问", + "hidden": false, + "visibleOn": "${AND(statesCode == 200,AND(queryType>10,queryType<20))}" } ] } ], + "quickSaveItemApi": { + "url": "/c/save/queryBody", + "method": "post", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "dataType": "json" + }, "editorSetting": { "mock": { "enable": true, @@ -260,11 +361,6 @@ "autoFillHeight": true } ], - "id": "u:2100b771c123", - "pullRefresh": { - "disabled": true - }, - "asideResizor": false, "definitions": { "modal-ref-1": { "type": "drawer", @@ -288,11 +384,25 @@ "hidden": false }, { + "name": "queryType", + "label": "queryType", + "row": 0, + "type": "input-number", + "id": "u:bb0a5884f46d", + "visible": false, + "hidden": false, + "keyboard": true, + "step": 1, + "value": 0, + "min": 0, + "max": 0 + }, + { + "type": "input-text", "name": "title", "label": "title", - "row": 1, - "type": "input-text", "id": "u:ba1548d04809", + "row": 1, "onEvent": { "change": { "weight": 0, @@ -301,11 +411,11 @@ } }, { + "type": "input-text", + "id": "u:9bd95f9ca5ad", "name": "url", "label": "url", "row": 2, - "type": "input-text", - "id": "u:9bd95f9ca5ad", "hidden": false, "clearValueOnHidden": false, "visible": true, @@ -314,9 +424,9 @@ "value": "${IF(ISEMPTY(id),\"\",CONCATENATE(\"eq/\",id))}" }, { - "type": "input-table", "name": "apiParams", "label": "参数设定", + "type": "input-table", "id": "u:904bffd1aa6c", "columns": [ { @@ -447,96 +557,35 @@ { "type": "crud", "id": "u:9a2552614c4b", - "syncLocation": false, - "api": { - "method": "get", - "url": "/q/findList/queryBlock", - "messages": {}, - "requestAdaptor": "", - "adaptor": "", - "sendOn": "${!ISEMPTY(id)}", - "data": { - "pid": "${id}" - } - }, - "bulkActions": [], - "itemActions": [], - "headerToolbar": [ - { - "label": "新增", - "type": "button", - "level": "primary", - "id": "u:a7d3e67b1405", - "onEvent": { - "click": { - "weight": 0, - "actions": [ - { - "ignoreError": false, - "actionType": "dialog", - "dialog": { - "$ref": "modal-ref-5" - }, - "data": { - "apiInfoId": "${id}", - "index": "${count}" - } - } - ] - } - } - }, - { - "type": "button", - "tpl": "内容", - "wrapperComponent": "", - "id": "u:5fad74206dcd", - "label": "刷新", - "onEvent": { - "click": { - "weight": 0, - "actions": [ - { - "componentId": "u:9a2552614c4b", - "ignoreError": false, - "actionType": "reload", - "outputVar": "", - "args": { - "resetPage": true - } - } - ] - } - } - } - ], "columns": [ { - "name": "id", "label": "ID", - "type": "text", + "name": "id", "id": "u:1e7e617a5d94", "placeholder": "-", "width": 1, + "type": "text", "toggled": false }, { - "name": "title", "label": "title", + "name": "title", "type": "text", "id": "u:a1287fa03d46", "placeholder": "-" }, { - "type": "text", "label": "queryTitle", "name": "queryTitle", + "type": "text", "id": "u:064b2f704eaf", "placeholder": "-" }, { - "type": "operation", "label": "操作", + "type": "operation", + "id": "u:74186454db5d", + "placeholder": "-", "buttons": [ { "type": "button", @@ -627,33 +676,94 @@ } } ], - "id": "u:74186454db5d", - "placeholder": "-", "width": "15%" } ], - "messages": {}, - "loadDataOnce": true, - "matchFunc": "", - "footerToolbar": [], - "perPageField": "", - "pageField": "", - "showFooter": false, - "hiddenOn": "${ISEMPTY(id)}", "draggable": true, - "saveOrderApi": { - "url": "/qb/sort", - "method": "post", + "syncLocation": false, + "api": { + "method": "get", + "url": "/q/findList/queryBlock", "messages": {}, - "requestAdaptor": "var ids = api.data.ids\r\napi.data = {};\r\napi.data = ids.split(\",\");\r\nreturn api;", + "requestAdaptor": "", "adaptor": "", - "dataType": "json" - } - } - ], - "api": { - "url": "/c/save/apiInfo", - "method": "post", + "sendOn": "${!ISEMPTY(id)}", + "data": { + "pid": "${id}" + } + }, + "bulkActions": [], + "itemActions": [], + "headerToolbar": [ + { + "label": "新增", + "type": "button", + "level": "primary", + "id": "u:a7d3e67b1405", + "onEvent": { + "click": { + "weight": 0, + "actions": [ + { + "ignoreError": false, + "actionType": "dialog", + "dialog": { + "$ref": "modal-ref-5" + }, + "data": { + "apiInfoId": "${id}", + "index": "${count}" + } + } + ] + } + } + }, + { + "type": "button", + "tpl": "内容", + "wrapperComponent": "", + "id": "u:5fad74206dcd", + "label": "刷新", + "onEvent": { + "click": { + "weight": 0, + "actions": [ + { + "componentId": "u:9a2552614c4b", + "ignoreError": false, + "actionType": "reload", + "outputVar": "", + "args": { + "resetPage": true + } + } + ] + } + } + } + ], + "messages": {}, + "loadDataOnce": true, + "matchFunc": "", + "footerToolbar": [], + "perPageField": "", + "pageField": "", + "showFooter": false, + "hiddenOn": "${ISEMPTY(id)}", + "saveOrderApi": { + "url": "/qb/sort", + "method": "post", + "messages": {}, + "requestAdaptor": "var ids = api.data.ids\r\napi.data = {};\r\napi.data = ids.split(\",\");\r\nreturn api;", + "adaptor": "", + "dataType": "json" + } + } + ], + "api": { + "url": "/c/save/apiInfo", + "method": "post", "requestAdaptor": "", "adaptor": "", "messages": {}, @@ -776,13 +886,14 @@ "visible": false }, { - "name": "title", - "label": "title", "type": "input-text", - "id": "u:d0cc8da15cff" + "id": "u:d0cc8da15cff", + "name": "title", + "label": "title" }, { "type": "radios", + "id": "u:3c00a8ca60dc", "label": "单一值", "name": "single", "options": [ @@ -795,20 +906,20 @@ "value": true } ], - "id": "u:3c00a8ca60dc", "selectFirst": true }, { - "label": "bodyId", - "name": "bodyId", "type": "input-text", "id": "u:ddb4f28debdc", + "label": "bodyId", + "name": "bodyId", "visible": false, "hidden": true, "clearValueOnHidden": true }, { "type": "service", + "id": "u:297ce4f88018", "body": [ { "type": "grid", @@ -960,7 +1071,6 @@ "rowClassName": "m-none p-none" } ], - "id": "u:297ce4f88018", "dsType": "api", "data": { "bodyInfo": {} @@ -1039,6 +1149,33 @@ }, { "type": "crud", + "columns": [ + { + "id": "u:cae05b8efe83", + "name": "id", + "label": "id", + "type": "text", + "placeholder": "-", + "toggled": false, + "width": 1 + }, + { + "id": "u:42008b37f675", + "name": "title", + "label": "title", + "type": "text", + "placeholder": "-" + }, + { + "type": "date", + "label": "updatedAt", + "name": "updatedAt", + "id": "u:16543dd9aeeb", + "placeholder": "-", + "width": 30 + } + ], + "id": "u:02d4702494c8", "syncLocation": false, "api": { "method": "get", @@ -1070,33 +1207,6 @@ } } ], - "columns": [ - { - "name": "id", - "label": "id", - "type": "text", - "id": "u:cae05b8efe83", - "placeholder": "-", - "toggled": false, - "width": 1 - }, - { - "name": "title", - "label": "title", - "type": "text", - "id": "u:42008b37f675", - "placeholder": "-" - }, - { - "type": "date", - "label": "updatedAt", - "name": "updatedAt", - "id": "u:16543dd9aeeb", - "placeholder": "-", - "width": 30 - } - ], - "id": "u:02d4702494c8", "messages": {}, "filter": { "title": "查询条件", @@ -1187,6 +1297,460 @@ }, "withDefaultData": false, "dataMapSwitch": false + }, + "modal-ref-2": { + "type": "drawer", + "title": "接口设定V2", + "body": [ + { + "type": "form", + "id": "u:22425dc65951", + "api": { + "method": "post", + "url": "/c/save/apiInfo", + "messages": {}, + "requestAdaptor": "try {\r\n var resultList = [];\r\n var obj = context.dataRelMap;\r\n for (const key in obj) {\r\n if (!obj.hasOwnProperty(key)) {\r\n continue;\r\n }\r\n var value = obj[key];\r\n const valueList = Array.isArray(value) ? value : [value];\r\n\r\n if (valueList.length === 0) {\r\n console.warn(`Key '${key}' has empty array`);\r\n continue;\r\n }\r\n\r\n valueList.forEach(item => {\r\n if (item != null) {\r\n if (typeof item === 'object') {\r\n resultList.push({\r\n topic: key,\r\n ...item\r\n });\r\n } else {\r\n resultList.push({\r\n topic: key,\r\n value: item\r\n });\r\n }\r\n }\r\n });\r\n };\r\n context['dataRels'] = resultList;\r\n} catch (e) {\r\n console.log(e);\r\n}\r\n\r\nreturn api;", + "adaptor": "", + "dataType": "json" + }, + "title": "编辑数据", + "mode": "flex", + "labelAlign": "top", + "dsType": "api", + "feat": "Edit", + "body": [ + { + "type": "input-text", + "row": 0, + "name": "id", + "label": "id", + "id": "u:237473abc372", + "visible": false, + "hidden": false, + "colSize": "1" + }, + { + "type": "input-text", + "row": 0, + "name": "status", + "label": "status", + "id": "u:9735be1d8579", + "visible": false, + "hidden": false, + "colSize": "1" + }, + { + "row": 1, + "type": "grid", + "id": "u:b8e819c495eb", + "columns": [ + { + "body": [ + { + "type": "input-text", + "row": 2, + "id": "u:ba1548d04809", + "label": "接口名", + "name": "title", + "onEvent": { + "change": { + "weight": 0, + "actions": [] + } + }, + "labelAlign": "left", + "wrapperCustomStyle": { + "root": { + "margin-top": "12px", + "margin-bottom": "6px" + } + } + }, + { + "name": "url", + "label": "url", + "row": 3, + "type": "input-url", + "id": "u:9bd95f9ca5ad", + "value": "", + "labelAlign": "left", + "wrapperCustomStyle": { + "root": { + "margin-bottom": "6px", + "margin-top": "6px" + } + }, + "required": true + }, + { + "type": "select", + "name": "queryType", + "label": "请求方式", + "id": "u:c73492bfeb01", + "row": 4, + "options": [ + { + "label": "GET", + "value": 11 + }, + { + "label": "POST", + "value": 12 + } + ], + "multiple": false, + "labelAlign": "left", + "value": 11, + "wrapperCustomStyle": { + "root": { + "margin-top": "7px", + "margin-bottom": "5px" + } + } + } + ], + "id": "u:0828375407aa", + "md": 7 + }, + { + "body": [ + { + "type": "textarea", + "label": "备注", + "name": "remark", + "id": "u:b8c886b167a3", + "minRows": 3, + "maxRows": 20, + "showCounter": true, + "themeCss": { + "labelClassName": { + "padding-and-margin:default": {} + } + } + } + ], + "id": "u:6b35396a8088" + } + ], + "gap": "base", + "wrapperCustomStyle": {}, + "themeCss": { + "baseControlClassName": { + "padding-and-margin:default": { + "marginTop": "var(--sizes-size-0)", + "paddingTop": "var(--sizes-size-0)", + "marginBottom": "var(--sizes-size-0)", + "paddingBottom": "var(--sizes-size-0)" + } + } + } + }, + { + "type": "input-table", + "columns": [ + { + "id": "u:0f712b46e01b", + "label": "id", + "name": "id", + "quickEdit": false, + "inline": true, + "visible": false, + "placeholder": "-", + "hidden": true, + "width": 1 + }, + { + "id": "u:600e240e8211", + "label": "title", + "name": "title", + "quickEdit": { + "type": "input-text", + "name": "title", + "mode": "popOver" + }, + "type": "text", + "placeholder": "-" + }, + { + "label": "dataType", + "name": "dataType", + "quickEdit": { + "type": "wrapper", + "id": "u:735d6f9d6fef", + "mode": "popOver", + "body": [ + { + "type": "select", + "name": "dataType", + "id": "u:a309dfa43b00", + "multiple": false, + "source": { + "url": "/dataType", + "method": "get", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "cache": 120000 + }, + "labelField": "title", + "valueField": "value" + } + ], + "style": { + "position": "static", + "display": "block" + }, + "isFixedHeight": false, + "isFixedWidth": false + }, + "type": "text", + "id": "u:488b2d50e1d1", + "placeholder": "-" + }, + { + "label": "defaultVal", + "name": "defaultVal", + "type": "text", + "quickEdit": { + "type": "input-text", + "name": "defaultVal", + "mode": "popOver" + }, + "id": "u:4f6793cda9ec", + "placeholder": "-" + }, + { + "label": "paramType", + "name": "paramType", + "type": "mapping", + "quickEdit": { + "type": "wrapper", + "mode": "popOver", + "body": [ + { + "type": "select", + "name": "paramType", + "id": "u:052605cb8eaa", + "multiple": false, + "options": [ + { + "label": "输出", + "value": "1" + }, + { + "label": "变量", + "value": "2" + }, + { + "label": "RequestParam", + "value": "10" + }, + { + "label": "RequestBody", + "value": "11" + } + ] + } + ], + "id": "u:c747e567e704", + "style": { + "position": "static", + "display": "block" + }, + "isFixedHeight": false, + "isFixedWidth": false + }, + "id": "u:f26dbe09803b", + "placeholder": "-", + "map": { + "1": "输出", + "2": "变量", + "10": "RequestParam", + "11": "RequestBody" + } + } + ], + "row": 5, + "id": "u:904bffd1aa6c", + "name": "apiParams", + "label": "参数设定", + "addable": true, + "footerAddBtn": { + "label": "新增", + "icon": "fa fa-plus", + "id": "u:66b4cc87ab85" + }, + "strictMode": true, + "removable": true, + "copyable": true, + "editable": true, + "columnsTogglable": false, + "draggable": true, + "labelRemark": { + "icon": "fa fa-question-circle", + "trigger": [ + "hover" + ], + "className": "Remark--warning", + "placement": "top", + "title": "", + "content": "执行方法对应的参数将自动加载,但执行条件中的SPEL表达式则需要添加;此位置中的参数优先级高于执行方法对应的参数" + }, + "className": "m-t-none p-none", + "labelClassName": "" + }, + { + "type": "input-table", + "name": "dataRelMap.funInfo", + "label": "执行方法", + "columns": [ + { + "label": "id", + "name": "id", + "quickEdit": false, + "id": "u:bbf14d9c82e6", + "inline": true, + "visible": false + }, + { + "label": "groupId", + "name": "groupId", + "quickEdit": false, + "id": "u:6b63cd2cff0e", + "inline": true, + "visible": false + }, + { + "label": "方法名", + "name": "target", + "quickEdit": { + "type": "nested-select", + "id": "u:e44cd55f6f85", + "mode": "popOver", + "name": "target", + "searchable": true, + "onlyLeaf": true, + "multiple": false, + "required": true, + "source": "/q/findList/funInfo", + "labelField": "title", + "valueField": "id" + }, + "type": "mapping", + "id": "u:1cf9ce550ba8", + "placeholder": "-" + }, + { + "label": "执行条件", + "name": "dataExp", + "type": "text", + "quickEdit": { + "type": "input-text", + "name": "dataExp", + "mode": "popOver", + "id": "u:41746ea74549", + "placeholder": "为空表示为真" + }, + "id": "u:87dba633b728", + "placeholder": "-" + } + ], + "addable": true, + "footerAddBtn": { + "label": "新增", + "icon": "fa fa-plus", + "id": "u:dd16a0af55b6" + }, + "strictMode": true, + "id": "u:5656119074bf", + "removable": true, + "copyable": true, + "row": 6, + "labelRemark": { + "icon": "fa fa-question-circle", + "trigger": [ + "hover" + ], + "className": "Remark--warning", + "placement": "right", + "title": "", + "content": "执行第一个匹配成功的" + }, + "needConfirm": false, + "required": true, + "draggable": true + } + ], + "resetAfterSubmit": true, + "actions": [ + { + "type": "button", + "actionType": "cancel", + "label": "取消" + }, + { + "type": "button", + "actionType": "submit", + "label": "提交", + "level": "primary" + } + ], + "onEvent": { + "submitSucc": { + "actions": [ + { + "actionType": "search", + "groupType": "component", + "componentId": "u:d6b3f2f118a6" + } + ] + } + }, + "initApi": { + "url": "/q/findOne/apiInfo", + "method": "get", + "requestAdaptor": "", + "adaptor": "var dataRelMap = {};\r\nvar list = payload.data['dataRels'];\r\nconsole.log(list);\r\nlist.forEach((item, index) => {\r\n if (item && typeof item === 'object') {\r\n const key = item['topic'];\r\n\r\n if (key !== undefined && key !== null) {\r\n const { ['topic']: _, ...rest } = item;\r\n\r\n if (!dataRelMap[key]) {\r\n dataRelMap[key] = [];\r\n }\r\n dataRelMap[key].push(rest);\r\n } \r\n }\r\n});\r\npayload.data['dataRelMap'] = dataRelMap;\r\nreturn payload;", + "messages": {}, + "sendOn": "${!ISEMPTY(id)}", + "data": { + "pkey": "${id}" + } + }, + "debug": false, + "staticOn": "${AND(statesCode == 200,AND(queryType>10,queryType<20))}" + } + ], + "id": "u:e02b88dc8778", + "showCloseButton": false, + "closeOnOutside": false, + "closeOnEsc": false, + "showErrorMsg": true, + "showLoading": true, + "draggable": false, + "actionType": "drawer", + "actions": [ + { + "type": "button", + "actionType": "cancel", + "label": "取消", + "id": "u:d67b62d4814d" + }, + { + "type": "button", + "actionType": "submit", + "label": "提交", + "level": "primary", + "id": "u:780304c8c416" + } + ], + "size": "xl", + "resizable": false, + "width": "80%", + "editorSetting": { + "displayName": "接口设定V2" + }, + "position": "left" } } } \ No newline at end of file diff --git a/apis/viewer-apis-client/src/main/resources/static/html/pages/env.json b/apis/viewer-apis-client/src/main/resources/static/html/pages/env.json new file mode 100644 index 0000000000000000000000000000000000000000..95f5057b0651c622d476b68e5d1215170634f91b --- /dev/null +++ b/apis/viewer-apis-client/src/main/resources/static/html/pages/env.json @@ -0,0 +1,888 @@ +{ + "type": "page", + "title": "datalist", + "body": [ + { + "type": "tabs", + "id": "u:08cf293c461d", + "tabs": [ + { + "title": "缓存配置", + "body": [ + { + "type": "crud", + "id": "u:de6b50f4ffa6", + "syncLocation": false, + "api": { + "method": "get", + "url": "/q/findList/envVars", + "requestAdaptor": "", + "adaptor": "if (Object.keys(payload).length === 0) return payload;\r\nvar data = payload.data;\r\nconsole.log(data)\r\nif (Array.isArray(data) && data.length < 1) return payload;\r\n// data.forEach((item, index) => {\r\n// if (Object.keys(index.payload).length === 0) continue;\r\n// index[\"payload\"] = JSON.parse(index.payload);\r\n// console.log(index);\r\n// });\r\nfor (let i = 0; i < data.length; i++) {\r\n const item = data[i];\r\n console.log(`第${i}个对象:`, item);\r\n item[\"payload\"] = JSON.parse(item.payload);\r\n}\r\nconsole.log(data)\r\nreturn payload;", + "messages": {}, + "data": { + "topic": "CacheInfo" + } + }, + "bulkActions": [], + "itemActions": [ + { + "label": "修改", + "type": "button", + "id": "u:a5dd83fa85a0", + "onEvent": { + "click": { + "weight": 0, + "actions": [ + { + "ignoreError": false, + "actionType": "drawer", + "drawer": { + "$ref": "modal-ref-1" + } + } + ] + } + } + }, + { + "label": "删除", + "type": "button", + "id": "u:921331af149e", + "level": "default", + "themeCss": { + "className": { + "font:default": { + "color": "#da0c0c" + } + } + }, + "onEvent": { + "click": { + "weight": 0, + "actions": [ + { + "actionType": "ajax", + "api": { + "url": "/c/delete/envVars", + "method": "post", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "dataType": "form-data", + "data": { + "pkey": "${id}" + } + }, + "outputVar": "responseResult", + "options": {} + }, + { + "componentId": "u:de6b50f4ffa6", + "ignoreError": false, + "actionType": "reload" + } + ] + } + }, + "confirmText": "确认要删除数据" + } + ], + "headerToolbar": [ + { + "label": "新增", + "type": "button", + "level": "primary", + "id": "u:99c393f36c44", + "onEvent": { + "click": { + "weight": 0, + "actions": [ + { + "ignoreError": false, + "actionType": "drawer", + "drawer": { + "$ref": "modal-ref-1" + } + } + ] + } + } + } + ], + "messages": {}, + "initFetch": true, + "loadDataOnce": true, + "matchFunc": "", + "footerToolbar": [], + "pageField": "", + "perPageField": "", + "showFooter": false, + "filter": null, + "showHeader": true, + "columnsTogglable": false, + "columns": [ + { + "name": "id", + "label": "ID", + "type": "text", + "id": "u:a7711ef94541", + "placeholder": "-", + "width": 1, + "inline": true, + "visible": false, + "hidden": true + }, + { + "name": "payload.title", + "label": "标题", + "type": "text", + "id": "u:81d904405c8e", + "placeholder": "-", + "inline": true + }, + { + "type": "text", + "label": "cacheType", + "name": "payload.cacheType", + "id": "u:0e637ae97972", + "inline": true, + "filterable": { + "searchable": true, + "options": [ + { + "label": "redis", + "value": "redis" + }, + { + "label": "caffeine", + "value": "caffeine" + }, + { + "label": "cacheSet", + "value": "cacheSet" + } + ] + }, + "placeholder": "-" + }, + { + "type": "text", + "label": "updatedAt", + "name": "updatedAt", + "id": "u:3253b3612d89", + "placeholder": "-", + "inline": true, + "width": "25%" + } + ], + "onEvent": { + "fetchInited": { + "weight": 0, + "actions": [ + { + "ignoreError": false, + "actionType": "setValue", + "args": { + "value": "${event.data.responseData}", + "path": "global.AllCaches" + } + } + ] + } + } + } + ], + "id": "u:89886b1773be", + "mountOnEnter": true, + "unmountOnExit": true + }, + { + "title": "异常设定", + "body": [ + { + "id": "u:08c853828ea8", + "type": "form", + "title": "", + "mode": "flex", + "labelAlign": "top", + "dsType": "api", + "feat": "Edit", + "body": [ + { + "name": "id", + "label": "id", + "row": 0, + "type": "input-text", + "id": "u:4d680cd17eee", + "value": "excEnvVar", + "visible": false, + "colSize": "1/3", + "labelAlign": "left" + }, + { + "name": "type", + "label": "type", + "row": 0, + "type": "input-text", + "id": "u:961e5b2f0ce4", + "value": "0", + "visible": false, + "colSize": "1/3", + "labelAlign": "left" + }, + { + "name": "topic", + "label": "topic", + "row": 0, + "type": "input-text", + "id": "u:6617f7d56b49", + "value": "excEnvVar", + "visible": false, + "colSize": "1/3", + "labelAlign": "left" + }, + { + "name": "pbo.saveNums", + "label": "异常条数保存条数", + "row": 1, + "type": "input-number", + "id": "u:b62358ca5202", + "keyboard": true, + "step": 1, + "colSize": "1", + "labelAlign": "top", + "min": -1, + "value": -1 + }, + { + "name": "pbo.saveTimes", + "label": "异常条数保存时长", + "row": 2, + "type": "input-number", + "id": "u:49006a5f27fb", + "keyboard": true, + "step": 1, + "value": -1, + "min": -1 + }, + { + "name": "pbo.useSave", + "label": "启用异常存储", + "row": 3, + "type": "switch", + "id": "u:945b208f8f0f", + "value": true, + "mode": "horizontal" + } + ], + "actions": [ + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "u:08c853828ea8" + } + ] + } + }, + "level": "default", + "id": "u:7ef54e7daf91" + }, + { + "type": "button", + "label": "提交", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "submit", + "componentId": "u:08c853828ea8" + } + ] + } + }, + "level": "primary", + "id": "u:d6f584711a98" + } + ], + "resetAfterSubmit": true, + "initApi": { + "method": "get", + "url": "q/findOne/envVars", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "data": { + "pkey": "${id}" + } + }, + "api": { + "url": "/c/save/envVars", + "method": "post", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "dataType": "json" + }, + "debug": false + } + ], + "id": "u:d0c595bc32f2", + "mountOnEnter": true, + "unmountOnExit": true, + "reload": true + }, + { + "title": "修改记录", + "body": [ + { + "type": "form", + "id": "u:c91c599be5df", + "title": "", + "mode": "flex", + "labelAlign": "top", + "dsType": "api", + "feat": "Edit", + "body": [ + { + "name": "pbo.saveNums", + "label": "保存条数", + "row": 2, + "type": "input-number", + "id": "u:f983f4456bd9", + "keyboard": true, + "step": 1, + "value": -1, + "min": -1 + }, + { + "name": "pbo.saveTimes", + "label": "保存时长", + "row": 3, + "type": "input-number", + "id": "u:2c26b4ce3cbe", + "keyboard": true, + "step": 1, + "value": -1, + "min": -1 + }, + { + "name": "pbo.useSave", + "label": "启用历史存储", + "row": 4, + "type": "switch", + "id": "u:99923399c065", + "value": true + }, + { + "name": "id", + "label": "id", + "row": 0, + "type": "input-text", + "id": "u:4768d0e57eb5", + "visible": false, + "hidden": false, + "colSize": "1/3", + "value": "logEnvVar", + "readOnly": false, + "autoFill": {}, + "labelAlign": "left" + }, + { + "name": "type", + "label": "type", + "row": 0, + "type": "input-text", + "id": "u:a1c1e3553ba2", + "visible": false, + "hidden": false, + "colSize": "1/3", + "value": "0", + "labelAlign": "left", + "clearValueOnHidden": false + }, + { + "name": "topic", + "label": "topic", + "row": 0, + "type": "input-text", + "id": "u:1b321053675e", + "visible": false, + "hidden": false, + "colSize": "1/3", + "value": "logEnvVar", + "labelAlign": "left" + } + ], + "actions": [ + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "u:c91c599be5df" + } + ] + } + }, + "level": "default", + "id": "u:aeaf4961a4ae" + }, + { + "type": "button", + "label": "提交", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "submit", + "componentId": "u:c91c599be5df" + } + ] + } + }, + "level": "primary", + "id": "u:33658b0bb09b" + } + ], + "resetAfterSubmit": true, + "initApi": { + "method": "get", + "url": "getEnvVars", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "data": { + "varId": "${id}" + } + }, + "api": { + "url": "/c/save/envVars", + "method": "post", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "dataType": "json" + }, + "debug": false + } + ], + "id": "u:1c426fd79cdd", + "mountOnEnter": false, + "unmountOnExit": true, + "reload": true + } + ], + "mountOnEnter": false, + "tabsMode": "vertical", + "unmountOnExit": false, + "onEvent": { + "change": { + "weight": 0, + "actions": [] + } + } + } + ], + "id": "u:7a693302428f", + "asideResizor": false, + "pullRefresh": { + "disabled": true + }, + "regions": [ + "body" + ], + "definitions": { + "modal-ref-1": { + "type": "drawer", + "title": "缓存设定", + "body": [ + { + "id": "u:ea89f901f184", + "type": "form", + "title": "表单", + "mode": "horizontal", + "labelAlign": "left", + "dsType": "api", + "feat": "Edit", + "body": [ + { + "name": "id", + "label": "id", + "type": "input-text", + "id": "u:822053c15a39", + "visible": false + }, + { + "name": "topic", + "label": "topic", + "type": "input-text", + "id": "u:90a969f11d62", + "visible": false, + "value": "cacheInfo" + }, + { + "name": "type", + "label": "type", + "type": "input-text", + "id": "u:b772982b153d", + "visible": false, + "value": "0" + }, + { + "name": "pbo.title", + "label": "标题", + "type": "input-text", + "id": "u:4fd061567c22" + }, + { + "type": "input-number", + "label": "expireSeconds", + "name": "pbo.expireSeconds", + "id": "u:fd66baaf1d1d", + "keyboard": true, + "step": 1 + }, + { + "type": "select", + "label": "cacheType", + "name": "pbo.cacheType", + "id": "u:4a8e26c6e14e", + "options": [ + { + "label": "redis", + "value": "redis" + }, + { + "label": "caffeine", + "value": "caffeine" + }, + { + "label": "cacheSet", + "value": "cacheSet" + } + ], + "multiple": false, + "required": true, + "selectFirst": true, + "value": "caffeine" + }, + { + "type": "switch-container", + "items": [ + { + "title": "状态一", + "body": [ + { + "type": "grid", + "columns": [ + { + "body": [ + { + "type": "input-text", + "label": "Host", + "name": "pbo.host", + "id": "u:bd2768750863", + "mode": "normal", + "labelAlign": "top", + "required": true, + "clearValueOnHidden": true, + "showCounter": false, + "validations": {}, + "validationErrors": {} + } + ], + "id": "u:3632a9648794", + "md": 9 + }, + { + "body": [ + { + "type": "input-number", + "label": "Port", + "name": "pbo.port", + "keyboard": true, + "id": "u:fca8ef236344", + "step": 1, + "mode": "normal", + "labelAlign": "top", + "max": 65535, + "precision": "", + "min": 1, + "required": true, + "clearValueOnHidden": true + } + ], + "id": "u:1cf8beec5676", + "md": "" + } + ], + "id": "u:0bad78fff330" + }, + { + "type": "grid", + "columns": [ + { + "body": [ + { + "type": "input-text", + "label": "Username", + "name": "pbo.username", + "id": "u:a6052a41f3fa", + "mode": "normal", + "labelAlign": "top", + "clearValueOnHidden": true + } + ], + "id": "u:ecf3d053118d", + "md": "" + }, + { + "body": [ + { + "type": "input-password", + "label": "Password", + "name": "pbo.password", + "id": "u:7ac618101181", + "keyboard": true, + "step": 1, + "showCounter": false, + "validations": {}, + "validationErrors": {}, + "mode": "normal", + "labelAlign": "top", + "clearValueOnHidden": true + } + ], + "id": "u:b59b1c45c38b", + "md": "" + } + ], + "id": "u:4d5b7835bdfc" + }, + { + "type": "input-number", + "label": "database", + "name": "pbo.database", + "keyboard": true, + "id": "u:159d79ad0b9d", + "step": 1, + "max": 16, + "min": 0, + "clearValueOnHidden": true, + "themeCss": { + "labelClassName": { + "padding-and-margin:default": { + "marginTop": "var(--sizes-size-5)" + } + }, + "inputControlClassName": { + "padding-and-margin:default": { + "marginTop": "var(--sizes-size-5)" + } + } + } + }, + { + "type": "input-number", + "label": "timeout", + "name": "pbo.timeout", + "keyboard": true, + "id": "u:5bee77b67753", + "step": 1, + "max": 16, + "min": 0, + "clearValueOnHidden": true + } + ], + "id": "u:603427a10ea4", + "editing": true, + "index": 0, + "visibleOn": "${pbo.cacheType === `redis`}" + }, + { + "title": "状态二", + "body": [ + { + "type": "input-number", + "label": "initial", + "name": "pbo.initial", + "keyboard": true, + "id": "u:2549977877db", + "step": 1, + "clearValueOnHidden": true + }, + { + "type": "input-number", + "label": "max", + "name": "pbo.max", + "keyboard": true, + "id": "u:daea711a619a", + "step": 1, + "clearValueOnHidden": true + } + ], + "id": "u:3269b94237ff", + "editing": true, + "index": 1, + "visibleOn": "${pbo.cacheType === `caffeine`}" + }, + { + "title": "状态", + "body": [ + { + "type": "combo", + "label": "缓存组合", + "name": "pbo.cacheIdList", + "multiple": true, + "addable": true, + "removable": true, + "removableMode": "icon", + "addBtn": { + "label": "新增", + "icon": "fa fa-plus", + "level": "primary", + "size": "sm", + "id": "u:a88bfbd47f00" + }, + "items": [ + { + "type": "select", + "name": "select", + "placeholder": "选项", + "id": "u:5ec1154631cd", + "multiple": false, + "source": { + "method": "get", + "url": "envsWithTopic", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "data": { + "topic": "cacheInfo" + } + }, + "labelField": "pbo", + "valueField": "id", + "required": true + } + ], + "id": "u:2df6305709db", + "strictMode": true, + "syncFields": [], + "flat": true, + "joinValues": false, + "draggable": true, + "required": true + } + ], + "id": "u:7c972598b208", + "visibleOn": "${pbo.cacheType===\"cacheSet\"}" + } + ], + "style": { + "position": "static", + "display": "block" + }, + "id": "u:1716c288f5e5", + "isFixedHeight": false, + "isFixedWidth": false + } + ], + "api": { + "url": "/c/save/envVars", + "method": "post", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "dataType": "json" + }, + "resetAfterSubmit": true, + "actions": [ + { + "type": "button", + "label": "提交", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "submit", + "componentId": "u:ea89f901f184" + } + ] + } + }, + "level": "primary" + } + ], + "initApi": { + "url": "/q/findOne/envVars", + "method": "get", + "requestAdaptor": "", + "adaptor": "if (Object.keys(payload).length === 0) return payload;\r\nvar data = payload.data;\r\ndata[\"payload\"] = JSON.parse(data.payload);\r\nconsole.log(data)\r\nreturn payload;", + "messages": {}, + "data": { + "pkey": "${id}" + }, + "sendOn": "${!ISEMPTY(id)}" + }, + "debug": true + } + ], + "actions": [ + { + "type": "button", + "actionType": "cancel", + "label": "取消", + "id": "u:e6e19d291dc9" + }, + { + "type": "button", + "actionType": "confirm", + "label": "确定", + "id": "u:4415cbce6090", + "primary": true, + "reload": "u:de6b50f4ffa6" + } + ], + "actionType": "drawer", + "id": "u:f76d90e20e33", + "showCloseButton": true, + "closeOnOutside": false, + "closeOnEsc": false, + "showErrorMsg": true, + "showLoading": true, + "draggable": false, + "resizable": false, + "onEvent": { + "confirm": { + "weight": 0, + "actions": [ + { + "componentId": "u:de6b50f4ffa6", + "actionType": "reload", + "args": {}, + "groupType": "component" + } + ] + } + } + } + }, + "initApi": { + "url": "", + "method": "get", + "requestAdaptor": "", + "adaptor": "", + "messages": {} + }, + "aside": [], + "data": {} +} \ No newline at end of file diff --git a/apis/viewer-apis-client/src/main/resources/static/html/pages/exportDataInfo.json b/apis/viewer-apis-client/src/main/resources/static/html/pages/exportDataInfo.json index b71f6fdcc810879d0ccdb84f1598d96512f255f5..ea47e75c353bdaa66e9c88ccb8c9960741d79906 100644 --- a/apis/viewer-apis-client/src/main/resources/static/html/pages/exportDataInfo.json +++ b/apis/viewer-apis-client/src/main/resources/static/html/pages/exportDataInfo.json @@ -251,7 +251,7 @@ "multiple": false, "source": { "method": "get", - "url": "/file/template", + "url": "/file/templates", "requestAdaptor": "", "adaptor": "", "messages": {} diff --git a/apis/viewer-apis-client/src/main/resources/static/html/pages/funInfo.json b/apis/viewer-apis-client/src/main/resources/static/html/pages/funInfo.json new file mode 100644 index 0000000000000000000000000000000000000000..655996c18cab8523a11d2b4d847b6eb25f472194 --- /dev/null +++ b/apis/viewer-apis-client/src/main/resources/static/html/pages/funInfo.json @@ -0,0 +1,1627 @@ +{ + "type": "page", + "body": [ + { + "type": "crud2", + "id": "u:d6b3f2f118a6", + "dsType": "api", + "api": { + "url": "/q/findList/funInfo", + "method": "get" + }, + "mode": "table2", + "syncLocation": true, + "primaryField": "id", + "loadType": "", + "quickSaveItemApi": { + "url": "/c/save/queryBody", + "method": "post", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "dataType": "json" + }, + "filter": { + "type": "form", + "title": "条件查询", + "mode": "inline", + "columnCount": 3, + "clearValueOnHidden": true, + "behavior": [ + "SimpleQuery" + ], + "body": [ + { + "name": "title", + "label": "title", + "type": "input-text", + "size": "full", + "required": false, + "behavior": "SimpleQuery", + "id": "u:8902beccd2d7" + }, + { + "name": "remark", + "label": "remark", + "type": "input-text", + "size": "full", + "required": false, + "behavior": "SimpleQuery", + "id": "u:a117f7305e9c" + } + ], + "actions": [ + { + "type": "button", + "label": "新增", + "onEvent": { + "click": { + "actions": [ + { + "ignoreError": false, + "actionType": "drawer", + "drawer": { + "$ref": "modal-ref-1" + } + } + ] + } + }, + "id": "u:48f65763bc82" + }, + { + "type": "reset", + "label": "重置", + "id": "u:0b137f850d9f" + }, + { + "type": "submit", + "label": "查询", + "level": "primary", + "id": "u:a6320fbacffc" + } + ], + "id": "u:6af17830696b", + "feat": "Insert" + }, + "headerToolbar": [], + "footerToolbar": [], + "columns": [ + { + "type": "tpl", + "title": "id", + "name": "id", + "id": "u:10f4e7e05418", + "placeholder": "-", + "width": 1, + "visible": false, + "hidden": true + }, + { + "type": "tpl", + "title": "title", + "name": "title", + "id": "u:7b5904fba5cc", + "placeholder": "-", + "width": "30%" + }, + { + "type": "tpl", + "title": "remark", + "name": "remark", + "id": "u:968da5f1938e", + "placeholder": "-" + }, + { + "type": "tpl", + "title": "updatedAt", + "name": "updatedAt", + "id": "u:0c07bb68b2d3", + "placeholder": "-", + "width": "16%" + }, + { + "type": "operation", + "title": "操作", + "id": "u:e2ed8df96baa", + "width": "12%", + "buttons": [ + { + "type": "button", + "label": "编辑", + "level": "link", + "behavior": "Edit", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "drawer", + "drawer": { + "$ref": "modal-ref-1" + } + } + ] + } + }, + "id": "u:89db420d516e" + }, + { + "type": "button", + "label": "删除", + "level": "link", + "behavior": "Delete", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "ajax", + "outputVar": "responseResult", + "options": {}, + "api": { + "url": "/c/delete/funInfo", + "method": "post", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "data": { + "pkey": "${id}" + }, + "dataType": "form-data" + } + }, + { + "actionType": "search", + "groupType": "component", + "componentId": "u:d6b3f2f118a6" + } + ] + } + }, + "id": "u:a573a1548749", + "className": "m-r-xs text-danger", + "confirmText": "确认要删除数据" + }, + { + "label": "测试", + "level": "light", + "id": "u:2c00c0ce2087", + "type": "button", + "behavior": "Edit", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "drawer", + "drawer": { + "$ref": "modal-ref-1" + } + } + ] + } + }, + "visible": false + } + ] + } + ], + "editorSetting": { + "mock": { + "enable": true, + "maxDisplayRows": 5 + } + }, + "showHeader": true, + "autoFillHeight": true + } + ], + "id": "u:2100b771c123", + "asideResizor": false, + "pullRefresh": { + "disabled": true + }, + "dsType": "api", + "editorSetting": { + "mock": { + "enable": true, + "maxDisplayRows": 5 + } + }, + "regions": [ + "body" + ], + "definitions": { + "modal-ref-1": { + "type": "drawer", + "body": [ + { + "id": "u:22425dc65951", + "type": "form", + "title": "编辑数据", + "mode": "flex", + "labelAlign": "top", + "dsType": "api", + "feat": "Edit", + "body": [ + { + "name": "id", + "label": "id", + "row": 0, + "type": "input-text", + "id": "u:237473abc372", + "visible": false, + "hidden": false + }, + { + "name": "title", + "label": "title", + "row": 1, + "type": "input-text", + "id": "u:ba1548d04809", + "onEvent": { + "change": { + "weight": 0, + "actions": [] + } + } + }, + { + "type": "input-table", + "name": "params", + "label": "参数设定", + "id": "u:904bffd1aa6c", + "columns": [ + { + "label": "id", + "name": "id", + "quickEdit": false, + "id": "u:0f712b46e01b", + "placeholder": "-", + "inline": true, + "visible": false, + "hidden": true, + "width": 1 + }, + { + "label": "title", + "name": "title", + "quickEdit": { + "type": "input-text", + "name": "title", + "mode": "popOver" + }, + "type": "text", + "id": "u:600e240e8211", + "placeholder": "-" + }, + { + "label": "dataType", + "name": "dataType", + "quickEdit": { + "type": "wrapper", + "mode": "popOver", + "body": [ + { + "type": "select", + "name": "dataType", + "id": "u:a309dfa43b00", + "multiple": false, + "source": { + "url": "/dataType", + "method": "get", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "cache": 120000 + }, + "labelField": "title", + "valueField": "value" + } + ], + "id": "u:735d6f9d6fef", + "style": { + "position": "static", + "display": "block" + }, + "isFixedHeight": false, + "isFixedWidth": false + }, + "type": "text", + "id": "u:488b2d50e1d1", + "placeholder": "-" + }, + { + "label": "defaultVal", + "name": "defaultVal", + "type": "text", + "quickEdit": { + "type": "input-text", + "name": "defaultVal", + "mode": "popOver" + }, + "id": "u:4f6793cda9ec", + "placeholder": "-" + }, + { + "label": "paramType", + "name": "paramType", + "type": "mapping", + "quickEdit": { + "type": "wrapper", + "mode": "popOver", + "body": [ + { + "type": "select", + "name": "paramType", + "id": "u:052605cb8eaa", + "multiple": false, + "options": [ + { + "label": "输入", + "value": "0" + }, + { + "label": "输出", + "value": "1" + }, + { + "label": "内部", + "value": "2" + } + ], + "selectFirst": true + } + ], + "id": "u:c747e567e704", + "style": { + "position": "static", + "display": "block", + "fontFamily": "", + "fontSize": 12 + }, + "isFixedHeight": false, + "isFixedWidth": false + }, + "id": "u:f26dbe09803b", + "placeholder": "-", + "map": { + "0": "输入", + "1": "输出", + "2": "内部" + } + } + ], + "addable": true, + "footerAddBtn": { + "label": "新增", + "icon": "fa fa-plus", + "id": "u:66b4cc87ab85" + }, + "strictMode": true, + "copyable": true, + "editable": true, + "removable": true, + "columnsTogglable": false, + "draggable": true + }, + { + "type": "crud", + "id": "u:9a2552614c4b", + "columns": [ + { + "name": "id", + "label": "ID", + "id": "u:1e7e617a5d94", + "placeholder": "-", + "type": "text", + "width": 1, + "toggled": false + }, + { + "name": "title", + "label": "title", + "type": "text", + "id": "u:a1287fa03d46", + "placeholder": "-" + }, + { + "type": "text", + "label": "queryTitle", + "name": "queryTitle", + "id": "u:064b2f704eaf", + "placeholder": "-" + }, + { + "type": "operation", + "label": "操作", + "id": "u:74186454db5d", + "placeholder": "-", + "width": "15%", + "buttons": [ + { + "type": "button", + "label": "删除", + "level": "link", + "className": "text-danger", + "id": "u:2baa04017f90", + "onEvent": { + "click": { + "weight": 0, + "actions": [ + { + "ignoreError": false, + "actionType": "ajax", + "outputVar": "responseResult", + "options": {}, + "api": { + "url": "/c/delete/queryBlock", + "method": "post", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "data": { + "pkey": "${id}" + }, + "dataType": "form-data" + } + }, + { + "componentId": "u:9a2552614c4b", + "ignoreError": false, + "actionType": "reload", + "outputVar": "", + "args": { + "resetPage": true + } + } + ] + } + } + }, + { + "label": "编辑", + "type": "button", + "level": "link", + "id": "u:26b15c904a26", + "onEvent": { + "click": { + "weight": 0, + "actions": [ + { + "ignoreError": false, + "actionType": "dialog", + "data": { + "&": "$$", + "index": "${index}" + }, + "dialog": { + "$ref": "modal-ref-5" + } + } + ] + } + } + }, + { + "label": "添加", + "type": "button", + "level": "link", + "id": "u:b68a32e07fe5", + "onEvent": { + "click": { + "weight": 0, + "actions": [ + { + "ignoreError": false, + "actionType": "dialog", + "dialog": { + "$ref": "modal-ref-5" + }, + "data": { + "funInfoId": "${id}", + "index": "${index+1}" + } + } + ] + } + } + } + ] + } + ], + "syncLocation": false, + "api": { + "method": "get", + "url": "/q/findList/blockInfo", + "messages": {}, + "requestAdaptor": "", + "adaptor": "", + "sendOn": "${!ISEMPTY(id)}", + "data": { + "pid": "${id}" + } + }, + "bulkActions": [], + "itemActions": [], + "headerToolbar": [ + { + "label": "新增", + "type": "button", + "level": "primary", + "id": "u:a7d3e67b1405", + "onEvent": { + "click": { + "weight": 0, + "actions": [ + { + "ignoreError": false, + "actionType": "dialog", + "dialog": { + "$ref": "modal-ref-5" + }, + "data": { + "funInfoId": "${id}", + "index": "${count}" + } + } + ] + } + } + }, + { + "type": "button", + "tpl": "内容", + "wrapperComponent": "", + "id": "u:5fad74206dcd", + "label": "刷新", + "onEvent": { + "click": { + "weight": 0, + "actions": [ + { + "componentId": "u:9a2552614c4b", + "ignoreError": false, + "actionType": "reload", + "outputVar": "", + "args": { + "resetPage": true + } + } + ] + } + } + } + ], + "messages": {}, + "loadDataOnce": true, + "matchFunc": "", + "footerToolbar": [], + "perPageField": "", + "pageField": "", + "showFooter": false, + "hiddenOn": "${ISEMPTY(id)}", + "draggable": true, + "saveOrderApi": { + "url": "/qb/sort", + "method": "post", + "messages": {}, + "requestAdaptor": "var ids = api.data.ids\r\napi.data = {};\r\napi.data = ids.split(\",\");\r\nreturn api;", + "adaptor": "", + "dataType": "json" + } + } + ], + "api": { + "url": "/c/save/funInfo", + "method": "post", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "dataType": "json" + }, + "resetAfterSubmit": true, + "actions": [ + { + "type": "button", + "actionType": "cancel", + "label": "取消" + }, + { + "type": "button", + "actionType": "submit", + "label": "提交", + "level": "primary" + } + ], + "onEvent": { + "submitSucc": { + "actions": [ + { + "actionType": "search", + "groupType": "component", + "componentId": "u:d6b3f2f118a6" + } + ] + } + }, + "initApi": { + "url": "/q/findOne/funInfo", + "method": "get", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "sendOn": "${!ISEMPTY(id)}", + "data": { + "pkey": "${id}" + } + }, + "debug": false + } + ], + "title": "方法设定", + "size": "xl", + "actions": [ + { + "type": "button", + "actionType": "cancel", + "label": "取消", + "id": "u:d67b62d4814d" + }, + { + "type": "button", + "actionType": "submit", + "label": "提交", + "level": "primary", + "id": "u:780304c8c416" + } + ], + "actionType": "drawer", + "id": "u:e02b88dc8778", + "showCloseButton": true, + "closeOnOutside": false, + "closeOnEsc": false, + "showErrorMsg": true, + "showLoading": true, + "draggable": false, + "resizable": false, + "width": "80%", + "editorSetting": { + "displayName": "方法设定" + } + }, + "modal-ref-5": { + "type": "dialog", + "title": "查询块设定", + "body": [ + { + "type": "form", + "api": { + "method": "post", + "url": "/c/save/blockInfo", + "requestAdaptor": "api.data.dataStr = JSON.stringify(api.data.data);\r\nif (Object.prototype.hasOwnProperty.call(api.data, 'bodys')\r\n && Object.keys(api.data.bodys).length != 0) {\r\n api.data.bodys.forEach((ele) => {\r\n ele.paramsPayload = JSON.stringify(ele.params);\r\n });\r\n }\r\n\r\nreturn api;", + "adaptor": "", + "messages": {}, + "dataType": "json" + }, + "initApi": { + "method": "get", + "url": "/q/findOne/blockInfo", + "requestAdaptor": "", + "adaptor": "var baseData = payload.data;\r\nvar dataStr = baseData.dataStr;\r\nconsole.log(baseData);\r\nbaseData.data = {}\r\nif (!(!dataStr || dataStr.trim() === '')) {\r\n try {\r\n baseData.data = JSON.parse(dataStr);\r\n } catch (error) {\r\n console.error('JSON解析失败:', error);\r\n }\r\n}\r\n\r\nvar bodyArrs = baseData.bodys;\r\nif (bodyArrs != null && Array.isArray(bodyArrs) && bodyArrs.length > 0) {\r\n bodyArrs.forEach((ele) => {\r\n var paramsPayloadStr = ele.paramsPayload\r\n if (!paramsPayloadStr || paramsPayloadStr.trim() === '') {\r\n return;\r\n }\r\n try {\r\n console.log(paramsPayloadStr);\r\n ele.params = JSON.parse(paramsPayloadStr);\r\n } catch (error) {\r\n console.error('JSON解析失败:', error);\r\n }\r\n\r\n });\r\n}\r\nconsole.log(payload);\r\nreturn payload;", + "messages": {}, + "data": { + "pkey": "${id}" + }, + "sendOn": "${!ISEMPTY(id)}" + }, + "body": [ + { + "name": "id", + "label": "ID", + "type": "input-text", + "id": "u:947888999c29", + "visible": false + }, + { + "name": "pid", + "label": "pid", + "type": "input-text", + "id": "u:a89d087264be", + "value": "${funInfoId}", + "visible": false + }, + { + "type": "input-text", + "label": "orderNum", + "name": "orderNum", + "id": "u:b78705fdde19", + "value": "${IF(ISEMPTY(orderNum),index,orderNum)}", + "visible": false + }, + { + "type": "grid", + "columns": [ + { + "body": [ + { + "name": "title", + "label": "标题", + "type": "input-text", + "id": "u:d0cc8da15cff" + } + ], + "id": "u:1c4473c7db45", + "md": 7 + }, + { + "body": [ + { + "type": "radios", + "label": "单一值", + "name": "single", + "options": [ + { + "label": "多值", + "value": false + }, + { + "label": "单一值", + "value": true + } + ], + "id": "u:3c00a8ca60dc", + "selectFirst": true, + "value": false, + "mode": "inline" + } + ], + "id": "u:a6a75e8cda58" + } + ], + "id": "u:e3820994e2e4", + "themeCss": { + "baseControlClassName": { + "padding-and-margin:default": { + "marginTop": "var(--sizes-size-5)", + "marginRight": "var(--sizes-size-5)", + "marginBottom": "var(--sizes-size-5)", + "marginLeft": "var(--sizes-size-5)" + } + } + } + }, + { + "type": "grid", + "columns": [ + { + "body": [ + { + "type": "select", + "label": "模块类型", + "name": "bodyType", + "options": [ + { + "label": "task", + "value": "task" + }, + { + "label": "iterator", + "value": "iterator" + }, + { + "label": "choose", + "value": "choose" + }, + { + "label": "loop", + "value": "loop" + }, + { + "label": "value", + "value": "value" + }, + { + "label": "transpose", + "value": "transpose" + }, + { + "label": "single", + "value": "single" + }, + { + "label": "mcp", + "value": "mcp", + "hiddenOn": "true" + }, + { + "label": "parallel", + "value": "parallel", + "hiddenOn": "${true}" + } + ], + "id": "u:fd07835da4f1", + "multiple": false, + "value": "task" + } + ], + "md": 12, + "id": "u:6dbf87d57f9c" + } + ], + "id": "u:d7695cfaa781" + }, + { + "type": "grid", + "columns": [ + { + "body": [ + { + "type": "input-text", + "label": "执行条件", + "name": "data.caseRepx", + "id": "u:ac0330cdccfd", + "value": "", + "visible": true, + "hiddenOn": "${bodyType!=\"choose\"}", + "clearValueOnHidden": true + } + ], + "md": 12, + "id": "u:9df595961b98" + } + ], + "id": "u:3446a9eaa850" + }, + { + "type": "grid", + "columns": [ + { + "body": [ + { + "type": "input-text", + "label": "循环对象", + "name": "data.iteratorRepx", + "id": "u:f723d3e3c192", + "value": "", + "visible": true, + "hiddenOn": "${bodyType!=\"iterator\"}", + "clearValueOnHidden": true, + "labelRemark": { + "icon": "fa fa-question-circle", + "trigger": [ + "hover" + ], + "className": "Remark--warning", + "placement": "top", + "title": "spel表达式", + "content": "" + } + }, + { + "type": "input-text", + "label": "转置对象", + "name": "data.targetRepx", + "id": "u:50fc2e630cde", + "value": "", + "visible": true, + "hiddenOn": "${bodyType!=\"transpose\"}", + "clearValueOnHidden": true + } + ], + "md": 12, + "id": "u:a5bb6d1cfbaf" + } + ], + "id": "u:7dcbec6179e3" + }, + { + "type": "grid", + "columns": [ + { + "body": [ + { + "type": "input-text", + "label": "循环条件", + "name": "data.loopRepx", + "id": "u:4b0d8514a9b6", + "value": "", + "visible": true, + "hiddenOn": "${bodyType != \"loop\"}", + "clearValueOnHidden": true + } + ], + "id": "u:40db892e8241", + "md": 8 + }, + { + "body": [ + { + "type": "switch", + "label": "先执行循环", + "option": "", + "name": "data.doFirst", + "falseValue": false, + "trueValue": true, + "id": "u:d9e82b907d17", + "optionAtLeft": true, + "value": false, + "visible": true, + "hiddenOn": "${bodyType != \"loop\"}", + "clearValueOnHidden": true + } + ], + "id": "u:dc4170fc9c99", + "themeCss": { + "baseControlClassName": { + "padding-and-margin:default": {} + } + }, + "md": "auto" + } + ], + "id": "u:dc9f4e7d340a", + "gap": "base", + "themeCss": { + "baseControlClassName": { + "padding-and-margin:default": { + "marginBottom": "var(--sizes-size-4)" + } + } + }, + "align": "left", + "valign": "middle" + }, + { + "type": "input-table", + "name": "bodys", + "label": "执行体", + "columns": [ + { + "label": "id", + "name": "id", + "quickEdit": false, + "id": "u:00f891388450", + "placeholder": "-", + "toggled": true, + "inline": true, + "visible": false, + "type": "text", + "width": 1 + }, + { + "label": "函数名", + "name": "eleId", + "quickEdit": false, + "id": "u:301ca89dcf7f", + "placeholder": "-", + "toggled": true, + "inline": true, + "visible": true, + "type": "mapping", + "source": { + "url": "/q/findOne/${type}", + "method": "get", + "requestAdaptor": "", + "adaptor": "payload.data = [{\r\n value: payload.data.id,\r\n label: payload.data.title,\r\n nodeDate: new Date(payload.data.updatedAt)\r\n}];\r\nconsole.log(payload.data);\r\nreturn payload;", + "messages": {}, + "data": { + "pkey": "${eleId}" + }, + "cache": 3000, + "sendOn": "${!ISEMPTY(eleId)}" + }, + "itemSchema": { + "type": "tag", + "label": "${label | default: \"-\"}", + "id": "u:03c4128c9ac8", + "displayMode": "normal", + "style": { + "color": "#000000" + }, + "color": "${IF(ISBEFORE(STRTODATE(title,\"YYYY-MM-DD HH:mm:ss\"),nodeDate),\"red\",\"#ffffff\")}", + "className": "text-lg w-lg r b-a b-light" + }, + "popOver": false, + "className": "word-break " + }, + { + "type": "text", + "name": "title", + "label": "title", + "placeholder": "-", + "quickEdit": false, + "id": "u:f87d1c35b087", + "inline": true, + "toggled": true, + "visible": false + }, + { + "label": "type", + "name": "type", + "quickEdit": false, + "id": "u:554b5f34123d", + "placeholder": "-", + "type": "text", + "inline": true + }, + { + "label": "说明", + "name": "remark", + "quickEdit": { + "mode": "popOver", + "type": "wrapper", + "body": [ + { + "type": "textarea", + "name": "remark", + "id": "u:235b44cf528a", + "label": false, + "minRows": 3, + "maxRows": 20, + "showCounter": true + } + ], + "id": "u:2d7a5989d079", + "style": { + "position": "static", + "display": "block" + }, + "isFixedHeight": false, + "isFixedWidth": false + }, + "id": "u:706eae109e42", + "placeholder": "-", + "type": "text", + "inline": true, + "width": "20%" + }, + { + "label": "保留长度", + "name": "valNum", + "quickEdit": { + "mode": "popOver", + "type": "wrapper", + "body": [ + { + "type": "input-text", + "name": "valNum", + "id": "u:af68ddc7fb67", + "remark": { + "icon": "fa fa-question-circle", + "trigger": [ + "hover" + ], + "className": "Remark--warning", + "placement": "bottom", + "content": "N为不限长度集合;空字符串不错处理;小于1为非集合;数字为保留集合长度" + }, + "clearable": true, + "validations": { + "maxLength": 5 + }, + "maxLength": 5 + } + ], + "id": "u:4bad7798a18b", + "style": { + "position": "static", + "display": "block", + "fontFamily": "", + "fontSize": 12 + }, + "isFixedHeight": false, + "isFixedWidth": false + }, + "id": "u:af10f002c3f2", + "placeholder": "-", + "type": "text", + "inline": true, + "width": "10%" + }, + { + "type": "table", + "columns": [ + { + "label": "属性名", + "name": "title", + "type": "text", + "id": "u:4333a2e3f621", + "placeholder": "-", + "quickEdit": false, + "inline": true, + "className": "", + "align": "center", + "width": 40 + }, + { + "type": "text", + "label": "dataExp", + "name": "dataExp", + "id": "u:30a06df5a2fd", + "placeholder": "-", + "className": "", + "quickEdit": false, + "inline": false + } + ], + "label": "参数", + "id": "u:5dff38fbe06f", + "placeholder": "-", + "needConfirm": false, + "name": "params", + "mode": "horizontal", + "width": "30%", + "className": "m-none p-none", + "innerClassName": "m-none p-none mt", + "quickEdit": { + "mode": "inline", + "type": "wrapper", + "body": [ + { + "type": "input-table", + "name": "params", + "label": false, + "columns": [ + { + "label": "属性名", + "name": "title", + "quickEdit": false, + "id": "u:c461590e5773", + "placeholder": "-" + }, + { + "label": "paramId", + "name": "paramId", + "quickEdit": false, + "id": "u:94ed4e19e1d5", + "placeholder": "-", + "toggled": false, + "inline": true, + "visible": false + }, + { + "label": "dataExp", + "name": "dataExp", + "quickEdit": { + "type": "input-text", + "name": "dataExp", + "id": "u:47c59b3cd6f5" + }, + "id": "u:54ec1bb6bc46" + } + ], + "addable": false, + "footerAddBtn": { + "label": "新增", + "icon": "fa fa-plus" + }, + "strictMode": true, + "id": "u:b587b08aca63", + "needConfirm": false, + "mode": "horizontal", + "columnsTogglable": false, + "showFooterAddBtn": false, + "showTableAddBtn": false, + "removable": true + } + ], + "id": "u:ed7272953120", + "style": { + "position": "static", + "display": "block", + "fontFamily": "", + "fontSize": 12 + }, + "isFixedHeight": false, + "isFixedWidth": false + } + } + ], + "addable": true, + "footerAddBtn": { + "label": "新增", + "icon": "fa fa-plus", + "id": "u:df172d2f3474", + "onEvent": { + "click": { + "weight": 0, + "actions": [ + { + "ignoreError": false, + "actionType": "dialog", + "dialog": { + "$ref": "modal-ref-2" + } + } + ] + } + } + }, + "strictMode": true, + "id": "u:bdb7d62559c5", + "needConfirm": true, + "mode": "normal", + "removable": true, + "copyable": false, + "showTableAddBtn": true, + "onEvent": { + "add": { + "weight": 0, + "actions": [ + { + "ignoreError": false, + "actionType": "dialog", + "dialog": { + "$ref": "modal-ref-2" + }, + "data": { + "eleIndex": "${index}" + } + } + ] + }, + "edit": { + "weight": 0, + "actions": [ + { + "ignoreError": false, + "actionType": "ajax", + "outputVar": "responseResult", + "options": { + "silent": true + }, + "api": { + "url": "/q/findOne/${event.data.item.type}", + "method": "get", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "data": { + "pkey": "${event.data.item.eleId}" + } + } + }, + { + "actionType": "custom", + "args": {}, + "ignoreError": false, + "script": "// console.log(event);\n// console.log(context);\nvar sourceArr = event.data.responseData.params;\nvar sourceMap = new Map();\nvar filteredArrayA = sourceArr.filter(item =>\n item.paramType === undefined || item.paramType === 0\n);\nfilteredArrayA.forEach(item => {\n const transformedItem = {\n paramId: item.id,\n title: item.title\n };\n sourceMap.set(transformedItem.paramId, transformedItem);\n});\nvar targetMap = new Map();\nvar curArr = event.data.__super.item.params;\ncurArr.forEach(item => {\n targetMap.set(item.paramId, item);\n});\nvar targetArray = [];\ntargetArray.length = 0;\nsourceMap.forEach((value, paramId) => {\n if (targetMap.has(paramId)) {\n var targetItem = targetMap.get(paramId);\n targetArray.push({\n ...targetItem,\n title: value.title\n });\n } else {\n targetArray.push(value);\n }\n});\nconsole.log(targetArray);\nconsole.log(event.data.__super.index);\nevent.data.responseData.params = targetArray;\n\n\n" + }, + { + "actionType": "setValue", + "args": { + "value": { + "params": "${event.data.responseResult.responseData.params}", + "eleId": "${event.data.item.eleId}", + "type": "${event.data.item.type}", + "title": "${DATETOSTR(event.data.responseResult.responseData.updatedAt)}", + "id": "${event.data.item.id}", + "remark": "${event.data.item.remark}", + "valNum": "${event.data.item.valNum}" + }, + "index": "${event.data.index}" + }, + "componentId": "u:bdb7d62559c5", + "groupType": "component" + } + ] + } + }, + "minLength": 0, + "required": true, + "columnsTogglable": false, + "draggable": true, + "editable": true, + "showIndex": true, + "deleteBtnIcon": "", + "deleteBtnLabel": "删除", + "addBtnIcon": "", + "addBtnLabel": "添加", + "editBtnIcon": "", + "editBtnLabel": "编辑", + "clearValueOnHidden": true, + "hiddenOn": "${bodyType==\"transpose\" || bodyType==\"value\"}" + }, + { + "type": "input-table", + "name": "bodys[0].params", + "label": "表格表单", + "columns": [ + { + "label": "属性名", + "name": "paramId", + "quickEdit": { + "type": "input-text", + "name": "paramId", + "id": "u:b528983f0885" + }, + "id": "u:5268b1f61fc0" + }, + { + "label": "表达式", + "name": "dataExp", + "quickEdit": { + "type": "input-text", + "name": "dataExp", + "id": "u:ac7646931b25" + }, + "id": "u:b0c0c2777300" + } + ], + "addable": true, + "footerAddBtn": { + "label": "新增", + "icon": "fa fa-plus", + "id": "u:17aad1ab3311" + }, + "strictMode": true, + "id": "u:71266446cc58", + "needConfirm": false, + "copyable": true, + "removable": true, + "showIndex": true, + "clearValueOnHidden": true, + "hiddenOn": "${ bodyType!=\"value\"}" + } + ], + "id": "u:1bf35f729bae", + "actions": [ + { + "type": "submit", + "label": "提交", + "primary": true + } + ], + "feat": "Edit", + "dsType": "api", + "labelAlign": "left", + "debug": false + } + ], + "actionType": "dialog", + "id": "u:ef7246e567db", + "actions": [ + { + "type": "button", + "actionType": "cancel", + "label": "取消", + "id": "u:03abd219df23" + }, + { + "type": "button", + "actionType": "confirm", + "label": "确定", + "primary": true, + "id": "u:00f32235c9a0", + "reload": "u:9a2552614c4b" + } + ], + "showCloseButton": true, + "closeOnOutside": false, + "closeOnEsc": false, + "showErrorMsg": true, + "showLoading": true, + "draggable": false, + "size": "xl", + "position": "left", + "resizable": false, + "inputParams": { + "type": "object", + "properties": { + "funInfoId": { + "type": "string" + } + }, + "required": [] + }, + "withDefaultData": false, + "dataMapSwitch": false + }, + "modal-ref-2": { + "type": "dialog", + "title": "未命名弹窗", + "body": [ + { + "type": "crud", + "id": "u:02d4702494c8", + "syncLocation": false, + "api": { + "method": "get", + "url": "/q/findList/${selectType}", + "messages": {}, + "requestAdaptor": "", + "adaptor": "", + "data": { + "&": "$$" + } + }, + "bulkActions": [], + "itemActions": [ + { + "label": "选用", + "type": "button", + "id": "u:e4f6794dcb70", + "level": "link", + "onEvent": { + "click": { + "weight": 0, + "actions": [ + { + "actionType": "ajax", + "ignoreError": false, + "outputVar": "responseResult", + "options": {}, + "api": { + "url": "/q/findOne/${selectType}", + "method": "get", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "data": { + "pkey": "${id}" + } + } + }, + { + "actionType": "setValue", + "args": { + "value": { + "eleId": "${event.data.responseResult.responseData.id}", + "title": "${DATETOSTR(event.data.responseResult.responseData.updatedAt)}", + "params": "${ARRAYMAP(\nIF(selectType===\"queryBody\",\nevent.data.responseResult.responseData.params,\nARRAYFILTER(event.data.responseResult.responseData.params,item=>item.paramType == 0)\n ),item=>{paramId:item.id,title:item.title})}", + "type": "${selectType}" + }, + "index": "${eleIndex}" + }, + "groupType": "component", + "componentId": "u:bdb7d62559c5" + }, + { + "actionType": "closeDialog", + "ignoreError": false + } + ] + } + } + } + ], + "columns": [ + { + "name": "id", + "label": "id", + "type": "text", + "id": "u:cae05b8efe83", + "placeholder": "-", + "toggled": false, + "width": 1 + }, + { + "name": "title", + "label": "title", + "type": "text", + "id": "u:42008b37f675", + "placeholder": "-" + }, + { + "type": "date", + "label": "updatedAt", + "name": "updatedAt", + "id": "u:16543dd9aeeb", + "placeholder": "-", + "width": 30 + } + ], + "messages": {}, + "filter": { + "title": "查询条件", + "body": [ + { + "type": "input-text", + "name": "title", + "label": "title", + "id": "u:c653ff24977b" + }, + { + "type": "input-text", + "name": "query", + "label": "query", + "id": "u:9436ab022b64" + }, + { + "type": "select", + "label": "选项", + "name": "selectType", + "options": [ + { + "label": "queryBody", + "value": "queryBody" + }, + { + "label": "funInfo", + "value": "funInfo" + } + ], + "id": "u:55c2ecbf4ba1", + "multiple": false, + "selectFirst": true + } + ], + "id": "u:58984a97150f", + "actions": [ + { + "type": "submit", + "label": "搜索", + "primary": true, + "id": "u:35e43698403e" + }, + { + "type": "button", + "label": "取消", + "onEvent": { + "click": { + "actions": [ + { + "componentId": "u:bdb7d62559c5", + "groupType": "component", + "actionType": "deleteItem", + "args": { + "index": "${eleIndex}" + } + }, + { + "componentId": "", + "ignoreError": false, + "actionType": "closeDialog" + } + ] + } + }, + "id": "u:0b689282389b" + } + ], + "feat": "Insert", + "labelAlign": "left" + }, + "initFetch": true, + "loadDataOnce": true, + "matchFunc": "", + "footerToolbar": [], + "visibleOn": "${ISEMPTY(bodyId)}", + "perPageField": "", + "pageField": "" + } + ], + "id": "u:fdb4b50e5549", + "showCloseButton": false, + "closeOnOutside": false, + "closeOnEsc": false, + "showErrorMsg": true, + "showLoading": true, + "draggable": false, + "actionType": "dialog", + "inputParams": { + "type": "object", + "properties": { + "eleIndex": { + "type": "number" + } + }, + "required": [] + }, + "onEvent": {}, + "hideActions": true, + "actions": [ + { + "type": "button", + "actionType": "cancel", + "label": "取消" + }, + { + "type": "button", + "actionType": "confirm", + "label": "确定", + "primary": true + } + ] + } + } +} \ No newline at end of file diff --git a/apis/viewer-apis-client/src/main/resources/static/html/pages/history/ApiInfo.json_v0 b/apis/viewer-apis-client/src/main/resources/static/html/pages/history/ApiInfo.json_v0 new file mode 100644 index 0000000000000000000000000000000000000000..4bbbf420e6cc30976cca174cf99295d398a21b79 --- /dev/null +++ b/apis/viewer-apis-client/src/main/resources/static/html/pages/history/ApiInfo.json_v0 @@ -0,0 +1,1192 @@ +{ + "type": "page", + "regions": [ + "body" + ], + "body": [ + { + "type": "crud2", + "id": "u:d6b3f2f118a6", + "mode": "table2", + "dsType": "api", + "syncLocation": true, + "primaryField": "id", + "loadType": "", + "api": { + "url": "/q/findList/apiInfo", + "method": "get" + }, + "quickSaveItemApi": { + "url": "/c/save/queryBody", + "method": "post", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "dataType": "json" + }, + "filter": { + "type": "form", + "title": "条件查询", + "mode": "inline", + "columnCount": 3, + "clearValueOnHidden": true, + "behavior": [ + "SimpleQuery" + ], + "body": [ + { + "name": "title", + "label": "title", + "type": "input-text", + "size": "full", + "required": false, + "behavior": "SimpleQuery", + "id": "u:8902beccd2d7" + }, + { + "name": "url", + "label": "url", + "type": "input-text", + "size": "full", + "required": false, + "behavior": "SimpleQuery", + "id": "u:4957ce42ffed" + } + ], + "actions": [ + { + "type": "button", + "label": "新增", + "onEvent": { + "click": { + "actions": [ + { + "ignoreError": false, + "actionType": "drawer", + "drawer": { + "$ref": "modal-ref-1" + } + } + ] + } + }, + "id": "u:48f65763bc82" + }, + { + "type": "reset", + "label": "重置", + "id": "u:0b137f850d9f" + }, + { + "type": "submit", + "label": "查询", + "level": "primary", + "id": "u:a6320fbacffc" + } + ], + "id": "u:6af17830696b", + "feat": "Insert" + }, + "headerToolbar": [], + "footerToolbar": [ + { + "type": "flex", + "direction": "row", + "justify": "flex-start", + "alignItems": "stretch", + "style": { + "position": "static", + "flexWrap": "nowrap" + }, + "items": [ + { + "type": "container", + "align": "left", + "body": [], + "wrapperBody": false, + "style": { + "flexGrow": 1, + "flex": "1 1 auto", + "position": "static", + "display": "flex", + "flexBasis": "auto", + "flexDirection": "row", + "flexWrap": "nowrap", + "alignItems": "stretch", + "justifyContent": "flex-start" + }, + "id": "u:b76ccc02db9a" + }, + { + "type": "container", + "align": "right", + "body": [], + "wrapperBody": false, + "style": { + "flexGrow": 1, + "flex": "1 1 auto", + "position": "static", + "display": "flex", + "flexDirection": "row", + "flexWrap": "nowrap", + "alignItems": "stretch", + "justifyContent": "flex-end" + }, + "id": "u:29066429e821", + "isFixedHeight": false + } + ], + "id": "u:c31243274210", + "isFixedHeight": false, + "isFixedWidth": false, + "visible": false, + "hidden": true + } + ], + "columns": [ + { + "type": "tpl", + "title": "id", + "name": "id", + "id": "u:10f4e7e05418", + "placeholder": "-", + "width": 1, + "visible": false, + "hidden": true + }, + { + "type": "tpl", + "title": "title", + "name": "title", + "id": "u:7b5904fba5cc", + "placeholder": "-", + "width": "30%" + }, + { + "type": "tpl", + "title": "url", + "name": "url", + "id": "u:8360797d9693", + "placeholder": "", + "copyable": true, + "tpl": "${CONCATENATE(\"eq/\",id)}", + "wrapperComponent": "", + "onEvent": { + "click": { + "weight": 0, + "actions": [] + } + } + }, + { + "type": "tpl", + "title": "updatedAt", + "name": "updatedAt", + "id": "u:0c07bb68b2d3", + "placeholder": "-", + "width": "16%" + }, + { + "type": "operation", + "title": "操作", + "id": "u:e2ed8df96baa", + "width": "12%", + "buttons": [ + { + "type": "button", + "label": "编辑", + "level": "link", + "behavior": "Edit", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "drawer", + "drawer": { + "$ref": "modal-ref-1" + } + } + ] + } + }, + "id": "u:89db420d516e" + }, + { + "type": "button", + "label": "删除", + "behavior": "Delete", + "className": "m-r-xs text-danger", + "level": "link", + "confirmText": "确认要删除数据", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "ajax", + "outputVar": "responseResult", + "options": {}, + "api": { + "url": "/c/delete/apiInfo", + "method": "post", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "data": { + "pkey": "${id}" + }, + "dataType": "form-data" + } + }, + { + "actionType": "search", + "groupType": "component", + "componentId": "u:d6b3f2f118a6" + } + ] + } + }, + "id": "u:a573a1548749" + } + ] + } + ], + "editorSetting": { + "mock": { + "enable": true, + "maxDisplayRows": 5 + } + }, + "showHeader": true, + "autoFillHeight": true + } + ], + "id": "u:2100b771c123", + "pullRefresh": { + "disabled": true + }, + "asideResizor": false, + "definitions": { + "modal-ref-1": { + "type": "drawer", + "body": [ + { + "id": "u:22425dc65951", + "type": "form", + "title": "编辑数据", + "mode": "flex", + "labelAlign": "top", + "dsType": "api", + "feat": "Edit", + "body": [ + { + "name": "id", + "label": "id", + "row": 0, + "type": "input-text", + "id": "u:237473abc372", + "visible": false, + "hidden": false + }, + { + "name": "title", + "label": "title", + "row": 1, + "type": "input-text", + "id": "u:ba1548d04809", + "onEvent": { + "change": { + "weight": 0, + "actions": [] + } + } + }, + { + "name": "url", + "label": "url", + "row": 2, + "type": "input-text", + "id": "u:9bd95f9ca5ad", + "hidden": false, + "clearValueOnHidden": false, + "visible": true, + "readOnly": true, + "static": true, + "value": "${IF(ISEMPTY(id),\"\",CONCATENATE(\"eq/\",id))}" + }, + { + "type": "input-table", + "name": "apiParams", + "label": "参数设定", + "id": "u:904bffd1aa6c", + "columns": [ + { + "label": "id", + "name": "id", + "quickEdit": false, + "id": "u:0f712b46e01b", + "placeholder": "-", + "inline": true, + "visible": false, + "hidden": true, + "width": 1 + }, + { + "label": "title", + "name": "title", + "quickEdit": { + "type": "input-text", + "name": "title", + "mode": "popOver" + }, + "type": "text", + "id": "u:600e240e8211", + "placeholder": "-" + }, + { + "label": "dataType", + "name": "dataType", + "quickEdit": { + "type": "wrapper", + "mode": "popOver", + "body": [ + { + "type": "select", + "name": "dataType", + "id": "u:a309dfa43b00", + "multiple": false, + "source": { + "url": "/dataType", + "method": "get", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "cache": 120000 + }, + "labelField": "title", + "valueField": "value" + } + ], + "id": "u:735d6f9d6fef", + "style": { + "position": "static", + "display": "block" + }, + "isFixedHeight": false, + "isFixedWidth": false + }, + "type": "text", + "id": "u:488b2d50e1d1", + "placeholder": "-" + }, + { + "label": "defaultVal", + "name": "defaultVal", + "type": "text", + "quickEdit": { + "type": "input-text", + "name": "defaultVal", + "mode": "popOver" + }, + "id": "u:4f6793cda9ec", + "placeholder": "-" + }, + { + "label": "paramType", + "name": "paramType", + "type": "mapping", + "quickEdit": { + "type": "wrapper", + "mode": "popOver", + "body": [ + { + "type": "select", + "name": "paramType", + "id": "u:052605cb8eaa", + "multiple": false, + "options": [ + { + "label": "输入", + "value": "0" + }, + { + "label": "输出", + "value": "1" + } + ] + } + ], + "id": "u:c747e567e704", + "style": { + "position": "static", + "display": "block" + }, + "isFixedHeight": false, + "isFixedWidth": false + }, + "id": "u:f26dbe09803b", + "placeholder": "-", + "map": { + "0": "输入", + "1": "输出" + } + } + ], + "addable": true, + "footerAddBtn": { + "label": "新增", + "icon": "fa fa-plus", + "id": "u:66b4cc87ab85" + }, + "strictMode": true, + "copyable": true, + "editable": true, + "removable": true, + "columnsTogglable": false, + "draggable": true + }, + { + "type": "crud", + "id": "u:9a2552614c4b", + "syncLocation": false, + "api": { + "method": "get", + "url": "/q/findList/queryBlock", + "messages": {}, + "requestAdaptor": "", + "adaptor": "", + "sendOn": "${!ISEMPTY(id)}", + "data": { + "pid": "${id}" + } + }, + "bulkActions": [], + "itemActions": [], + "headerToolbar": [ + { + "label": "新增", + "type": "button", + "level": "primary", + "id": "u:a7d3e67b1405", + "onEvent": { + "click": { + "weight": 0, + "actions": [ + { + "ignoreError": false, + "actionType": "dialog", + "dialog": { + "$ref": "modal-ref-5" + }, + "data": { + "apiInfoId": "${id}", + "index": "${count}" + } + } + ] + } + } + }, + { + "type": "button", + "tpl": "内容", + "wrapperComponent": "", + "id": "u:5fad74206dcd", + "label": "刷新", + "onEvent": { + "click": { + "weight": 0, + "actions": [ + { + "componentId": "u:9a2552614c4b", + "ignoreError": false, + "actionType": "reload", + "outputVar": "", + "args": { + "resetPage": true + } + } + ] + } + } + } + ], + "columns": [ + { + "name": "id", + "label": "ID", + "type": "text", + "id": "u:1e7e617a5d94", + "placeholder": "-", + "width": 1, + "toggled": false + }, + { + "name": "title", + "label": "title", + "type": "text", + "id": "u:a1287fa03d46", + "placeholder": "-" + }, + { + "type": "text", + "label": "queryTitle", + "name": "queryTitle", + "id": "u:064b2f704eaf", + "placeholder": "-" + }, + { + "type": "operation", + "label": "操作", + "buttons": [ + { + "type": "button", + "label": "删除", + "level": "link", + "className": "text-danger", + "id": "u:2baa04017f90", + "onEvent": { + "click": { + "weight": 0, + "actions": [ + { + "ignoreError": false, + "actionType": "ajax", + "outputVar": "responseResult", + "options": {}, + "api": { + "url": "/c/delete/queryBlock", + "method": "post", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "data": { + "pkey": "${id}" + }, + "dataType": "form-data" + } + }, + { + "componentId": "u:9a2552614c4b", + "ignoreError": false, + "actionType": "reload", + "outputVar": "", + "args": { + "resetPage": true + } + } + ] + } + } + }, + { + "label": "编辑", + "type": "button", + "level": "link", + "id": "u:26b15c904a26", + "onEvent": { + "click": { + "weight": 0, + "actions": [ + { + "ignoreError": false, + "actionType": "dialog", + "data": { + "&": "$$", + "index": "${index}" + }, + "dialog": { + "$ref": "modal-ref-5" + } + } + ] + } + } + }, + { + "label": "添加", + "type": "button", + "level": "link", + "id": "u:b68a32e07fe5", + "onEvent": { + "click": { + "weight": 0, + "actions": [ + { + "ignoreError": false, + "actionType": "dialog", + "dialog": { + "$ref": "modal-ref-5" + }, + "data": { + "apiInfoId": "${id}", + "index": "${index+1}" + } + } + ] + } + } + } + ], + "id": "u:74186454db5d", + "placeholder": "-", + "width": "15%" + } + ], + "messages": {}, + "loadDataOnce": true, + "matchFunc": "", + "footerToolbar": [], + "perPageField": "", + "pageField": "", + "showFooter": false, + "hiddenOn": "${ISEMPTY(id)}", + "draggable": true, + "saveOrderApi": { + "url": "/qb/sort", + "method": "post", + "messages": {}, + "requestAdaptor": "var ids = api.data.ids\r\napi.data = {};\r\napi.data = ids.split(\",\");\r\nreturn api;", + "adaptor": "", + "dataType": "json" + } + } + ], + "api": { + "url": "/c/save/apiInfo", + "method": "post", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "dataType": "json" + }, + "resetAfterSubmit": true, + "actions": [ + { + "type": "button", + "actionType": "cancel", + "label": "取消" + }, + { + "type": "button", + "actionType": "submit", + "label": "提交", + "level": "primary" + } + ], + "onEvent": { + "submitSucc": { + "actions": [ + { + "actionType": "search", + "groupType": "component", + "componentId": "u:d6b3f2f118a6" + } + ] + } + }, + "initApi": { + "url": "/q/findOne/apiInfo", + "method": "get", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "sendOn": "${!ISEMPTY(id)}", + "data": { + "pkey": "${id}" + } + }, + "debug": false + } + ], + "title": "接口设定", + "size": "xl", + "actions": [ + { + "type": "button", + "actionType": "cancel", + "label": "取消", + "id": "u:d67b62d4814d" + }, + { + "type": "button", + "actionType": "submit", + "label": "提交", + "level": "primary", + "id": "u:780304c8c416" + } + ], + "actionType": "drawer", + "id": "u:e02b88dc8778", + "showCloseButton": true, + "closeOnOutside": false, + "closeOnEsc": false, + "showErrorMsg": true, + "showLoading": true, + "draggable": false, + "resizable": false, + "width": "80%" + }, + "modal-ref-5": { + "type": "dialog", + "title": "查询块设定", + "body": [ + { + "type": "form", + "api": { + "method": "post", + "url": "/c/save/queryBlock", + "requestAdaptor": "delete api.data._body;\r\nreturn api;", + "adaptor": "", + "messages": {}, + "dataType": "json" + }, + "initApi": { + "method": "get", + "url": "/q/findOne/queryBlock", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "data": { + "pkey": "${id}" + }, + "sendOn": "${!ISEMPTY(id)}" + }, + "body": [ + { + "name": "id", + "label": "ID", + "type": "input-text", + "id": "u:947888999c29", + "visible": false + }, + { + "name": "pid", + "label": "pid", + "type": "input-text", + "id": "u:a89d087264be", + "value": "${apiInfoId}", + "visible": false + }, + { + "type": "input-text", + "label": "orderNum", + "name": "orderNum", + "id": "u:b78705fdde19", + "value": "${IF(ISEMPTY(orderNum),index,orderNum)}", + "visible": false + }, + { + "name": "title", + "label": "title", + "type": "input-text", + "id": "u:d0cc8da15cff" + }, + { + "type": "radios", + "label": "单一值", + "name": "single", + "options": [ + { + "label": "多值", + "value": false + }, + { + "label": "单一值", + "value": true + } + ], + "id": "u:3c00a8ca60dc", + "selectFirst": true + }, + { + "label": "bodyId", + "name": "bodyId", + "type": "input-text", + "id": "u:ddb4f28debdc", + "visible": false, + "hidden": true, + "clearValueOnHidden": true + }, + { + "type": "service", + "body": [ + { + "type": "grid", + "columns": [ + { + "body": [ + { + "label": "title", + "name": "_body.title", + "type": "input-text", + "id": "u:23afd2618dd9", + "onEvent": { + "change": { + "weight": 0, + "actions": [ + { + "componentId": "u:c48f889577d2", + "ignoreError": false, + "actionType": "setValue", + "args": { + "value": "${event.data.value}" + } + } + ] + } + }, + "static": true, + "readOnly": true, + "disabled": false + } + ], + "id": "u:60dff1e3bbcf", + "md": 10 + }, + { + "body": [ + { + "type": "button", + "label": "cancel", + "onEvent": { + "click": { + "actions": [ + { + "componentId": "u:1bf35f729bae", + "ignoreError": false, + "actionType": "setValue", + "args": { + "value": { + "bodyId": "", + "paramMappings": "" + } + } + }, + { + "ignoreError": false, + "actionType": "setValue", + "args": { + "value": { + "bodyInfo": "" + } + } + }, + { + "componentId": "u:0a63f2676f9c", + "ignoreError": false, + "actionType": "hidden" + } + ] + } + }, + "id": "u:b88775b93d2e" + } + ], + "id": "u:d8bc9c87807d" + } + ], + "id": "u:43199990804e", + "gap": "none" + }, + { + "type": "textarea", + "label": "查询语句", + "name": "_body.query", + "id": "u:0d8fb6667ef2", + "minRows": 3, + "maxRows": 20, + "static": false, + "trimContents": false, + "readOnly": true + }, + { + "type": "input-table", + "name": "paramMappings", + "label": "参数设定", + "columns": [ + { + "label": "id", + "name": "id", + "quickEdit": false, + "id": "u:adeb901db77c", + "placeholder": "-", + "inline": true, + "visible": false, + "width": 1 + }, + { + "label": "qpId", + "name": "qpId", + "quickEdit": false, + "type": "mapping", + "id": "u:7f6968bb7120", + "placeholder": "-", + "source": "${bodyInfo.params}", + "valueField": "id", + "labelField": "title" + }, + { + "label": "dataExp", + "name": "dataExp", + "quickEdit": { + "type": "input-text", + "name": "dataExp", + "id": "u:dcef81af1202" + }, + "type": "text", + "id": "u:ac81234222a3" + } + ], + "addable": false, + "footerAddBtn": { + "label": "新增", + "icon": "fa fa-plus", + "id": "u:d14880bff14e" + }, + "strictMode": true, + "id": "u:0a63f2676f9c", + "multiple": false, + "needConfirm": false, + "editable": false, + "removable": false, + "columnsTogglable": false, + "visible": false, + "clearValueOnHidden": false, + "hidden": false, + "copyable": false, + "canAccessSuperData": true, + "showFooterAddBtn": false, + "mode": "normal", + "rowClassName": "m-none p-none" + } + ], + "id": "u:297ce4f88018", + "dsType": "api", + "data": { + "bodyInfo": {} + }, + "onEvent": { + "init": { + "weight": 0, + "actions": [ + { + "ignoreError": false, + "actionType": "ajax", + "outputVar": "queryBodyRespResult", + "options": {}, + "api": { + "url": "/q/findOne/queryBody", + "method": "get", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "sendOn": "${!ISEMPTY(bodyId)}", + "data": { + "pkey": "${bodyId}" + } + } + }, + { + "ignoreError": false, + "actionType": "setValue", + "args": { + "value": { + "bodyInfo": "${event.data.queryBodyRespResult}" + } + } + }, + { + "ignoreError": false, + "actionType": "custom", + "args": {}, + "script": "console.log(context.props.data.bodyInfo.params);\r\nconsole.log(context.props);\r\nconsole.log(event);\r\ncontext.props.data.bodyInfo = event.data;\r\nconsole.log(context.props);\r\nconsole.log(event);" + }, + { + "ignoreError": false, + "actionType": "setValue", + "args": { + "value": "${event.data.queryBodyRespResult.title}" + }, + "componentId": "u:23afd2618dd9" + }, + { + "ignoreError": false, + "actionType": "setValue", + "args": { + "value": "${event.data.queryBodyRespResult.query}" + }, + "componentId": "u:0d8fb6667ef2" + }, + { + "componentId": "u:1bf35f729bae", + "ignoreError": false, + "actionType": "setValue", + "args": { + "value": { + "paramMappings": "${ISEMPTY(paramMappings)?ISTYPE(paramMappings,'array')?paramMappings:ARRAYMAP(event.data.queryBodyRespResult.responseData.params,item => {\"qpId\":item.id}):paramMappings\n}" + } + } + }, + { + "actionType": "show", + "ignoreError": false, + "componentId": "u:0a63f2676f9c" + } + ] + } + }, + "visibleOn": "${!ISEMPTY(bodyId)}" + }, + { + "type": "crud", + "syncLocation": false, + "api": { + "method": "get", + "url": "/q/findList/queryBody" + }, + "bulkActions": [], + "itemActions": [ + { + "label": "选用", + "type": "button", + "id": "u:e4f6794dcb70", + "level": "link", + "onEvent": { + "click": { + "weight": 0, + "actions": [ + { + "ignoreError": false, + "actionType": "setValue", + "args": { + "value": { + "bodyId": "${id}" + } + }, + "componentId": "u:1bf35f729bae" + } + ] + } + } + } + ], + "columns": [ + { + "name": "id", + "label": "id", + "type": "text", + "id": "u:cae05b8efe83", + "placeholder": "-", + "toggled": false, + "width": 1 + }, + { + "name": "title", + "label": "title", + "type": "text", + "id": "u:42008b37f675", + "placeholder": "-" + }, + { + "type": "date", + "label": "updatedAt", + "name": "updatedAt", + "id": "u:16543dd9aeeb", + "placeholder": "-", + "width": 30 + } + ], + "id": "u:02d4702494c8", + "messages": {}, + "filter": { + "title": "查询条件", + "body": [ + { + "type": "input-text", + "name": "title", + "label": "title", + "id": "u:c653ff24977b" + }, + { + "type": "input-text", + "name": "query", + "label": "query", + "id": "u:9436ab022b64" + } + ], + "id": "u:58984a97150f", + "actions": [ + { + "type": "submit", + "label": "搜索", + "primary": true, + "id": "u:35e43698403e" + } + ], + "feat": "Insert", + "labelAlign": "left" + }, + "initFetch": true, + "loadDataOnce": true, + "matchFunc": "", + "footerToolbar": [], + "visibleOn": "${ISEMPTY(bodyId)}", + "perPageField": "", + "pageField": "" + } + ], + "id": "u:1bf35f729bae", + "actions": [ + { + "type": "submit", + "label": "提交", + "primary": true + } + ], + "feat": "Edit", + "dsType": "api", + "labelAlign": "left", + "debug": true + } + ], + "actionType": "dialog", + "id": "u:ef7246e567db", + "actions": [ + { + "type": "button", + "actionType": "cancel", + "label": "取消", + "id": "u:03abd219df23" + }, + { + "type": "button", + "actionType": "confirm", + "label": "确定", + "primary": true, + "id": "u:00f32235c9a0", + "reload": "u:9a2552614c4b" + } + ], + "showCloseButton": true, + "closeOnOutside": false, + "closeOnEsc": false, + "showErrorMsg": true, + "showLoading": true, + "draggable": false, + "size": "xl", + "position": "left", + "resizable": false, + "inputParams": { + "type": "object", + "properties": { + "apiInfoId": { + "type": "string" + } + }, + "required": [] + }, + "withDefaultData": false, + "dataMapSwitch": false + } + } +} \ No newline at end of file diff --git a/apis/viewer-apis-client/src/main/resources/static/html/pages/history/funInfo.json_250811 b/apis/viewer-apis-client/src/main/resources/static/html/pages/history/funInfo.json_250811 new file mode 100644 index 0000000000000000000000000000000000000000..5931f84fb04caad6cd90ded886b24651d94ed823 --- /dev/null +++ b/apis/viewer-apis-client/src/main/resources/static/html/pages/history/funInfo.json_250811 @@ -0,0 +1,1573 @@ +{ + "type": "page", + "id": "u:2100b771c123", + "dsType": "api", + "editorSetting": { + "mock": { + "enable": true, + "maxDisplayRows": 5 + } + }, + "asideResizor": false, + "pullRefresh": { + "disabled": true + }, + "regions": [ + "body" + ], + "body": [ + { + "type": "crud2", + "id": "u:d6b3f2f118a6", + "dsType": "api", + "api": { + "url": "/q/findList/funInfo", + "method": "get" + }, + "mode": "table2", + "syncLocation": true, + "primaryField": "id", + "loadType": "", + "quickSaveItemApi": { + "url": "/c/save/queryBody", + "method": "post", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "dataType": "json" + }, + "filter": { + "type": "form", + "title": "条件查询", + "mode": "inline", + "columnCount": 3, + "clearValueOnHidden": true, + "behavior": [ + "SimpleQuery" + ], + "body": [ + { + "name": "title", + "label": "title", + "type": "input-text", + "size": "full", + "required": false, + "behavior": "SimpleQuery", + "id": "u:8902beccd2d7" + }, + { + "name": "remark", + "label": "remark", + "type": "input-text", + "size": "full", + "required": false, + "behavior": "SimpleQuery", + "id": "u:a117f7305e9c" + } + ], + "actions": [ + { + "type": "button", + "label": "新增", + "onEvent": { + "click": { + "actions": [ + { + "ignoreError": false, + "actionType": "drawer", + "drawer": { + "$ref": "modal-ref-1" + } + } + ] + } + }, + "id": "u:48f65763bc82" + }, + { + "type": "reset", + "label": "重置", + "id": "u:0b137f850d9f" + }, + { + "type": "submit", + "label": "查询", + "level": "primary", + "id": "u:a6320fbacffc" + } + ], + "id": "u:6af17830696b", + "feat": "Insert" + }, + "headerToolbar": [], + "footerToolbar": [], + "columns": [ + { + "type": "tpl", + "title": "id", + "name": "id", + "id": "u:10f4e7e05418", + "placeholder": "-", + "width": 1, + "visible": false, + "hidden": true + }, + { + "type": "tpl", + "title": "title", + "name": "title", + "id": "u:7b5904fba5cc", + "placeholder": "-", + "width": "30%" + }, + { + "type": "tpl", + "title": "remark", + "name": "remark", + "id": "u:968da5f1938e", + "placeholder": "-" + }, + { + "type": "tpl", + "title": "updatedAt", + "name": "updatedAt", + "id": "u:0c07bb68b2d3", + "placeholder": "-", + "width": "16%" + }, + { + "type": "operation", + "title": "操作", + "id": "u:e2ed8df96baa", + "width": "12%", + "buttons": [ + { + "type": "button", + "label": "编辑", + "level": "link", + "behavior": "Edit", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "drawer", + "drawer": { + "$ref": "modal-ref-1" + } + } + ] + } + }, + "id": "u:89db420d516e" + }, + { + "type": "button", + "label": "删除", + "level": "link", + "behavior": "Delete", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "ajax", + "outputVar": "responseResult", + "options": {}, + "api": { + "url": "/c/delete/funInfo", + "method": "post", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "data": { + "pkey": "${id}" + }, + "dataType": "form-data" + } + }, + { + "actionType": "search", + "groupType": "component", + "componentId": "u:d6b3f2f118a6" + } + ] + } + }, + "id": "u:a573a1548749", + "className": "m-r-xs text-danger", + "confirmText": "确认要删除数据" + }, + { + "label": "测试", + "level": "light", + "id": "u:2c00c0ce2087", + "type": "button", + "behavior": "Edit", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "drawer", + "drawer": { + "$ref": "modal-ref-1" + } + } + ] + } + } + } + ] + } + ], + "editorSetting": { + "mock": { + "enable": true, + "maxDisplayRows": 5 + } + }, + "showHeader": true, + "autoFillHeight": true + } + ], + "definitions": { + "modal-ref-1": { + "type": "drawer", + "body": [ + { + "id": "u:22425dc65951", + "type": "form", + "title": "编辑数据", + "mode": "flex", + "labelAlign": "top", + "dsType": "api", + "feat": "Edit", + "body": [ + { + "name": "id", + "label": "id", + "row": 0, + "type": "input-text", + "id": "u:237473abc372", + "visible": false, + "hidden": false + }, + { + "name": "title", + "label": "title", + "row": 1, + "type": "input-text", + "id": "u:ba1548d04809", + "onEvent": { + "change": { + "weight": 0, + "actions": [] + } + } + }, + { + "type": "input-table", + "name": "params", + "label": "参数设定", + "id": "u:904bffd1aa6c", + "columns": [ + { + "label": "id", + "name": "id", + "quickEdit": false, + "id": "u:0f712b46e01b", + "placeholder": "-", + "inline": true, + "visible": false, + "hidden": true, + "width": 1 + }, + { + "label": "title", + "name": "title", + "quickEdit": { + "type": "input-text", + "name": "title", + "mode": "popOver" + }, + "type": "text", + "id": "u:600e240e8211", + "placeholder": "-" + }, + { + "label": "dataType", + "name": "dataType", + "quickEdit": { + "type": "wrapper", + "mode": "popOver", + "body": [ + { + "type": "select", + "name": "dataType", + "id": "u:a309dfa43b00", + "multiple": false, + "source": { + "url": "/dataType", + "method": "get", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "cache": 120000 + }, + "labelField": "title", + "valueField": "value" + } + ], + "id": "u:735d6f9d6fef", + "style": { + "position": "static", + "display": "block" + }, + "isFixedHeight": false, + "isFixedWidth": false + }, + "type": "text", + "id": "u:488b2d50e1d1", + "placeholder": "-" + }, + { + "label": "defaultVal", + "name": "defaultVal", + "type": "text", + "quickEdit": { + "type": "input-text", + "name": "defaultVal", + "mode": "popOver" + }, + "id": "u:4f6793cda9ec", + "placeholder": "-" + }, + { + "label": "paramType", + "name": "paramType", + "type": "mapping", + "quickEdit": { + "type": "wrapper", + "mode": "popOver", + "body": [ + { + "type": "select", + "name": "paramType", + "id": "u:052605cb8eaa", + "multiple": false, + "options": [ + { + "label": "输入", + "value": "0" + }, + { + "label": "输出", + "value": "1" + }, + { + "label": "内部", + "value": "2" + } + ], + "selectFirst": true + } + ], + "id": "u:c747e567e704", + "style": { + "position": "static", + "display": "block", + "fontFamily": "", + "fontSize": 12 + }, + "isFixedHeight": false, + "isFixedWidth": false + }, + "id": "u:f26dbe09803b", + "placeholder": "-", + "map": { + "0": "输入", + "1": "输出", + "2": "内部" + } + } + ], + "addable": true, + "footerAddBtn": { + "label": "新增", + "icon": "fa fa-plus", + "id": "u:66b4cc87ab85" + }, + "strictMode": true, + "copyable": true, + "editable": true, + "removable": true, + "columnsTogglable": false, + "draggable": true + }, + { + "type": "crud", + "id": "u:9a2552614c4b", + "columns": [ + { + "name": "id", + "label": "ID", + "id": "u:1e7e617a5d94", + "placeholder": "-", + "type": "text", + "width": 1, + "toggled": false + }, + { + "name": "title", + "label": "title", + "type": "text", + "id": "u:a1287fa03d46", + "placeholder": "-" + }, + { + "type": "text", + "label": "queryTitle", + "name": "queryTitle", + "id": "u:064b2f704eaf", + "placeholder": "-" + }, + { + "type": "operation", + "label": "操作", + "id": "u:74186454db5d", + "placeholder": "-", + "width": "15%", + "buttons": [ + { + "type": "button", + "label": "删除", + "level": "link", + "className": "text-danger", + "id": "u:2baa04017f90", + "onEvent": { + "click": { + "weight": 0, + "actions": [ + { + "ignoreError": false, + "actionType": "ajax", + "outputVar": "responseResult", + "options": {}, + "api": { + "url": "/c/delete/queryBlock", + "method": "post", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "data": { + "pkey": "${id}" + }, + "dataType": "form-data" + } + }, + { + "componentId": "u:9a2552614c4b", + "ignoreError": false, + "actionType": "reload", + "outputVar": "", + "args": { + "resetPage": true + } + } + ] + } + } + }, + { + "label": "编辑", + "type": "button", + "level": "link", + "id": "u:26b15c904a26", + "onEvent": { + "click": { + "weight": 0, + "actions": [ + { + "ignoreError": false, + "actionType": "dialog", + "data": { + "&": "$$", + "index": "${index}" + }, + "dialog": { + "$ref": "modal-ref-5" + } + } + ] + } + } + }, + { + "label": "添加", + "type": "button", + "level": "link", + "id": "u:b68a32e07fe5", + "onEvent": { + "click": { + "weight": 0, + "actions": [ + { + "ignoreError": false, + "actionType": "dialog", + "dialog": { + "$ref": "modal-ref-5" + }, + "data": { + "funInfoId": "${id}", + "index": "${index+1}" + } + } + ] + } + } + } + ] + } + ], + "syncLocation": false, + "api": { + "method": "get", + "url": "/q/findList/blockInfo", + "messages": {}, + "requestAdaptor": "", + "adaptor": "", + "sendOn": "${!ISEMPTY(id)}", + "data": { + "pid": "${id}" + } + }, + "bulkActions": [], + "itemActions": [], + "headerToolbar": [ + { + "label": "新增", + "type": "button", + "level": "primary", + "id": "u:a7d3e67b1405", + "onEvent": { + "click": { + "weight": 0, + "actions": [ + { + "ignoreError": false, + "actionType": "dialog", + "dialog": { + "$ref": "modal-ref-5" + }, + "data": { + "funInfoId": "${id}", + "index": "${count}" + } + } + ] + } + } + }, + { + "type": "button", + "tpl": "内容", + "wrapperComponent": "", + "id": "u:5fad74206dcd", + "label": "刷新", + "onEvent": { + "click": { + "weight": 0, + "actions": [ + { + "componentId": "u:9a2552614c4b", + "ignoreError": false, + "actionType": "reload", + "outputVar": "", + "args": { + "resetPage": true + } + } + ] + } + } + } + ], + "messages": {}, + "loadDataOnce": true, + "matchFunc": "", + "footerToolbar": [], + "perPageField": "", + "pageField": "", + "showFooter": false, + "hiddenOn": "${ISEMPTY(id)}", + "draggable": true, + "saveOrderApi": { + "url": "/qb/sort", + "method": "post", + "messages": {}, + "requestAdaptor": "var ids = api.data.ids\r\napi.data = {};\r\napi.data = ids.split(\",\");\r\nreturn api;", + "adaptor": "", + "dataType": "json" + } + } + ], + "api": { + "url": "/c/save/funInfo", + "method": "post", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "dataType": "json" + }, + "resetAfterSubmit": true, + "actions": [ + { + "type": "button", + "actionType": "cancel", + "label": "取消" + }, + { + "type": "button", + "actionType": "submit", + "label": "提交", + "level": "primary" + } + ], + "onEvent": { + "submitSucc": { + "actions": [ + { + "actionType": "search", + "groupType": "component", + "componentId": "u:d6b3f2f118a6" + } + ] + } + }, + "initApi": { + "url": "/q/findOne/funInfo", + "method": "get", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "sendOn": "${!ISEMPTY(id)}", + "data": { + "pkey": "${id}" + } + }, + "debug": true + } + ], + "title": "方法设定", + "size": "xl", + "actions": [ + { + "type": "button", + "actionType": "cancel", + "label": "取消", + "id": "u:d67b62d4814d" + }, + { + "type": "button", + "actionType": "submit", + "label": "提交", + "level": "primary", + "id": "u:780304c8c416" + } + ], + "actionType": "drawer", + "id": "u:e02b88dc8778", + "showCloseButton": true, + "closeOnOutside": false, + "closeOnEsc": false, + "showErrorMsg": true, + "showLoading": true, + "draggable": false, + "resizable": false, + "width": "80%", + "editorSetting": { + "displayName": "方法设定" + } + }, + "modal-ref-5": { + "type": "dialog", + "title": "查询块设定", + "body": [ + { + "type": "form", + "api": { + "method": "post", + "url": "/c/save/blockInfo", + "requestAdaptor": "api.data.dataStr = JSON.stringify(api.data.data);\r\nif (Object.prototype.hasOwnProperty.call(api.data, 'bodys')\r\n && Object.keys(api.data.bodys).length != 0) {\r\n api.data.bodys.forEach((ele) => {\r\n ele.paramsPayload = JSON.stringify(ele.params);\r\n });\r\n }\r\n\r\nreturn api;", + "adaptor": "", + "messages": {}, + "dataType": "json" + }, + "initApi": { + "method": "get", + "url": "/q/findOne/blockInfo", + "requestAdaptor": "", + "adaptor": "var baseData = payload.data;\r\nvar dataStr = baseData.dataStr;\r\nconsole.log(baseData);\r\nbaseData.data = {}\r\nif (!(!dataStr || dataStr.trim() === '')) {\r\n try {\r\n baseData.data = JSON.parse(dataStr);\r\n } catch (error) {\r\n console.error('JSON解析失败:', error);\r\n }\r\n}\r\n\r\nvar bodyArrs = baseData.bodys;\r\nif (bodyArrs != null && Array.isArray(bodyArrs) && bodyArrs.length > 0) {\r\n bodyArrs.forEach((ele) => {\r\n var paramsPayloadStr = ele.paramsPayload\r\n if (!paramsPayloadStr || paramsPayloadStr.trim() === '') {\r\n return;\r\n }\r\n try {\r\n console.log(paramsPayloadStr);\r\n ele.params = JSON.parse(paramsPayloadStr);\r\n } catch (error) {\r\n console.error('JSON解析失败:', error);\r\n }\r\n\r\n });\r\n}\r\nconsole.log(payload);\r\nreturn payload;", + "messages": {}, + "data": { + "pkey": "${id}" + }, + "sendOn": "${!ISEMPTY(id)}" + }, + "body": [ + { + "name": "id", + "label": "ID", + "type": "input-text", + "id": "u:947888999c29", + "visible": false + }, + { + "name": "pid", + "label": "pid", + "type": "input-text", + "id": "u:a89d087264be", + "value": "${funInfoId}", + "visible": false + }, + { + "type": "input-text", + "label": "orderNum", + "name": "orderNum", + "id": "u:b78705fdde19", + "value": "${IF(ISEMPTY(orderNum),index,orderNum)}", + "visible": false + }, + { + "type": "grid", + "columns": [ + { + "body": [ + { + "name": "title", + "label": "标题", + "type": "input-text", + "id": "u:d0cc8da15cff" + } + ], + "id": "u:1c4473c7db45", + "md": 7 + }, + { + "body": [ + { + "type": "radios", + "label": "单一值", + "name": "single", + "options": [ + { + "label": "多值", + "value": false + }, + { + "label": "单一值", + "value": true + } + ], + "id": "u:3c00a8ca60dc", + "selectFirst": true, + "value": false, + "mode": "inline" + } + ], + "id": "u:a6a75e8cda58" + } + ], + "id": "u:e3820994e2e4", + "themeCss": { + "baseControlClassName": { + "padding-and-margin:default": { + "marginTop": "var(--sizes-size-5)", + "marginRight": "var(--sizes-size-5)", + "marginBottom": "var(--sizes-size-5)", + "marginLeft": "var(--sizes-size-5)" + } + } + } + }, + { + "type": "grid", + "columns": [ + { + "body": [ + { + "type": "select", + "label": "模块类型", + "name": "bodyType", + "options": [ + { + "label": "task", + "value": "task" + }, + { + "label": "iterator", + "value": "iterator" + }, + { + "label": "choose", + "value": "choose" + }, + { + "label": "loop", + "value": "loop" + }, + { + "label": "value", + "value": "value" + }, + { + "label": "transpose", + "value": "transpose" + }, + { + "label": "single", + "value": "single" + }, + { + "label": "mcp", + "value": "mcp" + }, + { + "label": "parallel", + "value": "parallel" + } + ], + "id": "u:fd07835da4f1", + "multiple": false, + "value": "task" + } + ], + "md": 12, + "id": "u:6dbf87d57f9c" + } + ], + "id": "u:d7695cfaa781" + }, + { + "type": "grid", + "columns": [ + { + "body": [ + { + "type": "input-text", + "label": "执行条件", + "name": "data.caseRepx", + "id": "u:ac0330cdccfd", + "value": "", + "visible": true, + "hiddenOn": "${bodyType!=\"choose\"}", + "clearValueOnHidden": true + } + ], + "md": 12, + "id": "u:9df595961b98" + } + ], + "id": "u:3446a9eaa850" + }, + { + "type": "grid", + "columns": [ + { + "body": [ + { + "type": "input-text", + "label": "循环对象", + "name": "data.iteratorRepx", + "id": "u:f723d3e3c192", + "value": "", + "visible": true, + "hiddenOn": "${bodyType!=\"iterator\"}", + "clearValueOnHidden": true, + "labelRemark": { + "icon": "fa fa-question-circle", + "trigger": [ + "hover" + ], + "className": "Remark--warning", + "placement": "top", + "title": "spel表达式", + "content": "" + } + }, + { + "type": "input-text", + "label": "转置对象", + "name": "data.targetRepx", + "id": "u:50fc2e630cde", + "value": "", + "visible": true, + "hiddenOn": "${bodyType!=\"transpose\"}", + "clearValueOnHidden": true + } + ], + "md": 12, + "id": "u:a5bb6d1cfbaf" + } + ], + "id": "u:7dcbec6179e3" + }, + { + "type": "grid", + "columns": [ + { + "body": [ + { + "type": "input-text", + "label": "循环条件", + "name": "data.loopRepx", + "id": "u:4b0d8514a9b6", + "value": "", + "visible": true, + "hiddenOn": "${bodyType != \"loop\"}", + "clearValueOnHidden": true + } + ], + "id": "u:40db892e8241", + "md": 8 + }, + { + "body": [ + { + "type": "switch", + "label": "先执行循环", + "option": "", + "name": "data.doFirst", + "falseValue": false, + "trueValue": true, + "id": "u:d9e82b907d17", + "optionAtLeft": true, + "value": false, + "visible": true, + "hiddenOn": "${bodyType != \"loop\"}", + "clearValueOnHidden": true + } + ], + "id": "u:dc4170fc9c99", + "themeCss": { + "baseControlClassName": { + "padding-and-margin:default": {} + } + }, + "md": "auto" + } + ], + "id": "u:dc9f4e7d340a", + "gap": "base", + "themeCss": { + "baseControlClassName": { + "padding-and-margin:default": { + "marginBottom": "var(--sizes-size-4)" + } + } + }, + "align": "left", + "valign": "middle" + }, + { + "type": "input-table", + "name": "bodys", + "label": "执行体", + "columns": [ + { + "label": "id", + "name": "id", + "quickEdit": false, + "id": "u:00f891388450", + "placeholder": "-", + "toggled": true, + "inline": true, + "visible": false, + "type": "text", + "width": 1 + }, + { + "label": "函数名", + "name": "eleId", + "quickEdit": false, + "id": "u:301ca89dcf7f", + "placeholder": "-", + "toggled": true, + "inline": true, + "visible": true, + "type": "mapping", + "source": { + "url": "/q/findOne/${type}", + "method": "get", + "requestAdaptor": "", + "adaptor": "payload.data = [{\r\n value: payload.data.id,\r\n label: payload.data.title,\r\n nodeDate: new Date(payload.data.updatedAt)\r\n}];\r\nconsole.log(payload.data);\r\nreturn payload;", + "messages": {}, + "data": { + "pkey": "${eleId}" + }, + "cache": 3000, + "sendOn": "${!ISEMPTY(eleId)}" + }, + "itemSchema": { + "type": "tag", + "label": "${label | default: \"-\"}", + "id": "u:03c4128c9ac8", + "displayMode": "normal", + "style": { + "color": "#000000" + }, + "color": "${IF(ISBEFORE(STRTODATE(title,\"YYYY-MM-DD HH:mm:ss\"),nodeDate),\"red\",\"#ffffff\")}", + "className": "text-lg w-lg r b-a b-light" + } + }, + { + "type": "text", + "name": "title", + "label": "title", + "placeholder": "-", + "quickEdit": false, + "id": "u:f87d1c35b087", + "inline": true, + "toggled": true, + "visible": false + }, + { + "label": "type", + "name": "type", + "quickEdit": false, + "id": "u:554b5f34123d", + "placeholder": "-", + "type": "text", + "inline": true + }, + { + "label": "说明", + "name": "remark", + "quickEdit": { + "mode": "popOver", + "type": "wrapper", + "body": [ + { + "type": "input-text", + "name": "remark", + "id": "u:0b0142a13455" + } + ], + "id": "u:2d7a5989d079", + "style": { + "position": "static", + "display": "block" + }, + "isFixedHeight": false, + "isFixedWidth": false + }, + "id": "u:706eae109e42", + "placeholder": "-", + "type": "text", + "inline": true + }, + { + "type": "table", + "columns": [ + { + "label": "属性名", + "name": "title", + "type": "text", + "id": "u:4333a2e3f621", + "placeholder": "-", + "quickEdit": false, + "inline": true, + "className": "", + "align": "center", + "width": 40 + }, + { + "type": "text", + "label": "dataExp", + "name": "dataExp", + "id": "u:30a06df5a2fd", + "placeholder": "-", + "className": "", + "quickEdit": false, + "inline": false + } + ], + "label": "参数", + "id": "u:5dff38fbe06f", + "placeholder": "-", + "needConfirm": false, + "name": "params", + "mode": "horizontal", + "width": "30%", + "className": "m-none p-none", + "innerClassName": "m-none p-none mt", + "quickEdit": { + "mode": "inline", + "type": "wrapper", + "body": [ + { + "type": "input-table", + "name": "params", + "label": false, + "columns": [ + { + "label": "属性名", + "name": "title", + "quickEdit": false, + "id": "u:c461590e5773", + "placeholder": "-" + }, + { + "label": "paramId", + "name": "paramId", + "quickEdit": false, + "id": "u:94ed4e19e1d5", + "placeholder": "-", + "toggled": false, + "inline": true, + "visible": false + }, + { + "label": "dataExp", + "name": "dataExp", + "quickEdit": { + "type": "input-text", + "name": "dataExp", + "id": "u:47c59b3cd6f5" + }, + "id": "u:54ec1bb6bc46" + } + ], + "addable": false, + "footerAddBtn": { + "label": "新增", + "icon": "fa fa-plus" + }, + "strictMode": true, + "id": "u:b587b08aca63", + "needConfirm": false, + "mode": "horizontal", + "columnsTogglable": false, + "showFooterAddBtn": false, + "showTableAddBtn": false, + "removable": true + } + ], + "id": "u:ed7272953120", + "style": { + "position": "static", + "display": "block", + "fontFamily": "", + "fontSize": 12 + }, + "isFixedHeight": false, + "isFixedWidth": false + } + } + ], + "addable": true, + "footerAddBtn": { + "label": "新增", + "icon": "fa fa-plus", + "id": "u:df172d2f3474", + "onEvent": { + "click": { + "weight": 0, + "actions": [ + { + "ignoreError": false, + "actionType": "dialog", + "dialog": { + "$ref": "modal-ref-2" + } + } + ] + } + } + }, + "strictMode": true, + "id": "u:bdb7d62559c5", + "needConfirm": true, + "mode": "normal", + "removable": true, + "copyable": false, + "showTableAddBtn": true, + "onEvent": { + "add": { + "weight": 0, + "actions": [ + { + "ignoreError": false, + "actionType": "dialog", + "dialog": { + "$ref": "modal-ref-2" + }, + "data": { + "eleIndex": "${index}" + } + } + ] + }, + "edit": { + "weight": 0, + "actions": [ + { + "ignoreError": false, + "actionType": "ajax", + "outputVar": "responseResult", + "options": { + "silent": true + }, + "api": { + "url": "/q/findOne/${event.data.item.type}", + "method": "get", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "data": { + "pkey": "${event.data.item.eleId}" + } + } + }, + { + "actionType": "custom", + "args": {}, + "ignoreError": false, + "script": "// console.log(event);\n// console.log(context);\nvar sourceArr = event.data.responseData.params;\nvar sourceMap = new Map();\nvar filteredArrayA = sourceArr.filter(item =>\n item.paramType === undefined || item.paramType === 0\n);\nfilteredArrayA.forEach(item => {\n const transformedItem = {\n paramId: item.id,\n title: item.title\n };\n sourceMap.set(transformedItem.paramId, transformedItem);\n});\nvar targetMap = new Map();\nvar curArr = event.data.__super.item.params;\ncurArr.forEach(item => {\n targetMap.set(item.paramId, item);\n});\nvar targetArray = [];\ntargetArray.length = 0;\nsourceMap.forEach((value, paramId) => {\n if (targetMap.has(paramId)) {\n var targetItem = targetMap.get(paramId);\n targetArray.push({\n ...targetItem,\n title: value.title\n });\n } else {\n targetArray.push(value);\n }\n});\nconsole.log(targetArray);\nconsole.log(event.data.__super.index);\nevent.data.responseData.params = targetArray;\n\n\n" + }, + { + "actionType": "setValue", + "args": { + "value": { + "params": "${event.data.responseResult.responseData.params}", + "eleId": "${event.data.item.eleId}", + "type": "${event.data.item.type}", + "title": "${DATETOSTR(event.data.responseResult.responseData.updatedAt)}", + "id": "${event.data.item.id}", + "remark": "${event.data.item.remark}" + }, + "index": "${event.data.index}" + }, + "componentId": "u:bdb7d62559c5", + "groupType": "component" + } + ] + } + }, + "minLength": 0, + "required": true, + "columnsTogglable": false, + "draggable": true, + "editable": true, + "showIndex": true, + "deleteBtnIcon": "", + "deleteBtnLabel": "删除", + "addBtnIcon": "", + "addBtnLabel": "添加", + "editBtnIcon": "", + "editBtnLabel": "编辑", + "clearValueOnHidden": true, + "hiddenOn": "${bodyType==\"transpose\" || bodyType==\"value\"}" + }, + { + "type": "input-table", + "name": "bodys[0].params", + "label": "表格表单", + "columns": [ + { + "label": "属性名", + "name": "paramId", + "quickEdit": { + "type": "input-text", + "name": "paramId", + "id": "u:b528983f0885" + }, + "id": "u:5268b1f61fc0" + }, + { + "label": "表达式", + "name": "dataExp", + "quickEdit": { + "type": "input-text", + "name": "dataExp", + "id": "u:ac7646931b25" + }, + "id": "u:b0c0c2777300" + } + ], + "addable": true, + "footerAddBtn": { + "label": "新增", + "icon": "fa fa-plus", + "id": "u:17aad1ab3311" + }, + "strictMode": true, + "id": "u:71266446cc58", + "needConfirm": false, + "copyable": true, + "removable": true, + "showIndex": true, + "clearValueOnHidden": true, + "hiddenOn": "${ bodyType!=\"value\"}" + } + ], + "id": "u:1bf35f729bae", + "actions": [ + { + "type": "submit", + "label": "提交", + "primary": true + } + ], + "feat": "Edit", + "dsType": "api", + "labelAlign": "left", + "debug": true + } + ], + "actionType": "dialog", + "id": "u:ef7246e567db", + "actions": [ + { + "type": "button", + "actionType": "cancel", + "label": "取消", + "id": "u:03abd219df23" + }, + { + "type": "button", + "actionType": "confirm", + "label": "确定", + "primary": true, + "id": "u:00f32235c9a0", + "reload": "u:9a2552614c4b" + } + ], + "showCloseButton": true, + "closeOnOutside": false, + "closeOnEsc": false, + "showErrorMsg": true, + "showLoading": true, + "draggable": false, + "size": "xl", + "position": "left", + "resizable": false, + "inputParams": { + "type": "object", + "properties": { + "funInfoId": { + "type": "string" + } + }, + "required": [] + }, + "withDefaultData": false, + "dataMapSwitch": false + }, + "modal-ref-2": { + "type": "dialog", + "title": "未命名弹窗", + "body": [ + { + "type": "crud", + "id": "u:02d4702494c8", + "syncLocation": false, + "api": { + "method": "get", + "url": "/q/findList/${selectType}", + "messages": {}, + "requestAdaptor": "", + "adaptor": "", + "data": { + "&": "$$" + } + }, + "bulkActions": [], + "itemActions": [ + { + "label": "选用", + "type": "button", + "id": "u:e4f6794dcb70", + "level": "link", + "onEvent": { + "click": { + "weight": 0, + "actions": [ + { + "actionType": "ajax", + "ignoreError": false, + "outputVar": "responseResult", + "options": {}, + "api": { + "url": "/q/findOne/${selectType}", + "method": "get", + "requestAdaptor": "", + "adaptor": "", + "messages": {}, + "data": { + "pkey": "${id}" + } + } + }, + { + "actionType": "setValue", + "args": { + "value": { + "eleId": "${event.data.responseResult.responseData.id}", + "title": "${DATETOSTR(event.data.responseResult.responseData.updatedAt)}", + "params": "${ARRAYMAP(\nIF(selectType===\"queryBody\",\nevent.data.responseResult.responseData.params,\nARRAYFILTER(event.data.responseResult.responseData.params,item=>item.paramType == 0)\n ),item=>{paramId:item.id,title:item.title})}", + "type": "${selectType}" + }, + "index": "${eleIndex}" + }, + "groupType": "component", + "componentId": "u:bdb7d62559c5" + }, + { + "actionType": "closeDialog", + "ignoreError": false + } + ] + } + } + } + ], + "columns": [ + { + "name": "id", + "label": "id", + "type": "text", + "id": "u:cae05b8efe83", + "placeholder": "-", + "toggled": false, + "width": 1 + }, + { + "name": "title", + "label": "title", + "type": "text", + "id": "u:42008b37f675", + "placeholder": "-" + }, + { + "type": "date", + "label": "updatedAt", + "name": "updatedAt", + "id": "u:16543dd9aeeb", + "placeholder": "-", + "width": 30 + } + ], + "messages": {}, + "filter": { + "title": "查询条件", + "body": [ + { + "type": "input-text", + "name": "title", + "label": "title", + "id": "u:c653ff24977b" + }, + { + "type": "input-text", + "name": "query", + "label": "query", + "id": "u:9436ab022b64" + }, + { + "type": "select", + "label": "选项", + "name": "selectType", + "options": [ + { + "label": "queryBody", + "value": "queryBody" + }, + { + "label": "funInfo", + "value": "funInfo" + } + ], + "id": "u:55c2ecbf4ba1", + "multiple": false, + "selectFirst": true + } + ], + "id": "u:58984a97150f", + "actions": [ + { + "type": "submit", + "label": "搜索", + "primary": true, + "id": "u:35e43698403e" + }, + { + "type": "button", + "label": "取消", + "onEvent": { + "click": { + "actions": [ + { + "componentId": "u:bdb7d62559c5", + "groupType": "component", + "actionType": "deleteItem", + "args": { + "index": "${eleIndex}" + } + }, + { + "componentId": "", + "ignoreError": false, + "actionType": "closeDialog" + } + ] + } + }, + "id": "u:0b689282389b" + } + ], + "feat": "Insert", + "labelAlign": "left" + }, + "initFetch": true, + "loadDataOnce": true, + "matchFunc": "", + "footerToolbar": [], + "visibleOn": "${ISEMPTY(bodyId)}", + "perPageField": "", + "pageField": "" + } + ], + "id": "u:fdb4b50e5549", + "showCloseButton": false, + "closeOnOutside": false, + "closeOnEsc": false, + "showErrorMsg": true, + "showLoading": true, + "draggable": false, + "actionType": "dialog", + "inputParams": { + "type": "object", + "properties": { + "eleIndex": { + "type": "number" + } + }, + "required": [] + }, + "onEvent": {}, + "hideActions": true, + "actions": [ + { + "type": "button", + "actionType": "cancel", + "label": "取消" + }, + { + "type": "button", + "actionType": "confirm", + "label": "确定", + "primary": true + } + ] + } + } +} \ No newline at end of file diff --git a/apis/viewer-apis-client/src/main/resources/static/html/pages/index.json b/apis/viewer-apis-client/src/main/resources/static/html/pages/index.json index 16ee973779c1d0c4f4aabd681213718dbbc343c2..23cd535bfe2d95ba01ef98afe7878ecc08315a4e 100644 --- a/apis/viewer-apis-client/src/main/resources/static/html/pages/index.json +++ b/apis/viewer-apis-client/src/main/resources/static/html/pages/index.json @@ -28,6 +28,11 @@ "url": "ApiInfo", "schemaApi": "/html/pages/ApiInfo.json" }, + { + "label": "设定方法", + "url": "funInfo", + "schemaApi": "/html/pages/funInfo.json" + }, { "label": "导出数据", "url": "ExportDataInfo", @@ -36,7 +41,7 @@ { "label": "基础信息", "url": "env", - "schemaApi": "/html/pages/cache.json" + "schemaApi": "/html/pages/env.json" } ] } diff --git a/apis/viewer-apis-client/src/main/resources/static/js/common.js b/apis/viewer-apis-client/src/main/resources/static/js/common.js new file mode 100644 index 0000000000000000000000000000000000000000..004298f8c43a5ce32e5567fe69e16b2ac87633fd --- /dev/null +++ b/apis/viewer-apis-client/src/main/resources/static/js/common.js @@ -0,0 +1,13 @@ +function parseJSONStr(jsonString) { + // 判空 + if (!jsonString || jsonString.trim() === '') { + return null; // 或者返回 {} 空对象 + } + + try { + return JSON.parse(jsonString); + } catch (error) { + console.error('JSON解析失败:', error); + return null; // 或者返回 {} 空对象 + } +} diff --git a/commons/viewer-common-api/src/main/java/xyz/thoughtset/viewer/common/api/result/Result.java b/commons/viewer-common-api/src/main/java/xyz/thoughtset/viewer/common/api/result/Result.java index 2d801f90db89429b0042769b77ffa53bdb70388f..0b70f9053fd47dc84128261ea2b495042f9f3042 100644 --- a/commons/viewer-common-api/src/main/java/xyz/thoughtset/viewer/common/api/result/Result.java +++ b/commons/viewer-common-api/src/main/java/xyz/thoughtset/viewer/common/api/result/Result.java @@ -8,10 +8,13 @@ import lombok.Data; import lombok.NoArgsConstructor; import lombok.SneakyThrows; +import java.util.Collection; +import java.util.Objects; + @Data @NoArgsConstructor public class Result { - private Integer code; + private Integer status; private String message; private Object data; private long count; @@ -19,8 +22,8 @@ public class Result { private String key; - public Result(Integer code, String message, Object data, long count,byte[] bytes) { - this.code = code; + public Result(Integer status, String message, Object data, long count,byte[] bytes) { + this.status = status; this.message = message; this.data = data; this.count = count; @@ -35,24 +38,34 @@ public class Result { public static Result success(String message, T data,byte[] bytes) { long num = 1; Object obj = data; + if (Objects.nonNull(data)) { + if (data instanceof Collection) { + num = ((Collection) data).size(); + } else if (data.getClass().isArray()) { + num = java.lang.reflect.Array.getLength(data); + } // if (data instanceof Page) { // Page pages = (Page) data; // num = pages.getTotal(); // obj = pages.getResults(); // } - return new Result<>(ResultEnum.SUCCESS.getCode(), message, obj,num, bytes); + } else { + obj = null; + num = 0; + } + return new Result<>(ResultEnum.SUCCESS.getStatus(), message, obj,num, bytes); } public static Result failed(String message) { - return new Result<>(ResultEnum.COMMON_FAILED.getCode(), message, null,0, StrUtil.utf8Bytes(message)); + return new Result<>(ResultEnum.FAILED.getStatus(), message, null,0, StrUtil.utf8Bytes(message)); } public static Result notLogIn() { return failed(ResultEnum.NOTLOGIN); } public static Result failed(ResultEnum errorResult) { - return new Result<>(errorResult.getCode(), errorResult.getMessage(), null,0, StrUtil.utf8Bytes(errorResult.getMessage())); + return new Result<>(errorResult.getStatus(), errorResult.getMessage(), null,0, StrUtil.utf8Bytes(errorResult.getMessage())); } private Result signData(byte[] bytes){ @@ -68,7 +81,7 @@ public class Result { } public boolean hasNotSuccess(){ - return !ResultEnum.SUCCESS.getCode().equals(code); + return !ResultEnum.SUCCESS.getStatus().equals(status); } diff --git a/commons/viewer-common-api/src/main/java/xyz/thoughtset/viewer/common/api/result/ResultEnum.java b/commons/viewer-common-api/src/main/java/xyz/thoughtset/viewer/common/api/result/ResultEnum.java index 9b2a9f97b08d71af1cd6c0e19ab7fd5c7f8cd836..b80455aba1a788d20404e3880ae63372b360b7e1 100644 --- a/commons/viewer-common-api/src/main/java/xyz/thoughtset/viewer/common/api/result/ResultEnum.java +++ b/commons/viewer-common-api/src/main/java/xyz/thoughtset/viewer/common/api/result/ResultEnum.java @@ -1,26 +1,26 @@ package xyz.thoughtset.viewer.common.api.result; public enum ResultEnum { - SUCCESS(200, "接口调用成功"), + SUCCESS(0, "接口调用成功"), FAILED(-1, "接口调用失败"), - VALIDATE_FAILED(-2002, "参数校验失败"), - COMMON_FAILED(-2003, "接口调用失败"), + VALIDATE_FAILED(-2, "参数校验失败"), + COMMON_FAILED(-3, "接口调用失败"), NOTLOGIN(401, "未登录"); - private Integer code; + private Integer status; private String message; - private ResultEnum(Integer code,String message){ - this.code=code; + private ResultEnum(Integer status, String message){ + this.status = status; this.message=message; } - Integer getCode(){return code;} + Integer getStatus(){return status;} String getMessage(){return message;} public static String getVal(String index){ for (ResultEnum ele : ResultEnum.values()) { - if(ele.getCode().equals(index)){ + if(ele.getStatus().equals(index)){ return ele.getMessage(); } } diff --git a/commons/viewer-common-crud/viewer-common-crud-core/src/main/java/xyz/thoughtset/viewer/common/crud/core/handler/BaseMetaHandler.java b/commons/viewer-common-crud/viewer-common-crud-core/src/main/java/xyz/thoughtset/viewer/common/crud/core/handler/BaseMetaHandler.java index 31536f0a8d053bcf90f1dec21abe5e7aa19ab9f6..406eda665573c57d4c9d130411677d33290e6c0f 100644 --- a/commons/viewer-common-crud/viewer-common-crud-core/src/main/java/xyz/thoughtset/viewer/common/crud/core/handler/BaseMetaHandler.java +++ b/commons/viewer-common-crud/viewer-common-crud-core/src/main/java/xyz/thoughtset/viewer/common/crud/core/handler/BaseMetaHandler.java @@ -10,19 +10,19 @@ import java.util.Date; @Slf4j @Component public class BaseMetaHandler implements MetaObjectHandler { - private Integer statesCode = 200; +// private Integer statesCode = 200; @Override public void insertFill(MetaObject metaObject) { this.strictInsertFill(metaObject, "createdAt", Date.class, new Date()); this.strictInsertFill(metaObject, "updatedAt", Date.class, new Date()); - this.strictInsertFill(metaObject, "statesCode", Integer.class, statesCode); +// this.strictInsertFill(metaObject, "statesCode", Integer.class, statesCode); } @Override public void updateFill(MetaObject metaObject) { log.debug(metaObject.getOriginalObject().getClass().getSimpleName()); this.strictUpdateFill(metaObject, "updatedAt", Date.class, new Date()); - this.strictUpdateFill(metaObject, "statesCode", Integer.class, statesCode); +// this.strictUpdateFill(metaObject, "statesCode", Integer.class, statesCode); } } diff --git a/commons/viewer-common-crud/viewer-common-crud-core/src/main/java/xyz/thoughtset/viewer/common/crud/core/service/BaseQueryService.java b/commons/viewer-common-crud/viewer-common-crud-core/src/main/java/xyz/thoughtset/viewer/common/crud/core/service/BaseQueryService.java new file mode 100644 index 0000000000000000000000000000000000000000..00ed63ed255c2462c6ac0c2a55cf87c5a38388c8 --- /dev/null +++ b/commons/viewer-common-crud/viewer-common-crud-core/src/main/java/xyz/thoughtset/viewer/common/crud/core/service/BaseQueryService.java @@ -0,0 +1,26 @@ +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 BaseQueryService { +// public Object createData(LinkedHashMap baseMap); +// +// +// public Object updateData(LinkedHashMap baseMap); +// +// public Object saveData(LinkedHashMap baseMap); +// +// public void deleteByPId(String pid); +// public boolean deleteById(String pkey); + public T selectDetail(String pkey); + public T selectByPId(String pid); + public List listByPId(String pid); + public Page selectPage(Page page, LinkedHashMap baseMap); + + List selectList(LinkedHashMap baseMap); +} diff --git a/commons/viewer-common-crud/viewer-common-crud-core/src/main/java/xyz/thoughtset/viewer/common/crud/core/service/BaseQueryServiceImpl.java b/commons/viewer-common-crud/viewer-common-crud-core/src/main/java/xyz/thoughtset/viewer/common/crud/core/service/BaseQueryServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..2a184c60adfac7a7eb474e9438302d3c88a8c2f3 --- /dev/null +++ b/commons/viewer-common-crud/viewer-common-crud-core/src/main/java/xyz/thoughtset/viewer/common/crud/core/service/BaseQueryServiceImpl.java @@ -0,0 +1,93 @@ +package xyz.thoughtset.viewer.common.crud.core.service; + +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 com.fasterxml.jackson.databind.ObjectMapper; +import lombok.SneakyThrows; +import org.springframework.beans.factory.annotation.Autowired; +import xyz.thoughtset.viewer.common.core.entity.IdMeta; +import xyz.thoughtset.viewer.common.crud.core.util.MPWrapperUtil; + +import java.util.LinkedHashMap; +import java.util.List; + +@SuppressWarnings({"unchecked","SpringJavaInjectionPointsAutowiringInspection"}) +public class BaseQueryServiceImpl, T extends IdMeta> extends ServiceImpl implements BaseService { + @Autowired + protected ObjectMapper mapper; + + @Override + public Object createData(LinkedHashMap baseMap){ + throw new UnsupportedOperationException("createData method is not supported, use saveData instead."); + } + + @Override + public Object updateData(LinkedHashMap baseMap){ + throw new UnsupportedOperationException("createData method is not supported, use saveData instead."); + } + + @Override + public Object saveData(LinkedHashMap baseMap){ + throw new UnsupportedOperationException("createData method is not supported, use saveData instead."); + } + + @Override + public T saveData(T data) { + throw new UnsupportedOperationException("saveData method is not supported, use saveData instead."); + } + + @Override + public void deleteByPId(String pid) { + throw new UnsupportedOperationException("createData method is not supported, use saveData instead."); + } + + @Override + public boolean deleteById(String pkey ){ + throw new UnsupportedOperationException("createData method is not supported, use saveData instead."); + } + + @Override + public T selectDetail(String pkey ){ + return getById(pkey); + } + + @Override + public T selectByPId(String pid) { + QueryWrapper query = new QueryWrapper(); + query.eq("pid",pid); + query.orderByDesc("id"); + return getOne(query); + } + + @Override + public List listByPId(String pid) { + QueryWrapper query = new QueryWrapper(); + query.eq("pid",pid); + query.orderByDesc("id"); + return list(query); + } + + @Override + public Page selectPage(Page page, LinkedHashMap baseMap){ + return page(page, MPWrapperUtil.buildWrapper(convertValue(baseMap))); + } + + @Override + public List selectList(LinkedHashMap baseMap) { + return list(MPWrapperUtil.buildWrapper(convertValue(baseMap))); + } + + @SneakyThrows + public T convertValue(LinkedHashMap baseMap) { + return mapper.convertValue(baseMap,this.getEntityClass()); + } + + protected QueryWrapper pidQueryWrapper(String pid){ + QueryWrapper query = new QueryWrapper(); + query.eq("pid",pid); + return query; + } + +} 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 cbf31e2be7a965d16bf6de504ee6557a4e3bd906..b4f8c25cc5b3bb5c37643932a02b575da36ce7ee 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 @@ -7,13 +7,14 @@ 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); + public T saveData(T data); public void deleteByPId(String pid); public boolean deleteById(String pkey); 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 9825194ed43ab6c9106fc79198b46ba5054279c1..00390cd39cddf0e0e3563cc2789873ecb97595a7 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 @@ -35,9 +35,14 @@ public class BaseServiceImpl , T extends IdMeta> extends @Override public Object saveData(LinkedHashMap baseMap){ Object o = convertValue(baseMap); - saveOrUpdate((T) o); + saveData((T) o); return o; } + @Override + public T saveData(T data){ + saveOrUpdate(data); + return data; + } @Override public void deleteByPId(String pid) { diff --git a/commons/viewer-common-envvar/src/main/java/xyz/thoughtset/viewer/common/envvar/factory/EnvPropSignFactory.java b/commons/viewer-common-envvar/src/main/java/xyz/thoughtset/viewer/common/envvar/factory/EnvPropSignFactory.java index 4b70d50f65f303fd9686638ba584b093997187fb..c1a2afdf295bdf22474a417231c3a1d1defe4650 100644 --- a/commons/viewer-common-envvar/src/main/java/xyz/thoughtset/viewer/common/envvar/factory/EnvPropSignFactory.java +++ b/commons/viewer-common-envvar/src/main/java/xyz/thoughtset/viewer/common/envvar/factory/EnvPropSignFactory.java @@ -30,20 +30,20 @@ public class EnvPropSignFactory { protected ApplicationContext applicationContext; private Map signMap = new HashMap<>(); - private Map LinkMap = new HashMap<>(); + private Map LinkMap = new HashMap<>(); - @PostConstruct - public void init() { - // 创建扫描器,false 表示不检查父类 - ClassPathScanningCandidateComponentProvider scanner = - new ClassPathScanningCandidateComponentProvider(false); - scanner.addIncludeFilter(new AnnotationTypeFilter(EnvPropSign.class)); - // 扫描指定包 - Set beanDefinitions = scanner.findCandidateComponents(scanPackage); - for (BeanDefinition beanDefinition : beanDefinitions) { - try { - Class clazz = Class.forName(beanDefinition.getBeanClassName()); - EnvPropSign envPropSign = clazz.getAnnotation(EnvPropSign.class); + @PostConstruct + public void init() { + // 创建扫描器,false 表示不检查父类 + ClassPathScanningCandidateComponentProvider scanner = + new ClassPathScanningCandidateComponentProvider(false); + scanner.addIncludeFilter(new AnnotationTypeFilter(EnvPropSign.class)); + // 扫描指定包 + Set beanDefinitions = scanner.findCandidateComponents(scanPackage); + for (BeanDefinition beanDefinition : beanDefinitions) { + try { + Class clazz = Class.forName(beanDefinition.getBeanClassName()); + EnvPropSign envPropSign = clazz.getAnnotation(EnvPropSign.class); String key = envPropSign.name(); if (!StringUtils.hasText(key)) { key = StringUtils.uncapitalize(clazz.getSimpleName()); @@ -60,7 +60,7 @@ public class EnvPropSignFactory { } public EnvPropSign getSignInfo(Class key) { - return getSignInfo(key.getSimpleName()); + return (EnvPropSign) key.getAnnotation(EnvPropSign.class); } public EnvPropSign getSignInfo(String key) { return (EnvPropSign) signMap.get(key).getAnnotation(EnvPropSign.class); diff --git a/commons/viewer-common-envvar/src/main/java/xyz/thoughtset/viewer/common/envvar/service/EnvVarsServiceImpl.java b/commons/viewer-common-envvar/src/main/java/xyz/thoughtset/viewer/common/envvar/service/EnvVarsServiceImpl.java index 6317cee49c60ceccee013046cf7de4b607fc4109..62dc95752588899df025acd7906d2509c7636530 100644 --- a/commons/viewer-common-envvar/src/main/java/xyz/thoughtset/viewer/common/envvar/service/EnvVarsServiceImpl.java +++ b/commons/viewer-common-envvar/src/main/java/xyz/thoughtset/viewer/common/envvar/service/EnvVarsServiceImpl.java @@ -21,9 +21,8 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; @Service -@Transactional public class EnvVarsServiceImpl extends BaseServiceImpl implements EnvVarsService { - private static final String TARGET_DATA_KEY = "payload"; + private static final String TARGET_DATA_KEY = "pbo"; private static final ConcurrentHashMap VAR_CACHE = new ConcurrentHashMap<>(); private static final ConcurrentHashMap> VAR_SUB_CACHE = new ConcurrentHashMap<>(); @@ -54,10 +53,20 @@ public class EnvVarsServiceImpl extends BaseServiceImpl imp data.setId(topic); } saveOrUpdate(data); - putCache(data.setBody(targetData)); + putCache(data); return data; } + @Override + public EnvVars selectDetail(String pkey) { + EnvVars envVars = super.selectDetail(pkey); + if (envVars != null) { + envVars.setBody(envSignFactory.loadData(envVars)); + putCache(envVars); + } + return envVars; + } + @Override public EnvVars getEnvVars(String varId) { return findCache(varId); @@ -65,7 +74,8 @@ public class EnvVarsServiceImpl extends BaseServiceImpl imp @Override public Object loadData(String varId) { - return findCache(varId).getPbo(); + EnvVars envVars = findCache(varId); + return Objects.isNull(envVars)?null:envVars.getPbo(); } @SneakyThrows diff --git a/executor/pom.xml b/executor/pom.xml index 6827d6241b6dbdcc8509c7b28a23366e12401af9..b3ab18ece7f813e25d5538a3395c28fbad693541 100644 --- a/executor/pom.xml +++ b/executor/pom.xml @@ -13,6 +13,7 @@ pom viewer-executor-core + viewer-executor-blocks diff --git a/executor/viewer-executor-blocks/pom.xml b/executor/viewer-executor-blocks/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..b02a35e0f1da52d5d09238a4fd7a5f2272ce9767 --- /dev/null +++ b/executor/viewer-executor-blocks/pom.xml @@ -0,0 +1,31 @@ + + + 4.0.0 + + xyz.thoughtset.viewer + executor + ${revision} + + + viewer-executor-blocks + + + 17 + 17 + UTF-8 + + + + + xyz.thoughtset.viewer + viewer-modules-step + + + xyz.thoughtset.viewer + viewer-modules-fun + + + + \ No newline at end of file diff --git a/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/BlocksExecutorAutoConfiguration.java b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/BlocksExecutorAutoConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..097a88e5db73903e96a93fbf9d225621f6868317 --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/BlocksExecutorAutoConfiguration.java @@ -0,0 +1,12 @@ +package xyz.thoughtset.viewer.executor.blocks; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan +@EnableConfigurationProperties +public class BlocksExecutorAutoConfiguration { +} diff --git a/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/constants/NodeConstant.java b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/constants/NodeConstant.java new file mode 100644 index 0000000000000000000000000000000000000000..174d45ec80b6caf16aee78e1be1f422830888184 --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/constants/NodeConstant.java @@ -0,0 +1,12 @@ +package xyz.thoughtset.viewer.executor.blocks.constants; + +public class NodeConstant { + public static final String DATA_NODE = "__E_N_"; + public static final String CURRENT_DATA = "__C_D_"; + public static final String CURRENT_DATA_NODE_INDEX = "__I"; + + public static String getDataNodeWithNum(int index) { + return DATA_NODE+"N" + String.format("%03d",index); + } + +} diff --git a/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/constants/TypeConstants.java b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/constants/TypeConstants.java new file mode 100644 index 0000000000000000000000000000000000000000..a843f78f156de91282cb297bd391a449e167b3ce --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/constants/TypeConstants.java @@ -0,0 +1,29 @@ +package xyz.thoughtset.viewer.executor.blocks.constants; + +import com.google.common.collect.ImmutableMap; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class TypeConstants { + public static final Map TYPE_MAP = new ImmutableMap.Builder() + .put("String", String.class) + .put("Boolean", Boolean.class) + .put("byte", Byte.class) + .put("Double", Double.class) + .put("Integer", Integer.class) + .put("Long", Long.class) + .put("Date", Date.class) + .build(); + + public static final List BASE_TYPE_LIST = TYPE_MAP.entrySet().stream() + .map( e -> { + HashMap map = new HashMap(); + map.put("title",e.getKey()); + map.put("value",e.getKey()); + return map; + }).collect(Collectors.toList()); +} diff --git a/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/BaseBlockBody.java b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/BaseBlockBody.java new file mode 100644 index 0000000000000000000000000000000000000000..fd6ce83602fc64e224089f15fe5837e095398eb4 --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/BaseBlockBody.java @@ -0,0 +1,21 @@ +package xyz.thoughtset.viewer.executor.blocks.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.util.ObjectUtils; +import xyz.thoughtset.viewer.modules.step.entity.block.BlockBodyEle; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class BaseBlockBody { + protected List bodyEles; + + public int listSize() { + return !ObjectUtils.isEmpty(bodyEles) ? bodyEles.size()+2 : 0; + } + +} diff --git a/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/BlockTypeEnum.java b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/BlockTypeEnum.java new file mode 100644 index 0000000000000000000000000000000000000000..36b12f1513fd9e4297c0306ececca47ede18a7f1 --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/BlockTypeEnum.java @@ -0,0 +1,52 @@ +package xyz.thoughtset.viewer.executor.blocks.entity; + +import lombok.Getter; + +@Getter +public enum BlockTypeEnum { + // 任务块 + TASK("task", TaskBody.class), + // 分支块 + CHOOSE("choose", ChooseBody.class), + // 循环块 + LOOP("loop", LoopBody.class), + // 循环块 + ITERATOR("iterator", IteratorBody.class), + // 并行块 +// PARALLEL("parallel", ParallelBody.class), + // MCP + MCP("mcp", MCPBody.class), + VALUE("value", ValueBody.class), + // 单体块 + DEFAULT("default", SingleBody.class), + SINGLE("single", SingleBody.class), + TRANSPOSE("transpose", TransposeBody.class); + + private final String type; + private final Class typeClass; + + BlockTypeEnum(String type,Class typeClass) { + this.type = type; + this.typeClass = typeClass; + } + + + public static BlockTypeEnum fromType(String type) { + for (BlockTypeEnum blockType : BlockTypeEnum.values()) { + if (blockType.getType().equalsIgnoreCase(type)) { + return blockType; + } + } + return DEFAULT; +// throw new IllegalArgumentException("Unknown block type: " + type); + } + + public static BlockTypeEnum fromClass(Class typeArg) { + for (BlockTypeEnum blockType : BlockTypeEnum.values()) { + if (blockType.getTypeClass().equals(typeArg)) { + return blockType; + } + } + throw new IllegalArgumentException("Unknown block type: " + typeArg.getName()); + } +} diff --git a/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/BodyEle.java b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/BodyEle.java new file mode 100644 index 0000000000000000000000000000000000000000..0651474950e30e426e72c586e5ca8ac3354f595e --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/BodyEle.java @@ -0,0 +1,21 @@ +package xyz.thoughtset.viewer.executor.blocks.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class BodyEle { + private String eleId; + private Integer type; + + public boolean eleWasFun() { + return 2 == type.intValue(); + } +// public boolean eleWasBlock() { +// return 1 == type.intValue(); +// } + +} diff --git a/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/ChooseBody.java b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/ChooseBody.java new file mode 100644 index 0000000000000000000000000000000000000000..31bf3ca79853904a75b63701b7210801d355f24a --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/ChooseBody.java @@ -0,0 +1,14 @@ +package xyz.thoughtset.viewer.executor.blocks.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ChooseBody extends BaseBlockBody { + private String caseRepx; + private String bodyType = BlockTypeEnum.CHOOSE.getType(); + +} diff --git a/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/IteratorBody.java b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/IteratorBody.java new file mode 100644 index 0000000000000000000000000000000000000000..a80f9b06b8a871cd1770b7b455c5734c2d898cd1 --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/IteratorBody.java @@ -0,0 +1,14 @@ +package xyz.thoughtset.viewer.executor.blocks.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class IteratorBody extends BaseBlockBody { + private String iteratorRepx; + private String bodyType = BlockTypeEnum.ITERATOR.getType(); + +} diff --git a/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/LoopBody.java b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/LoopBody.java new file mode 100644 index 0000000000000000000000000000000000000000..e113460e7320152a2aaf8b3ac148ddf84034553f --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/LoopBody.java @@ -0,0 +1,15 @@ +package xyz.thoughtset.viewer.executor.blocks.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class LoopBody extends BaseBlockBody { + private String loopRepx; + private boolean doFirst = false; + private String bodyType = BlockTypeEnum.LOOP.getType(); + +} diff --git a/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/MCPBody.java b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/MCPBody.java new file mode 100644 index 0000000000000000000000000000000000000000..c24fb984c409cf9c7027f2d9f26ad2bab59e7261 --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/MCPBody.java @@ -0,0 +1,13 @@ +package xyz.thoughtset.viewer.executor.blocks.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class MCPBody extends BaseBlockBody { + private String bodyType = BlockTypeEnum.MCP.getType(); + +} diff --git a/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/SingleBody.java b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/SingleBody.java new file mode 100644 index 0000000000000000000000000000000000000000..22ce9b432806a1ee1eb579a3c6c07ddea33aa34e --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/SingleBody.java @@ -0,0 +1,18 @@ +package xyz.thoughtset.viewer.executor.blocks.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import xyz.thoughtset.viewer.modules.step.entity.block.BlockBodyEle; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SingleBody extends BaseBlockBody { + private String bodyType = BlockTypeEnum.SINGLE.getType(); + + public BlockBodyEle getNode(){ + return this.getBodyEles().get(0); + } + +} diff --git a/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/TaskBody.java b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/TaskBody.java new file mode 100644 index 0000000000000000000000000000000000000000..0f3183bbd8e67170e3295cf6db90f4712dbc74c0 --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/TaskBody.java @@ -0,0 +1,13 @@ +package xyz.thoughtset.viewer.executor.blocks.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class TaskBody extends BaseBlockBody { + private String bodyType = BlockTypeEnum.TASK.getType(); + +} diff --git a/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/TransposeBody.java b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/TransposeBody.java new file mode 100644 index 0000000000000000000000000000000000000000..492d861e5a9ca9a9c91f6ed82d27beefcb678964 --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/TransposeBody.java @@ -0,0 +1,14 @@ +package xyz.thoughtset.viewer.executor.blocks.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class TransposeBody extends BaseBlockBody { + private String targetRepx; + private String bodyType = BlockTypeEnum.TRANSPOSE.getType(); + +} diff --git a/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/ValueBody.java b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/ValueBody.java new file mode 100644 index 0000000000000000000000000000000000000000..97b75aec3790f58352c78bfa35d01f6720654774 --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/entity/ValueBody.java @@ -0,0 +1,13 @@ +package xyz.thoughtset.viewer.executor.blocks.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ValueBody extends BaseBlockBody { + private String bodyType = BlockTypeEnum.VALUE.getType(); + +} diff --git a/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/AbstractBlockExecutor.java b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/AbstractBlockExecutor.java new file mode 100644 index 0000000000000000000000000000000000000000..b7d9786c32dca4c4887e5d8f1757beea9775a002 --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/AbstractBlockExecutor.java @@ -0,0 +1,145 @@ +package xyz.thoughtset.viewer.executor.blocks.executor; + +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.SneakyThrows; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.expression.ExpressionParser; +import org.springframework.expression.spel.support.StandardEvaluationContext; +import org.springframework.util.ObjectUtils; +import org.springframework.util.StringUtils; +import xyz.thoughtset.viewer.common.exc.exceptions.ExecException; +import xyz.thoughtset.viewer.executor.blocks.entity.BaseBlockBody; +import xyz.thoughtset.viewer.executor.blocks.entity.BlockTypeEnum; +import xyz.thoughtset.viewer.executor.blocks.entity.BodyEle; +import xyz.thoughtset.viewer.modules.ds.core.factory.ExecutorManager; +import xyz.thoughtset.viewer.executor.blocks.constants.NodeConstant; +import xyz.thoughtset.viewer.modules.step.entity.BlockParam; +import xyz.thoughtset.viewer.modules.step.entity.QueryBlock; +import xyz.thoughtset.viewer.modules.step.entity.block.BlockBodyEle; +import xyz.thoughtset.viewer.modules.step.entity.block.BlockInfo; +import xyz.thoughtset.viewer.modules.step.entity.block.EleParam; +import xyz.thoughtset.viewer.modules.step.service.QueryBlockService; + +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.*; +import java.util.stream.Collectors; + +@SuppressWarnings({"unchecked","SpringJavaInjectionPointsAutowiringInspection"}) +public abstract class AbstractBlockExecutor implements InitializingBean { + protected BlockTypeEnum supportType; + @Autowired + protected ExecutorManager executorManager; + @Autowired + protected ObjectMapper objectMapper; + @Autowired + protected BlockExecutorManager blockExecutorManager; + + @Override + public void afterPropertiesSet() throws Exception { + if (supportType == null) { + supportType = getSupportType(); + } + ExecutorRegistry.register(supportType, this); + this.init(); + } + protected void init() {} + + BlockTypeEnum getSupportType(){ + if (supportType == null) { + Type superClass = getClass().getGenericSuperclass(); + if (superClass instanceof ParameterizedType) { + // 获取实际类型参数 + Type[] typeArgs = ((ParameterizedType) superClass).getActualTypeArguments(); +// System.out.println("T's type: " + typeArgs[0]); + supportType = BlockTypeEnum.fromClass((Class) typeArgs[0]); + } + } + return supportType; + } + + @SneakyThrows + public Object executeQuery(BlockInfo block, ExpressionParser parser, Map params, StandardEvaluationContext context) throws ExecException { + T body = null; + try { + body = (T) objectMapper.readValue(block.getDataStr(),supportType.getTypeClass()); + } catch (Exception e) { + body = (T) supportType.getTypeClass().getConstructor().newInstance(); + } + body.setBodyEles((List) block.getBodys()); + if (ObjectUtils.isEmpty(body.getBodyEles()) + && !BlockTypeEnum.TRANSPOSE.equals(supportType)) { + return null; + } + return doQuery(block, body, new HashMap<>(),parser, context); + } + abstract Object doQuery(BlockInfo block, T body, Map params, ExpressionParser parser,StandardEvaluationContext context) throws ExecException; + + protected Map filterParams(BlockBodyEle bodyEle,Map contentMap, ExpressionParser parser,StandardEvaluationContext context){ + Map tmpParamsMap = new HashMap(); + List params = bodyEle.getParams(); + if (Objects.nonNull(params)){ + for (EleParam blockParam : params){ + if(!StringUtils.hasText(blockParam.getDataExp())){ + continue; + } + String exp =blockParam.getDataExp(); + exp = blockParam.getDataExp().startsWith("#")?exp:"#"+exp; + Object value = parser.parseExpression(exp).getValue(context); + context.setVariable(blockParam.getParamId(), value); + tmpParamsMap.put(blockParam.getParamId(), value); + } + } + return tmpParamsMap; + } + + protected Object execNode(BlockBodyEle ele, Map params, ExpressionParser parser, StandardEvaluationContext context){ + Map tmpMap = filterParams(ele, params, parser, context); + Object val = ele.eleWasFun()? blockExecutorManager.execBlocks(ele.getEleId(),tmpMap,parser): + executorManager.execute(ele.getEleId(),tmpMap); + if (ObjectUtils.isEmpty(val) || !StringUtils.hasText(ele.getValNum())) { + return val; + } + if("N".equals(ele.getValNum())){ + if (!(val instanceof Collection || val.getClass().isArray())) { + return new ArrayList<>(Collections.singletonList(val)); + } + } else { + Long index = 0L; + try { + index = Long.parseLong(ele.getValNum()); + }catch (Exception e){} + + if (1L <= index) { + if (val instanceof List) { + if (((Collection) val).size() > index) { + val = ((Collection) val).stream() + .limit(index).collect(Collectors.toList()); + } + } else if (val.getClass().isArray()) { + if (((Object[]) val).length > index) { + val = Arrays.copyOf((Object[]) val, Math.min(((Object[]) val).length, index.intValue())); + } + } else { + val = new ArrayList<>(Collections.singletonList(val)); + } + } else { + if (val instanceof List) { + val = ((Collection) val).stream() + .limit(1).collect(Collectors.toList()).get(0); + } else if (val.getClass().isArray()) { + val = ((Object[]) val)[0]; + } + } + } + return val; + } + + protected void putItVal(int index, Map params,StandardEvaluationContext context,Object val){ + String key = NodeConstant.getDataNodeWithNum(index); + params.put(key, val); + context.setVariable(key, val); + } + +} diff --git a/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/BlockExecutorManager.java b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/BlockExecutorManager.java new file mode 100644 index 0000000000000000000000000000000000000000..56475e171dea9ab3866c08dfd7a2c3129a44c887 --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/BlockExecutorManager.java @@ -0,0 +1,150 @@ +package xyz.thoughtset.viewer.executor.blocks.executor; + +import cn.hutool.core.convert.Convert; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.expression.ExpressionParser; +import org.springframework.expression.spel.standard.SpelExpressionParser; +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.common.exc.entity.ExcInfo; +import xyz.thoughtset.viewer.common.exc.exceptions.ExecException; +import xyz.thoughtset.viewer.modules.fun.constants.FunParamTypeConstant; +import xyz.thoughtset.viewer.modules.fun.entity.FunInfo; +import xyz.thoughtset.viewer.modules.fun.entity.FunParam; +import xyz.thoughtset.viewer.modules.fun.service.FunInfoService; +import xyz.thoughtset.viewer.modules.step.entity.block.BlockInfo; +import xyz.thoughtset.viewer.modules.step.service.BlockInfoService; +import xyz.thoughtset.viewer.modules.step.service.BlockInfoService; + +import java.util.*; + +@Component +public class BlockExecutorManager { + @Autowired + private BlockInfoService blockInfoService; + @Autowired + private FunInfoService funInfoService; +// @Autowired +// protected BlockExecutorManager blockExecutorManager; + + public Object execBlocks(String funId, Map params) { + return execBlocks(funId, params, new SpelExpressionParser(), new StandardEvaluationContext()); + } + public Object execBlocks(String funId,Map params,ExpressionParser parser){ + return execBlocks(funId, params, parser, new StandardEvaluationContext()); + } + public Object execBlocks(String funId,Map params,ExpressionParser parser,StandardEvaluationContext context){ + if (ObjectUtils.isEmpty(params)){ + params = new HashMap<>(); + } + FunInfo funInfo = funInfoService.getById(funId); + if (!StringUtils.hasText(funId) || funInfo == null) return null; + List blocks = blockInfoService.listByPId(funId); + Map contentMap = beforeQuery(params, funInfo,context); + for (BlockInfo block : blocks) { + Object queryResult; + try{ + //todo: block执行 + blockInfoService.loadBlockEles(block); + queryResult = ExecutorRegistry.findExecutor(block.getBodyType()) + .executeQuery(block, parser, contentMap,context); +// queryResult = blockExecutorManager.(block.getId(), params); + }catch (ExecException e){ + throw e.addApiId(funId); + }catch (Exception e){ + ExecException exc = ExcInfo.buildAndThrowExc(e,params); + exc.addBlockId(block.getId()); + exc.addApiId(funId); + throw exc; + } + String key = block.getTitle(); + if (!StringUtils.hasText(key)){ + if (queryResult instanceof Map){ + for (Map.Entry entry : ((Map) queryResult).entrySet()) { + key = Convert.convert(String.class, entry.getKey()); + contentMap.put(key, entry.getValue()); + context.setVariable(key, entry.getValue()); + } + } + continue; + } + Object val = queryResult; + if (block.resultWasSingle() && !ObjectUtils.isEmpty(queryResult)){ + if (val instanceof List){ + val = ((List)queryResult).get(0); + } + }else{ + if (!(val instanceof Collection)){ + val = new ArrayList<>(); + ((ArrayList) val).add(queryResult); + } + } + contentMap.put(key,val); + context.setVariable(key, val); + } + + return afterQuery(contentMap, funInfo,context); + } + + + protected Map beforeQuery(Map searchMap, FunInfo funInfo,StandardEvaluationContext context) { + if (funInfo == null) { + throw new NullPointerException("fun not found"); + } + //过滤入参+临时变量 + Map paramMap = new HashMap<>(); + List inputParams = funInfo.getGroupParams().get(FunParamTypeConstant.INPUT); + if(!ObjectUtils.isEmpty(inputParams) && !ObjectUtils.isEmpty(searchMap)){ + paramMap = new LinkedHashMap<>(); + for(FunParam param : inputParams) { + String key = param.getTitle(); + Object paramValue = searchMap.get(key); + if (paramValue == null) { + paramValue = param.getDefaultVal(); + } + context.setVariable(key, paramValue); + paramMap.put(key, paramValue); + } + } + List innerParams = funInfo.getGroupParams().get(FunParamTypeConstant.INNER); + if (!ObjectUtils.isEmpty(innerParams)){ + for (FunParam param : innerParams) { + String key = param.getTitle(); + Object paramValue = param.getDefaultVal(); + paramMap.put(key, paramValue); + context.setVariable(key, paramValue); + } + } + return paramMap; + } + protected Object afterQuery(Map result, FunInfo funInfo,StandardEvaluationContext context) { + List resultParams = funInfo.getGroupParams().get(FunParamTypeConstant.OUTPUT); + if(!ObjectUtils.isEmpty(resultParams)){ + if (resultParams.size() == 1 ){ + return result.get(resultParams.get(0).getTitle()); + } + Map resultMap = new HashMap<>(); + for (FunParam resultParam : resultParams) { + resultMap.put(resultParam.getTitle(),result.get(resultParam.getTitle())); + } + return resultMap; + } + return result; + } + + protected Map afterQuery(FunInfo funInfo,ExpressionParser parser,StandardEvaluationContext context) { + List resultParams = funInfo.getGroupParams().get(FunParamTypeConstant.OUTPUT); + if(!ObjectUtils.isEmpty(resultParams)){ + Map resultMap = new HashMap<>(); + for (FunParam resultParam : resultParams) { + resultMap.put(resultParam.getTitle(),parser.parseExpression(resultParam.getTitle()).getValue(context)); +// Object value = parser.parseExpression(exp).getValue(context); + } + return resultMap; + } + return null; + } + +} diff --git a/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/ExecutorRegistry.java b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/ExecutorRegistry.java new file mode 100644 index 0000000000000000000000000000000000000000..4af8a5fb27e27096e21d33ceb5cf457b07e57757 --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/ExecutorRegistry.java @@ -0,0 +1,33 @@ +package xyz.thoughtset.viewer.executor.blocks.executor; + + +import xyz.thoughtset.viewer.executor.blocks.entity.BlockTypeEnum; + +import java.util.concurrent.ConcurrentHashMap; + + +public class ExecutorRegistry { + private static AbstractBlockExecutor DEFAULT = null; + private static final ConcurrentHashMap Executor_Map = new ConcurrentHashMap<>(); +// @Getter +// private static final LinkedHashSet Executor_Keys = new LinkedHashSet<>(); + + public static void register(BlockTypeEnum supportType,AbstractBlockExecutor executor) { + Executor_Map.put(supportType, executor); + } + + public static AbstractBlockExecutor findExecutor(String supportType){ + return findExecutor(BlockTypeEnum.fromType(supportType)); + } + public static AbstractBlockExecutor findExecutor(BlockTypeEnum supportType){ + AbstractBlockExecutor executor = Executor_Map.get(supportType); + if (executor == null) { + return DEFAULT; + } + return executor; + } + public static AbstractBlockExecutor setDefault(AbstractBlockExecutor executor) { + return DEFAULT=executor; + } + +} diff --git a/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/IteratorBlockExecutor.java b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/IteratorBlockExecutor.java new file mode 100644 index 0000000000000000000000000000000000000000..a17f46bc8a2ee19139876a5a7e70643b216f34df --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/IteratorBlockExecutor.java @@ -0,0 +1,77 @@ +package xyz.thoughtset.viewer.executor.blocks.executor; + +import org.springframework.expression.ExpressionParser; +import org.springframework.expression.spel.support.StandardEvaluationContext; +import org.springframework.stereotype.Component; +import org.springframework.util.ObjectUtils; +import xyz.thoughtset.viewer.common.exc.exceptions.ExecException; +import xyz.thoughtset.viewer.executor.blocks.constants.NodeConstant; +import xyz.thoughtset.viewer.executor.blocks.entity.IteratorBody; +import xyz.thoughtset.viewer.executor.blocks.entity.LoopBody; +import xyz.thoughtset.viewer.modules.step.entity.block.BlockBodyEle; +import xyz.thoughtset.viewer.modules.step.entity.block.BlockInfo; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.LongAdder; + +//todo +@Component +public class IteratorBlockExecutor extends AbstractBlockExecutor { + + + @Override + Object doQuery(BlockInfo block, IteratorBody body, Map params, ExpressionParser parser, StandardEvaluationContext context) throws ExecException { + List results = new ArrayList<>(); + LongAdder index = new LongAdder(); + context.setVariable(NodeConstant.DATA_NODE, results); + params.put(NodeConstant.DATA_NODE, results); + Collection dataList = dataList(body, params, parser, context); + if (!ObjectUtils.isEmpty(dataList)) { + for (Object data : dataList) { + context.setVariable(NodeConstant.CURRENT_DATA_NODE_INDEX, index.intValue()); + params.put(NodeConstant.CURRENT_DATA_NODE_INDEX, index.intValue()); + params.put(NodeConstant.CURRENT_DATA, data); + context.setVariable(NodeConstant.CURRENT_DATA, data); + doLoop(results, body, params, parser, context, index); + } + } + params.remove(NodeConstant.DATA_NODE); + context.setVariable(NodeConstant.DATA_NODE,null); + context.setVariable(NodeConstant.CURRENT_DATA_NODE_INDEX, null); + params.remove(NodeConstant.CURRENT_DATA_NODE_INDEX); + context.setVariable(NodeConstant.CURRENT_DATA, null); + params.remove(NodeConstant.CURRENT_DATA); + return results; + } + + protected void doLoop(List results, IteratorBody body, Map params, ExpressionParser parser, StandardEvaluationContext context, LongAdder index) { + List eleResults = new ArrayList<>(body.getBodyEles().size()+1); + results.add(eleResults); + for (BlockBodyEle ele : body.getBodyEles()) { + eleResults.add(execNode(ele, params, parser, context)); + } + index.increment(); + } + + protected Collection dataList(IteratorBody body, Map params, ExpressionParser parser, StandardEvaluationContext context) { + String condition = body.getIteratorRepx(); + if (condition != null && !condition.isEmpty()) { + Object result = parser.parseExpression(condition.startsWith("#")?condition:"#"+condition).getValue(context); + if(!ObjectUtils.isEmpty(result)) { + if (result instanceof Map) { + return ((Map) result).entrySet(); + } else if (result instanceof Collection) { + return (Collection) result; + } else { + return List.of(result); + } + } + } + return null; + } + + +} diff --git a/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/LoopBlockExecutor.java b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/LoopBlockExecutor.java new file mode 100644 index 0000000000000000000000000000000000000000..5a125881d081ad47583675659431905cecede076 --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/LoopBlockExecutor.java @@ -0,0 +1,69 @@ +package xyz.thoughtset.viewer.executor.blocks.executor; + +import org.springframework.expression.ExpressionParser; +import org.springframework.expression.spel.support.StandardEvaluationContext; +import org.springframework.stereotype.Component; +import org.springframework.util.ObjectUtils; +import xyz.thoughtset.viewer.common.exc.exceptions.ExecException; +import xyz.thoughtset.viewer.executor.blocks.entity.BodyEle; +import xyz.thoughtset.viewer.executor.blocks.entity.LoopBody; +import xyz.thoughtset.viewer.executor.blocks.constants.NodeConstant; +import xyz.thoughtset.viewer.modules.step.entity.block.BlockBodyEle; +import xyz.thoughtset.viewer.modules.step.entity.block.BlockInfo; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.LongAdder; + +@Component +public class LoopBlockExecutor extends AbstractBlockExecutor { + + + @Override + Object doQuery(BlockInfo block, LoopBody body, Map params, ExpressionParser parser, StandardEvaluationContext context) throws ExecException { + List results = new ArrayList<>(); + context.setVariable(NodeConstant.DATA_NODE, results); + params.put(NodeConstant.DATA_NODE, results); + LongAdder index = new LongAdder(); + context.setVariable(NodeConstant.CURRENT_DATA_NODE_INDEX, index); + params.put(NodeConstant.CURRENT_DATA_NODE_INDEX, index); + if (body.isDoFirst()) { + do { + doLoop(results,body, params, parser, context,index); + }while (checkCondition(body, params, parser, context)); + }else { + while (checkCondition(body, params, parser, context)) { + doLoop(results,body, params, parser, context,index); + } + } + params.remove(NodeConstant.DATA_NODE); + context.setVariable(NodeConstant.DATA_NODE,null); + context.setVariable(NodeConstant.CURRENT_DATA_NODE_INDEX, null); + params.remove(NodeConstant.CURRENT_DATA_NODE_INDEX); + return results; + } + + protected void doLoop(List results,LoopBody body, Map params, ExpressionParser parser, StandardEvaluationContext context,LongAdder index) { + List eleResults = new ArrayList<>(body.getBodyEles().size()+1); + for (BlockBodyEle ele : body.getBodyEles()) { + eleResults.add(execNode(ele, params, parser, context)); + } + results.add(eleResults); + index.increment(); + } + + protected boolean checkCondition(LoopBody body, Map params, ExpressionParser parser, StandardEvaluationContext context) { + String condition = body.getLoopRepx(); + if (condition != null && !condition.isEmpty()) { + Object result = parser.parseExpression(condition.startsWith("#")?condition:"#"+condition).getValue(context); + if (result instanceof Boolean) { + return result != null && ((Boolean) result).booleanValue(); + } + return !ObjectUtils.isEmpty(result); + } + return false; + } + + +} diff --git a/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/MCPBlockExecutor.java b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/MCPBlockExecutor.java new file mode 100644 index 0000000000000000000000000000000000000000..bfbe8c0109b399a803d005066809c551f75d711d --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/MCPBlockExecutor.java @@ -0,0 +1,98 @@ +package xyz.thoughtset.viewer.executor.blocks.executor; + +import org.springframework.expression.ExpressionParser; +import org.springframework.expression.spel.support.StandardEvaluationContext; +import org.springframework.stereotype.Component; +import org.springframework.util.ObjectUtils; +import xyz.thoughtset.viewer.common.exc.exceptions.ExecException; +import xyz.thoughtset.viewer.executor.blocks.constants.NodeConstant; +import xyz.thoughtset.viewer.executor.blocks.entity.MCPBody; +import xyz.thoughtset.viewer.executor.blocks.entity.MCPBody; +import xyz.thoughtset.viewer.modules.step.entity.block.BlockBodyEle; +import xyz.thoughtset.viewer.modules.step.entity.block.BlockInfo; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.LongAdder; + +//todo +//@Component +public class MCPBlockExecutor extends AbstractBlockExecutor { + + + @Override + Object doQuery(BlockInfo block, MCPBody body, Map params, ExpressionParser parser, StandardEvaluationContext context) throws ExecException { + List results = new ArrayList<>(); + StringBuilder sb = new StringBuilder("你是方法调度助手,任务是从用户问题中选择最合适的方法,并给出参数。\n可用方法:\n"); +// registry.getAll().forEach((name, regMethod) -> +// sb.append(name).append(" - ").append(regMethod.description()).append("\n")); + + sb.append("请输出JSON:{\n") + .append(" \"methodName\": \"方法名\",\n") + .append(" \"parameters\": { \"参数名\": 值 }\n") + .append("}\n只输出JSON,不要解释。"); + String systemPrompt = """ + 你是一个数据库查询助手。 + 可用数据库查询方法: + 1. findByName(name: String) - 按名字模糊查找用户 + 2. findByAgeGreaterThan(age: int) - 查询年龄大于指定值的用户 + 3. findByNameAndMinAge(name: String, minAge: int) - 按名字模糊+年龄条件查询 + + 当我给你一个自然语言查询时,请只返回 JSON,不要任何额外说明: + { + "method": "方法名", + "params": { "参数名": 值 } + } + """; +// LongAdder index = new LongAdder(); +// context.setVariable(NodeConstant.DATA_NODE, results); +// params.put(NodeConstant.DATA_NODE, results); +// Collection dataList = dataList(body, params, parser, context); +// if (!ObjectUtils.isEmpty(dataList)) { +// for (Object data : dataList) { +// context.setVariable(NodeConstant.CURRENT_DATA_NODE_INDEX, index.intValue()); +// params.put(NodeConstant.CURRENT_DATA_NODE_INDEX, index.intValue()); +// params.put(NodeConstant.CURRENT_DATA, data); +// context.setVariable(NodeConstant.CURRENT_DATA, data); +// doLoop(results, body, params, parser, context, index); +// } +// } +// params.remove(NodeConstant.DATA_NODE); +// context.setVariable(NodeConstant.DATA_NODE,null); +// context.setVariable(NodeConstant.CURRENT_DATA_NODE_INDEX, null); +// params.remove(NodeConstant.CURRENT_DATA_NODE_INDEX); +// context.setVariable(NodeConstant.CURRENT_DATA, null); +// params.remove(NodeConstant.CURRENT_DATA); + return results; + } + + protected void doLoop(List results, MCPBody body, Map params, ExpressionParser parser, StandardEvaluationContext context, LongAdder index) { + List eleResults = new ArrayList<>(body.getBodyEles().size()+1); + results.add(eleResults); + for (BlockBodyEle ele : body.getBodyEles()) { + eleResults.add(execNode(ele, params, parser, context)); + } + index.increment(); + } + +// protected Collection dataList(MCPBody body, Map params, ExpressionParser parser, StandardEvaluationContext context) { +// String condition = body.getIteratorRepx(); +// if (condition != null && !condition.isEmpty()) { +// Object result = parser.parseExpression(condition.startsWith("#")?condition:"#"+condition).getValue(context); +// if(!ObjectUtils.isEmpty(result)) { +// if (result instanceof Map) { +// return ((Map) result).entrySet(); +// } else if (result instanceof Collection) { +// return (Collection) result; +// } else { +// return List.of(result); +// } +// } +// } +// return null; +// } + + +} diff --git a/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/SingleBlockExecutor.java b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/SingleBlockExecutor.java new file mode 100644 index 0000000000000000000000000000000000000000..cdb3d9816b03aaf861ad003a95fe2172c37c3ae6 --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/SingleBlockExecutor.java @@ -0,0 +1,33 @@ +package xyz.thoughtset.viewer.executor.blocks.executor; + +import org.springframework.expression.ExpressionParser; +import org.springframework.expression.spel.support.StandardEvaluationContext; +import org.springframework.stereotype.Component; +import xyz.thoughtset.viewer.common.exc.exceptions.ExecException; +import xyz.thoughtset.viewer.executor.blocks.entity.BlockTypeEnum; +import xyz.thoughtset.viewer.executor.blocks.entity.SingleBody; +import xyz.thoughtset.viewer.modules.step.entity.block.BlockInfo; + +import java.util.Map; + +@Component +public class SingleBlockExecutor extends AbstractBlockExecutor { + + @Override + protected void init() { + ExecutorRegistry.setDefault(this); + } + + @Override + BlockTypeEnum getSupportType() { + return BlockTypeEnum.SINGLE; + } + + @Override + Object doQuery(BlockInfo block, SingleBody baseBlockBody, Map params, ExpressionParser parser, StandardEvaluationContext context) throws ExecException { + return execNode(baseBlockBody.getNode(), params, parser, context); + } + + + +} diff --git a/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/TaskBlockExecutor.java b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/TaskBlockExecutor.java new file mode 100644 index 0000000000000000000000000000000000000000..901a7e8842147e24d4da98f4f8fcb86cfd00337a --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/TaskBlockExecutor.java @@ -0,0 +1,40 @@ +package xyz.thoughtset.viewer.executor.blocks.executor; + +import org.springframework.expression.ExpressionParser; +import org.springframework.expression.spel.support.StandardEvaluationContext; +import org.springframework.stereotype.Component; +import xyz.thoughtset.viewer.common.exc.exceptions.ExecException; +import xyz.thoughtset.viewer.executor.blocks.constants.NodeConstant; +import xyz.thoughtset.viewer.executor.blocks.entity.BodyEle; +import xyz.thoughtset.viewer.executor.blocks.entity.TaskBody; +import xyz.thoughtset.viewer.modules.step.entity.block.BlockBodyEle; +import xyz.thoughtset.viewer.modules.step.entity.block.BlockInfo; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@Component +public class TaskBlockExecutor extends AbstractBlockExecutor { + + + @Override + Object doQuery(BlockInfo block, TaskBody baseBlockBody, Map params, ExpressionParser parser, StandardEvaluationContext context) throws ExecException { + // Implement the logic for executing a loop block here + // This is a placeholder implementation + List results = new ArrayList<>(baseBlockBody.listSize()); + + context.setVariable("__ELENODE_", results); + params.put("__ELENODE_", results); +// int index = 0; + for (BlockBodyEle ele : baseBlockBody.getBodyEles()) { + results.add(execNode(ele, params, parser, context)); + } + params.remove(NodeConstant.DATA_NODE); + context.setVariable(NodeConstant.DATA_NODE,null); + return results; + } + + + +} diff --git a/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/TransposeBlockExecutor.java b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/TransposeBlockExecutor.java new file mode 100644 index 0000000000000000000000000000000000000000..f3f3791b473e88f9dafcead7997ff1f653488c8e --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/TransposeBlockExecutor.java @@ -0,0 +1,105 @@ +package xyz.thoughtset.viewer.executor.blocks.executor; + +import org.springframework.expression.ExpressionParser; +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.common.exc.exceptions.ExecException; +import xyz.thoughtset.viewer.executor.blocks.entity.BlockTypeEnum; +import xyz.thoughtset.viewer.executor.blocks.entity.TransposeBody; +import xyz.thoughtset.viewer.executor.blocks.entity.ValueBody; +import xyz.thoughtset.viewer.modules.step.entity.block.BlockBodyEle; +import xyz.thoughtset.viewer.modules.step.entity.block.BlockInfo; +import xyz.thoughtset.viewer.modules.step.entity.block.EleParam; + +import java.util.*; + +@Component +public class TransposeBlockExecutor extends AbstractBlockExecutor { + + + @Override + BlockTypeEnum getSupportType() { + return BlockTypeEnum.TRANSPOSE; + } + + + @Override + Object doQuery(BlockInfo block, TransposeBody body, Map params, ExpressionParser parser, StandardEvaluationContext context) throws ExecException { + //行列转换 + String exp = body.getTargetRepx(); + exp = exp.startsWith("#")?exp:"#"+exp; + Object value = parser.parseExpression(exp).getValue(context); + if (ObjectUtils.isEmpty(value)) return value; + if (value instanceof List){ + List list = (List) value; + TreeMap table = new TreeMap<>(); + int columnLen = list.size(); + for(int i = 0;i(columnLen+1); + table.put(j,colList); + } + colList.add(val); + } + } + ArrayList arrayList = new ArrayList<>(table.size()); + for (Map.Entry entry: table.entrySet()){ + arrayList.add(entry.getValue()); + } + value = arrayList; + } else if (value instanceof Map) { + value = mapTranspose((Map) value); + } + return value; + } + + private List mapTranspose(Map dataMap){ + int size = dataMap.size(); + List list = new ArrayList<>(2); + List list0 = new ArrayList<>(size); + List list1 = new ArrayList<>(size); + for (Map.Entry entry: dataMap.entrySet()){ + list0.add(entry.getKey()); + list1.add(entry.getValue()); + } + list.add(list0); + list.add(list1); + return list; + } +// @Override +// public Object executeQuery(BlockInfo block, ExpressionParser parser, Map params, StandardEvaluationContext context) throws ExecException { +// BlockBodyEle bodyEle = block.getFirstBody(); +// List eleParams = bodyEle.getParams(); +// if (Objects.nonNull(eleParams)){ +// for (EleParam blockParam : eleParams){ +// Object value = null; +// if(!StringUtils.hasLength(blockParam.getDataExp())){ +// String exp =blockParam.getDataExp(); +// exp = blockParam.getDataExp().startsWith("#")?exp:"#"+exp; +// value = parser.parseExpression(exp).getValue(context); +// } +// //qbid作为值对应名称进行存入 +// context.setVariable(blockParam.getParamId(), value); +// params.put(blockParam.getParamId(), value); +// } +// } +// return null; +// } +// +// @Override +// Object doQuery(BlockInfo block, TransposeBody body, Map params, ExpressionParser parser, StandardEvaluationContext context) throws ExecException { +// return null; +// } +} +//'003','数学',85); +//'002','英语',90); +//'003','政治',82); +//003 002 003 +//数学 英语 政治 +//85 90 82 \ No newline at end of file diff --git a/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/ValueBlockExecutor.java b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/ValueBlockExecutor.java new file mode 100644 index 0000000000000000000000000000000000000000..fa4a4a13042208d5c1f3e1a03dcae81d7c37a592 --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/java/xyz/thoughtset/viewer/executor/blocks/executor/ValueBlockExecutor.java @@ -0,0 +1,61 @@ +package xyz.thoughtset.viewer.executor.blocks.executor; + +import org.springframework.expression.ExpressionParser; +import org.springframework.expression.spel.support.StandardEvaluationContext; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; +import xyz.thoughtset.viewer.common.exc.exceptions.ExecException; +import xyz.thoughtset.viewer.executor.blocks.entity.BlockTypeEnum; +import xyz.thoughtset.viewer.executor.blocks.entity.ValueBody; +import xyz.thoughtset.viewer.modules.step.entity.BlockParam; +import xyz.thoughtset.viewer.modules.step.entity.block.BlockBodyEle; +import xyz.thoughtset.viewer.modules.step.entity.block.BlockInfo; +import xyz.thoughtset.viewer.modules.step.entity.block.EleParam; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@Component +public class ValueBlockExecutor extends AbstractBlockExecutor { + + + @Override + BlockTypeEnum getSupportType() { + return BlockTypeEnum.VALUE; + } + + @Override + public Object executeQuery(BlockInfo block, ExpressionParser parser, Map params, StandardEvaluationContext context) throws ExecException { + HashMap resultMaps = new HashMap<>(); + BlockBodyEle bodyEle = block.firstBody(); + List eleParams = bodyEle.getParams(); + if (Objects.nonNull(eleParams)){ + int size = eleParams.size(); + for (EleParam blockParam : eleParams){ + Object value = null; + if(StringUtils.hasLength(blockParam.getDataExp())){ + String exp =blockParam.getDataExp(); + exp = blockParam.getDataExp().startsWith("#")?exp:"#"+exp; + value = parser.parseExpression(exp).getValue(context); + } + //qbid作为值对应名称进行存入 + String key = blockParam.getParamId(); + if (StringUtils.hasText(key)){ + context.setVariable(key, value); + params.put(key, value); + resultMaps.put(key, value); + } else if (size == 1) { + return value; + } + } + } + return resultMaps; + } + + @Override + Object doQuery(BlockInfo block, ValueBody body, Map params, ExpressionParser parser, StandardEvaluationContext context) throws ExecException { + return null; + } +} diff --git a/executor/viewer-executor-blocks/src/main/resources/META-INF/spring.factories b/executor/viewer-executor-blocks/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000000000000000000000000000000000000..5ee0938d939a30c735a86b25390201c14f57201d --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/resources/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=xyz.thoughtset.viewer.executor.blocks \ No newline at end of file diff --git a/executor/viewer-executor-blocks/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/executor/viewer-executor-blocks/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000000000000000000000000000000000000..7d9cbb5605f32a88bb8b8b1b9d67f000de3980bd --- /dev/null +++ b/executor/viewer-executor-blocks/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +xyz.thoughtset.viewer.executor.blocks.BlocksExecutorAutoConfiguration \ No newline at end of file diff --git a/executor/viewer-executor-core/src/main/java/xyz/thoughtset/viewer/executor/core/service/QueryBodyServiceImpl.java b/executor/viewer-executor-core/src/main/java/xyz/thoughtset/viewer/executor/core/service/QueryBodyServiceImpl.java index 64b62ce3092d18d9316245325d49846db34b04a0..8391d530f07928d36ab8e9cdbafc2753f7cdf6ea 100644 --- a/executor/viewer-executor-core/src/main/java/xyz/thoughtset/viewer/executor/core/service/QueryBodyServiceImpl.java +++ b/executor/viewer-executor-core/src/main/java/xyz/thoughtset/viewer/executor/core/service/QueryBodyServiceImpl.java @@ -18,7 +18,6 @@ import java.util.List; import java.util.stream.Collectors; @Service -@Transactional public class QueryBodyServiceImpl extends BaseServiceImpl implements QueryBodyService { @Autowired @@ -26,6 +25,7 @@ public class QueryBodyServiceImpl extends BaseServiceImpl baseMap) { QueryBody entity = (QueryBody) super.saveData(baseMap); QueryWrapper paramQuery = new QueryWrapper(); diff --git a/modules/pom.xml b/modules/pom.xml index 1c6342ae503a1373c796629f4489f3e5fe978ff2..17a4ed1d8f293a5ba606f7e56dcabb12472baffd 100644 --- a/modules/pom.xml +++ b/modules/pom.xml @@ -15,7 +15,9 @@ viewer-modules-step viewer-modules-ds viewer-modules-api - viewer-modules-excel + viewer-modules-export + viewer-modules-fun + viewer-modules-datarel diff --git a/modules/viewer-modules-api/pom.xml b/modules/viewer-modules-api/pom.xml index 52375d4c12b5e8dc10bc12ce2d7bd8f65ad3cf2f..6d7c3f4c84ed430cd92039c5da17007e82fff7f8 100644 --- a/modules/viewer-modules-api/pom.xml +++ b/modules/viewer-modules-api/pom.xml @@ -22,6 +22,11 @@ xyz.thoughtset.viewer viewer-modules-step + + + xyz.thoughtset.viewer + viewer-executor-blocks + xyz.thoughtset.viewer viewer-common-api @@ -29,7 +34,11 @@ xyz.thoughtset.viewer - viewer-modules-excel + viewer-modules-export + + + xyz.thoughtset.viewer + viewer-modules-datarel diff --git a/modules/viewer-modules-api/src/main/java/xyz/thoughtset/viewer/modules/api/constants/ApiParamTypeConstant.java b/modules/viewer-modules-api/src/main/java/xyz/thoughtset/viewer/modules/api/constants/ApiParamTypeConstant.java index 926ec76de45a5d46039d85fc0e8acf3f61cb5f82..db2d04e15f848a1b8d6585ace3ff3ca605c8dee4 100644 --- a/modules/viewer-modules-api/src/main/java/xyz/thoughtset/viewer/modules/api/constants/ApiParamTypeConstant.java +++ b/modules/viewer-modules-api/src/main/java/xyz/thoughtset/viewer/modules/api/constants/ApiParamTypeConstant.java @@ -4,5 +4,7 @@ public class ApiParamTypeConstant { public static final Integer INPUT = 0; public static final Integer OUTPUT = 1; public static final Integer INNER = 2; + public static final Integer RequestParam = 10; + public static final Integer RequestBody = 11; } diff --git a/modules/viewer-modules-api/src/main/java/xyz/thoughtset/viewer/modules/api/controller/RequestController.java b/modules/viewer-modules-api/src/main/java/xyz/thoughtset/viewer/modules/api/controller/RequestController.java new file mode 100644 index 0000000000000000000000000000000000000000..aba79ac3e9adf3ecf75180ca7060c3c2eb5d7151 --- /dev/null +++ b/modules/viewer-modules-api/src/main/java/xyz/thoughtset/viewer/modules/api/controller/RequestController.java @@ -0,0 +1,118 @@ +package xyz.thoughtset.viewer.modules.api.controller; + + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.expression.spel.standard.SpelExpressionParser; +import org.springframework.expression.spel.support.StandardEvaluationContext; +import org.springframework.util.ObjectUtils; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.HandlerMapping; +import xyz.thoughtset.viewer.common.api.controller.BaseController; +import xyz.thoughtset.viewer.executor.blocks.executor.BlockExecutorManager; +import xyz.thoughtset.viewer.modules.api.constants.ApiParamTypeConstant; +import xyz.thoughtset.viewer.modules.api.entity.ApiInfo; +import xyz.thoughtset.viewer.modules.api.entity.ApiParam; +import xyz.thoughtset.viewer.modules.api.service.ApiInfoService; +import xyz.thoughtset.viewer.modules.datarel.constants.RelTopicConstant; +import xyz.thoughtset.viewer.modules.datarel.entity.DataRel; + +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +@Slf4j +//@ResponseBody +@SuppressWarnings({"unchecked","SpringJavaInjectionPointsAutowiringInspection"}) +public class RequestController extends BaseController { + @Autowired + protected BlockExecutorManager blockExecutorManager; +// @Autowired +// protected ApiInfoService apiInfoService; + + @Setter + String key; + @Setter + String beanName; + + ApiInfo apiInfo; + + public void setApiInfo(ApiInfo apiInfo) { + this.apiInfo = apiInfo; + if (apiInfo != null && !ObjectUtils.isEmpty(apiInfo.getId())) { + key = apiInfo.getId(); + } + } + + + + @RequestMapping + @ResponseBody + public Object invoke(HttpServletRequest request, HttpServletResponse response, + @RequestBody(required = false) Map requestBody, +// @PathVariable(required = false) Map pathVariables, + @RequestHeader(required = false) Map defaultHeaders, + @RequestParam(required = false) Map parameters){ + System.out.println(request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE)); + Map dataMap; + dataMap = switch (apiInfo.getQueryType()){ + case 12 -> requestBody; + case 11 -> parameters; + default -> new HashMap<>(); + }; + if (dataMap == null) dataMap = new HashMap<>(); + List apiParams = apiInfo.getApiParams(); + for (ApiParam param:apiParams){ + int typeNum = param.getParamType(); + if (ApiParamTypeConstant.RequestParam == typeNum){ + filterParam(param,parameters,dataMap); + } else if (ApiParamTypeConstant.RequestBody == typeNum){ + filterParam(param,requestBody,dataMap); + } else if (ApiParamTypeConstant.INNER == typeNum){ + String key = param.getTitle(); + Object paramValue = param.getDefaultVal(); + dataMap.put(key, paramValue); + } + } + SpelExpressionParser parser = new SpelExpressionParser(); + StandardEvaluationContext context = new StandardEvaluationContext(); + context.setVariables(dataMap); + String execKey = chooseExecKey(parser,context); + if (!StringUtils.hasText(execKey)) return null; + return blockExecutorManager.execBlocks(execKey,dataMap,parser,context); + } + + protected void filterParam(ApiParam param,Map inMap,Map map){ + String key = param.getTitle(); + Object paramValue = inMap.get(key); + if (paramValue == null) { + paramValue = param.getDefaultVal(); + } + map.put(key, paramValue); + } + + protected String chooseExecKey(SpelExpressionParser parser,StandardEvaluationContext context){ + List funRels = apiInfo.groupRels().get(RelTopicConstant.FUN_INFO); + for (DataRel rel : funRels){ + String exp = rel.getDataExp(); + if (!StringUtils.hasText(exp)) return rel.getTarget(); + if (checkCondition(exp, parser, context)) return rel.getTarget(); + } + return null; + } + + private boolean checkCondition(String exp, SpelExpressionParser parser, StandardEvaluationContext context) { + Object result = parser.parseExpression(exp.startsWith("#")?exp:"#"+exp).getValue(context); + if (result instanceof Boolean) { + return result != null && ((Boolean) result).booleanValue(); + } + return !ObjectUtils.isEmpty(result); + } + +} diff --git a/modules/viewer-modules-api/src/main/java/xyz/thoughtset/viewer/modules/api/entity/ApiInfo.java b/modules/viewer-modules-api/src/main/java/xyz/thoughtset/viewer/modules/api/entity/ApiInfo.java index daaa81c272792ce9d362ec23dde930e0592d6609..49abfb99be55aefde292015c812f700d736e7ca9 100644 --- a/modules/viewer-modules-api/src/main/java/xyz/thoughtset/viewer/modules/api/entity/ApiInfo.java +++ b/modules/viewer-modules-api/src/main/java/xyz/thoughtset/viewer/modules/api/entity/ApiInfo.java @@ -3,11 +3,13 @@ package xyz.thoughtset.viewer.modules.api.entity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import org.springframework.util.ObjectUtils; +import org.springframework.web.bind.annotation.RequestMethod; import xyz.thoughtset.viewer.common.core.entity.BaseMeta; import xyz.thoughtset.viewer.common.crud.core.annotation.ApiCRUDPower; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import xyz.thoughtset.viewer.modules.datarel.entity.DataRel; import java.util.List; import java.util.Map; @@ -15,16 +17,30 @@ import java.util.Map; @TableName @Data @AllArgsConstructor -@NoArgsConstructor @ApiCRUDPower(insert = false,save = true,update = false,list = true) public class ApiInfo extends BaseMeta { - +// private String funId; private String url; private Integer queryType; private Integer cacheTime; @TableField(exist = false) private List apiParams; + @TableField(exist = false) + private List dataRels; + + @TableField(exist = false) + private transient Map> dataRelMaps; + + public ApiInfo() { + this.queryType = null; + this.statesCode = null; + } + + public ApiInfo(String id, Integer statesCode) { + this.id = id; + this.statesCode = statesCode; + } public Map> groupParams(){ if (ObjectUtils.isEmpty(apiParams)) { @@ -34,5 +50,21 @@ public class ApiInfo extends BaseMeta { .collect(java.util.stream.Collectors.groupingBy(ApiParam::getParamType)); } + public Map> groupRels(){ + if (!ObjectUtils.isEmpty(dataRelMaps)) { + return dataRelMaps; + } + if (ObjectUtils.isEmpty(dataRels)) { + return Map.of(); + } + dataRelMaps = dataRels.stream() + .collect(java.util.stream.Collectors.groupingBy(DataRel::getTopic)); + return dataRelMaps; + } + + + public RequestMethod apiReqMethod() { + return queryType==11?RequestMethod.GET:RequestMethod.POST; + } } diff --git a/modules/viewer-modules-api/src/main/java/xyz/thoughtset/viewer/modules/api/service/ApiInfoService.java b/modules/viewer-modules-api/src/main/java/xyz/thoughtset/viewer/modules/api/service/ApiInfoService.java index 99e82eaa3d7e8793d90adee3254fedeb0ac670b6..5aed840776b8393ebaa4dc878251e030c5c9d099 100644 --- a/modules/viewer-modules-api/src/main/java/xyz/thoughtset/viewer/modules/api/service/ApiInfoService.java +++ b/modules/viewer-modules-api/src/main/java/xyz/thoughtset/viewer/modules/api/service/ApiInfoService.java @@ -5,4 +5,10 @@ import xyz.thoughtset.viewer.common.crud.core.service.BaseService; import xyz.thoughtset.viewer.modules.api.entity.ApiInfo; public interface ApiInfoService extends BaseService { + void publishApi(String id); + void unpublishedApi(String id); + + boolean checkUnique(ApiInfo entity); + boolean checkNoWorking(ApiInfo entity); + } diff --git a/modules/viewer-modules-api/src/main/java/xyz/thoughtset/viewer/modules/api/service/ApiInfoServiceImpl.java b/modules/viewer-modules-api/src/main/java/xyz/thoughtset/viewer/modules/api/service/ApiInfoServiceImpl.java index 7b5337f74a6fb0cedaa1d0539bb929b41910630d..c5397fabfeab309a53f19b971f646bf6acce7cc0 100644 --- a/modules/viewer-modules-api/src/main/java/xyz/thoughtset/viewer/modules/api/service/ApiInfoServiceImpl.java +++ b/modules/viewer-modules-api/src/main/java/xyz/thoughtset/viewer/modules/api/service/ApiInfoServiceImpl.java @@ -1,11 +1,17 @@ package xyz.thoughtset.viewer.modules.api.service; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import lombok.SneakyThrows; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.event.EventListener; +import org.springframework.util.StringUtils; import xyz.thoughtset.viewer.common.crud.core.service.BaseServiceImpl; import xyz.thoughtset.viewer.modules.api.dao.ApiInfoDao; import xyz.thoughtset.viewer.modules.api.dao.ApiParamDao; import xyz.thoughtset.viewer.modules.api.entity.ApiInfo; import xyz.thoughtset.viewer.modules.api.entity.ApiParam; +import xyz.thoughtset.viewer.modules.datarel.service.DataRelService; import xyz.thoughtset.viewer.modules.step.entity.QueryBlock; import xyz.thoughtset.viewer.modules.step.service.QueryBlockService; import org.springframework.beans.factory.annotation.Autowired; @@ -26,16 +32,29 @@ public class ApiInfoServiceImpl extends BaseServiceImpl imp private ApiParamDao apiParamDao; @Autowired private QueryBlockService queryBlockService; + @Autowired + private DynamicApiService dynamicApiService; + @Autowired + private DataRelService dataRelService; @Override - public Object saveData(LinkedHashMap baseMap) { - ApiInfo entity = (ApiInfo) super.saveData(baseMap); + public ApiInfo saveData(ApiInfo entity) { + if(ObjectUtils.isEmpty(entity.getQueryType())) { + entity.setQueryType(0); + } + if(entity.getQueryType()>10){ + entity.setStatesCode(100); + if (!StringUtils.hasText(entity.getUrl())) throw new RuntimeException("URL WAS NULL"); + } + if (checkUnique(entity)){ + throw new RuntimeException("url was been used"); + } + if (checkNoWorking(entity)){ + throw new RuntimeException("entity was working"); + } + saveOrUpdate(entity); List apiParams = entity.getApiParams(); if (!ObjectUtils.isEmpty(apiParams)){ - for (ApiParam param : apiParams){ - param.setPid(entity.getId()); - apiParamDao.insertOrUpdate(param); - } QueryWrapper paramQuery = new QueryWrapper(); paramQuery.lambda().eq(ApiParam::getPid,entity.getId()).select(ApiParam::getId); List oldParams = apiParamDao.selectList(paramQuery); @@ -53,27 +72,103 @@ public class ApiInfoServiceImpl extends BaseServiceImpl imp apiParamDao.deleteByIds(delIds); } } - + dataRelService.saveRels(entity.getId(),entity.getDataRels()); return entity; } @Override public ApiInfo getById(Serializable id) { ApiInfo result = super.getById(id); - QueryWrapper query = new QueryWrapper(); - query.lambda().eq(ApiParam::getPid,id).orderByAsc(ApiParam::getOrderNum).orderByDesc(ApiParam::getUpdatedAt); - result.setApiParams(apiParamDao.selectList(query)); + fillObj(result); return result; } + private ApiInfo fillObj(ApiInfo apiInfo) { + String pkey = apiInfo.getId(); + QueryWrapper query = new QueryWrapper(); + query.lambda().eq(ApiParam::getPid,pkey).orderByAsc(ApiParam::getOrderNum).orderByDesc(ApiParam::getUpdatedAt); + apiInfo.setApiParams(apiParamDao.selectList(query)); + apiInfo.setDataRels(dataRelService.listByPId(pkey)); + return apiInfo; + } + @Override public boolean deleteById(String pkey) { + if (dynamicApiService.checkHasWorking(pkey)){ + throw new RuntimeException("正在使用中请先停止再删除"); + } List blocks = queryBlockService.listByPId(pkey); - for (QueryBlock block : blocks){ - queryBlockService.deleteById(block.getId()); + if (!ObjectUtils.isEmpty(blocks)) { + for (QueryBlock block : blocks){ + queryBlockService.deleteById(block.getId()); + } } QueryWrapper query = this.pidQueryWrapper(pkey); apiParamDao.delete(query); + dataRelService.delRelsByPId(pkey); return super.deleteById(pkey); } + + @Override + public boolean checkUnique(ApiInfo entity) { + String url = entity.getUrl(); + if (StringUtils.hasText(url)) return false; + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(ApiInfo::getUrl, url); + if (StringUtils.hasText(entity.getId())) { + queryWrapper.lambda().ne(ApiInfo::getId, entity.getId()); + } + return this.count(queryWrapper) == 0; + } + + @Override + public boolean checkNoWorking(ApiInfo entity) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda() + .eq(ApiInfo::getId, entity.getId()) + .eq(ApiInfo::getStatesCode, 200); + return this.count(queryWrapper) > 0; + } + + + @SneakyThrows + @Override + public void publishApi(String id) { + ApiInfo apiInfo = getById(id); + baseMapper.updateById(new ApiInfo(id, 200)); + if(apiInfo.getQueryType()>10){ + dynamicApiService.registerMapping(apiInfo); + apiInfo.groupRels(); + } + } + + @Override + @SneakyThrows + public void unpublishedApi(String id) { +// dynamicApiService.unregisterMapping(super.getById(id)); + baseMapper.updateById(new ApiInfo(id, 100)); + dynamicApiService.unregisterMapping(id); + } + + @EventListener(ApplicationReadyEvent.class) + public void initData() { + // 初始化时加载所有API + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda() +// .select(ApiInfo::getId, ApiInfo::getUrl, ApiInfo::getStatesCode) + .eq(ApiInfo::getStatesCode, 200) + .isNotNull(ApiInfo::getQueryType) + .ge(ApiInfo::getQueryType,10); // 仅加载发布状态的API + List apiInfos = this.list(queryWrapper); + apiInfos.parallelStream() + .forEach(apiInfo -> { + try { + dynamicApiService.registerMapping(apiInfo); + fillObj(apiInfo); + apiInfo.groupRels(); + } catch (Exception e) { + throw new RuntimeException(e); + } + }); + } } diff --git a/modules/viewer-modules-api/src/main/java/xyz/thoughtset/viewer/modules/api/service/DynamicApiService.java b/modules/viewer-modules-api/src/main/java/xyz/thoughtset/viewer/modules/api/service/DynamicApiService.java new file mode 100644 index 0000000000000000000000000000000000000000..e7f09bf0a2a4fc49a45b1cde87f01621ea5f925d --- /dev/null +++ b/modules/viewer-modules-api/src/main/java/xyz/thoughtset/viewer/modules/api/service/DynamicApiService.java @@ -0,0 +1,126 @@ +package xyz.thoughtset.viewer.modules.api.service; + +import cn.hutool.core.map.BiMap; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.support.BeanDefinitionBuilder; +import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import org.springframework.context.ApplicationContext; +import org.springframework.stereotype.Component; +import org.springframework.util.ReflectionUtils; +import org.springframework.util.StringUtils; +import org.springframework.web.servlet.mvc.method.RequestMappingInfo; +import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; +import xyz.thoughtset.viewer.modules.api.controller.RequestController; +import xyz.thoughtset.viewer.modules.api.dao.ApiInfoDao; +import xyz.thoughtset.viewer.modules.api.entity.ApiInfo; + +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; + +@Slf4j +@Component +@RequiredArgsConstructor(onConstructor =@__(@Autowired)) +public class DynamicApiService implements InitializingBean { + private volatile static BiMap WORKINGBIMAP = new BiMap<>(new HashMap<>()); + private volatile static ConcurrentHashMap REQINFOCACHE = new ConcurrentHashMap<>(); + private final ApplicationContext applicationContext; + //将applicationContext转换为ConfigurableApplicationContext +// private ConfigurableApplicationContext configurableApplicationContext; + + // 获取bean工厂并转换为DefaultListableBeanFactory + private final DefaultListableBeanFactory defaultListableBeanFactory; + private final RequestMappingHandlerMapping requestMappingHandlerMapping; + + @Override + public void afterPropertiesSet() throws Exception { + + } + + private String registerBean(ApiInfo apiInfo){ + String intfKey = apiInfo.getId(); + String beanName = "Bean_"+intfKey; + putMappingWorking(beanName, apiInfo.getUrl()); + BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder.genericBeanDefinition(RequestController.class); + BeanDefinition beanDefinition = beanDefinitionBuilder.getRawBeanDefinition(); + beanDefinition.getPropertyValues() + .add("beanName",beanName) + .add("apiInfo", apiInfo); + //设置当前bean定义对象是单利的 + beanDefinition.setScope("singleton"); + defaultListableBeanFactory.registerBeanDefinition(beanName, beanDefinition); + return beanName; + } + public void registerMapping(ApiInfo apiInfo) throws Exception { + String path = apiInfo.getUrl(); + if (!StringUtils.hasText(path)) return; + //先注册bean + String beanName = registerBean(apiInfo); +// RequetMappingHandlerMapping requestMappingHandlerMapping = applicationContext.getBean(RequestMappingHandlerMapping.class); + if (!path.startsWith("/")) path = "/"+path; + RequestMappingInfo requestMappingInfo = RequestMappingInfo + .paths(path).methods(apiInfo.apiReqMethod()) + .build(); + Method handlerMethod = ReflectionUtils.findMethod(RequestController.class,"invoke",null); + requestMappingHandlerMapping.registerMapping(requestMappingInfo,applicationContext.getBean(beanName),handlerMethod); + REQINFOCACHE.put(beanName,requestMappingInfo); + } + + public void unregisterMapping(ApiInfo apiInfo) throws Exception { + unregisterMapping(apiInfo.getId()); + } + public void unregisterMapping(String apiKey) throws Exception { + String beanName = "Bean_"+ apiKey; +// final RequestMappingHandlerMapping requestMappingHandlerMapping = (RequestMappingHandlerMapping) +// applicationContext.getBean("requestMappingHandlerMapping"); + if (requestMappingHandlerMapping != null) { + Object controller = applicationContext.getBean(beanName); + if (controller == null) { + return; + } + requestMappingHandlerMapping.unregisterMapping(REQINFOCACHE.get(beanName)); +// final Class targetClass = controller.getClass(); +// ReflectionUtils.doWithMethods(targetClass, new ReflectionUtils.MethodCallback() { +// public void doWith(Method method) { +// Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass); +// try { +// Method createMappingMethod = RequestMappingHandlerMapping.class. +// getDeclaredMethod("getMappingForMethod", Method.class, Class.class); +// createMappingMethod.setAccessible(true); +// RequestMappingInfo requestMappingInfo = (RequestMappingInfo) +// createMappingMethod.invoke(requestMappingHandlerMapping, specificMethod, targetClass); +// if (requestMappingInfo != null) { +// requestMappingHandlerMapping.unregisterMapping(requestMappingInfo); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// }, ReflectionUtils.USER_DECLARED_METHODS); + + //卸载bean + defaultListableBeanFactory.removeBeanDefinition(beanName); + } + + WORKINGBIMAP.remove(beanName); + } + + private synchronized void putMappingWorking(String key,String value) { + if (WORKINGBIMAP.containsKey(key)){ + throw new RuntimeException("已激活"); + } + if (WORKINGBIMAP.containsValue(value)){ + throw new RuntimeException("已存在"); + } + WORKINGBIMAP.put(key,value); + } + + public boolean checkHasWorking(String key){ + return WORKINGBIMAP.containsKey("Bean_"+key); + } + +} diff --git a/modules/viewer-modules-datarel/pom.xml b/modules/viewer-modules-datarel/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..d7097b6e696a78558eef10d119bcc525bff4d30d --- /dev/null +++ b/modules/viewer-modules-datarel/pom.xml @@ -0,0 +1,20 @@ + + + 4.0.0 + + xyz.thoughtset.viewer + modules + ${revision} + + + viewer-modules-datarel + + + 17 + 17 + UTF-8 + + + \ No newline at end of file diff --git a/modules/viewer-modules-datarel/src/main/java/xyz/thoughtset/viewer/modules/datarel/ModuleRelsAutoConfiguration.java b/modules/viewer-modules-datarel/src/main/java/xyz/thoughtset/viewer/modules/datarel/ModuleRelsAutoConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..d5542ba21d7c5ad70175a6eaab8ff2769bc64125 --- /dev/null +++ b/modules/viewer-modules-datarel/src/main/java/xyz/thoughtset/viewer/modules/datarel/ModuleRelsAutoConfiguration.java @@ -0,0 +1,13 @@ +package xyz.thoughtset.viewer.modules.datarel; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan +@EnableConfigurationProperties +@MapperScan(basePackages = "xyz.thoughtset.viewer.modules.datarel.dao") +public class ModuleRelsAutoConfiguration { +} diff --git a/modules/viewer-modules-datarel/src/main/java/xyz/thoughtset/viewer/modules/datarel/constants/RelTopicConstant.java b/modules/viewer-modules-datarel/src/main/java/xyz/thoughtset/viewer/modules/datarel/constants/RelTopicConstant.java new file mode 100644 index 0000000000000000000000000000000000000000..6a9edca721f341e3a9b8dee03b0ea764e8f9169f --- /dev/null +++ b/modules/viewer-modules-datarel/src/main/java/xyz/thoughtset/viewer/modules/datarel/constants/RelTopicConstant.java @@ -0,0 +1,6 @@ +package xyz.thoughtset.viewer.modules.datarel.constants; + +public class RelTopicConstant { + public static final String FUN_INFO = "funInfo"; + +} diff --git a/modules/viewer-modules-datarel/src/main/java/xyz/thoughtset/viewer/modules/datarel/dao/DataRelDao.java b/modules/viewer-modules-datarel/src/main/java/xyz/thoughtset/viewer/modules/datarel/dao/DataRelDao.java new file mode 100644 index 0000000000000000000000000000000000000000..7fc731eb663641c803e6d8e1a71525d220b22747 --- /dev/null +++ b/modules/viewer-modules-datarel/src/main/java/xyz/thoughtset/viewer/modules/datarel/dao/DataRelDao.java @@ -0,0 +1,10 @@ +package xyz.thoughtset.viewer.modules.datarel.dao; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import xyz.thoughtset.viewer.modules.datarel.entity.DataRel; + +@Mapper +public interface DataRelDao extends BaseMapper { +} diff --git a/modules/viewer-modules-datarel/src/main/java/xyz/thoughtset/viewer/modules/datarel/entity/DataRel.java b/modules/viewer-modules-datarel/src/main/java/xyz/thoughtset/viewer/modules/datarel/entity/DataRel.java new file mode 100644 index 0000000000000000000000000000000000000000..c1025eba52658e229bc7950467e1d33624267787 --- /dev/null +++ b/modules/viewer-modules-datarel/src/main/java/xyz/thoughtset/viewer/modules/datarel/entity/DataRel.java @@ -0,0 +1,30 @@ +package xyz.thoughtset.viewer.modules.datarel.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.util.ObjectUtils; +import org.springframework.web.bind.annotation.RequestMethod; +import xyz.thoughtset.viewer.common.core.entity.BaseMeta; +import xyz.thoughtset.viewer.common.core.entity.IdMeta; +import xyz.thoughtset.viewer.common.crud.core.annotation.ApiCRUDPower; + +import java.util.List; +import java.util.Map; + +@TableName +@Data +@AllArgsConstructor +@NoArgsConstructor +public class DataRel extends IdMeta { + private Integer orderNum; + private String topic; + private String rel; + private String source; + private String target; + private String dataExp; + + +} diff --git a/modules/viewer-modules-datarel/src/main/java/xyz/thoughtset/viewer/modules/datarel/service/DataRelService.java b/modules/viewer-modules-datarel/src/main/java/xyz/thoughtset/viewer/modules/datarel/service/DataRelService.java new file mode 100644 index 0000000000000000000000000000000000000000..bd9a755b537eb49406f6e581ba6e432a7ee6e4e4 --- /dev/null +++ b/modules/viewer-modules-datarel/src/main/java/xyz/thoughtset/viewer/modules/datarel/service/DataRelService.java @@ -0,0 +1,20 @@ +package xyz.thoughtset.viewer.modules.datarel.service; + + +import xyz.thoughtset.viewer.common.crud.core.service.BaseService; +import xyz.thoughtset.viewer.modules.datarel.entity.DataRel; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public interface DataRelService extends BaseService { + List saveRels(String pId, List dataRels); + + List listByTopic(String topic); + + HashMap> groupRelsByPid(String pid); + + int delRelsByPId(String pId); + +} diff --git a/modules/viewer-modules-datarel/src/main/java/xyz/thoughtset/viewer/modules/datarel/service/DataRelServiceImpl.java b/modules/viewer-modules-datarel/src/main/java/xyz/thoughtset/viewer/modules/datarel/service/DataRelServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..e995e8831e8c31e37517b72d50fa4d39428c2ce6 --- /dev/null +++ b/modules/viewer-modules-datarel/src/main/java/xyz/thoughtset/viewer/modules/datarel/service/DataRelServiceImpl.java @@ -0,0 +1,89 @@ +package xyz.thoughtset.viewer.modules.datarel.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import lombok.SneakyThrows; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.ObjectUtils; +import org.springframework.util.StringUtils; +import xyz.thoughtset.viewer.common.crud.core.service.BaseServiceImpl; +import xyz.thoughtset.viewer.modules.datarel.dao.DataRelDao; +import xyz.thoughtset.viewer.modules.datarel.entity.DataRel; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.concurrent.atomic.LongAdder; +import java.util.stream.Collectors; + +@Service +@Transactional +public class DataRelServiceImpl extends BaseServiceImpl implements DataRelService { + + + @Override + public List saveRels(String pId, List dataRels) { + if (ObjectUtils.isEmpty(dataRels)){ return dataRels; } + QueryWrapper paramQuery = new QueryWrapper(); + paramQuery.lambda().eq(DataRel::getPid,pId).select(DataRel::getId); + List oldParams = baseMapper.selectList(paramQuery); + LongAdder longAdder = new LongAdder(); + HashSet relIds = new HashSet<>(); + for (DataRel ele : dataRels){ + if(!StringUtils.hasText(ele.getSource())){ + ele.setSource(pId); + } + ele.setPid(pId); + longAdder.increment(); + ele.setOrderNum(longAdder.intValue()); + baseMapper.insertOrUpdate(ele); + relIds.add(ele.getId()); + } + if (!ObjectUtils.isEmpty(oldParams)){ + List delIds = oldParams.stream() + .filter(e->!relIds.contains(e.getId())) + .map(DataRel::getId) + .collect(Collectors.toList()); + baseMapper.deleteByIds(delIds); + } + return dataRels; + } + + @Override + public List listByTopic(String topic) { + QueryWrapper query = new QueryWrapper<>(); + query.eq("topic", topic); + return list(query); + } + + @Override + public HashMap> groupRelsByPid(String pid) { + List dataRels = listByPId(pid); + if (ObjectUtils.isEmpty(dataRels)) { + return new HashMap<>(); + } + HashMap> groupedRels = dataRels.stream() + .collect(Collectors.groupingBy(DataRel::getTopic, HashMap::new, Collectors.toList())); + return groupedRels; + } + + @Override + public List listByPId(String pid) { + QueryWrapper queryWrapper = this.pidQueryWrapper(pid); + queryWrapper.lambda() + .orderByAsc(DataRel::getTopic) + .orderByAsc(DataRel::getOrderNum) + .orderByDesc(DataRel::getUpdatedAt); + return list(queryWrapper); + } + + @Override + public int delRelsByPId(String pId) { + return baseMapper.delete(pidQueryWrapper(pId)); + } + +} diff --git a/modules/viewer-modules-datarel/src/main/resources/META-INF/spring.factories b/modules/viewer-modules-datarel/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000000000000000000000000000000000000..d1ebca1b05d899db10c39da4a6f5c43629ea1e7f --- /dev/null +++ b/modules/viewer-modules-datarel/src/main/resources/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=xyz.thoughtset.viewer.modules.datarel \ No newline at end of file diff --git a/modules/viewer-modules-datarel/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/modules/viewer-modules-datarel/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000000000000000000000000000000000000..9d37276b7e93e4caff313c17211166f865a15fc6 --- /dev/null +++ b/modules/viewer-modules-datarel/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +xyz.thoughtset.viewer.modules.datarel.ModuleRelsAutoConfiguration \ 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 fc0e855e99800a7e5857fe3507e3b5ec63a4920f..cc510db87028d738302d42f8440d7d0e281218d5 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 @@ -3,6 +3,8 @@ package xyz.thoughtset.viewer.modules.ds.core.factory; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.DisposableBean; +import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; @@ -20,7 +22,7 @@ import java.util.concurrent.ConcurrentHashMap; @Component @Slf4j -public class ConnectFactory { +public class ConnectFactory implements InitializingBean, DisposableBean { @Autowired private ObjectMapper mapper; @Autowired @@ -28,6 +30,7 @@ public class ConnectFactory { @Autowired private DsConfigDao dsConfigDao; private ConcurrentHashMap DS_CACHE = new ConcurrentHashMap<>(); + public static final DsConfig BLOCK_DS_CONFIG = new DsConfig(); public T buildConnect(String dsId,Class targetType) { return (T) buildConnect(dsId); @@ -67,4 +70,15 @@ public class ConnectFactory { return connBuilder; } + @Override + public void afterPropertiesSet() throws Exception { + log.info("ConnectFactory initialized, DS_CACHE size: {}", DS_CACHE.size()); +// DS_CACHE.put(BLOCK_DS_CONFIG.getId(), BLOCK_DS_CONFIG); + } + + @Override + public void destroy() throws Exception { + log.info("Destroying ConnectFactory, clearing DS_CACHE"); + DS_CACHE.clear(); + } } diff --git a/modules/viewer-modules-ds/viewer-modules-ds-core/src/main/java/xyz/thoughtset/viewer/modules/ds/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 index 9b7a9a625fa780c980ed79f89f5b0774ffe08b2b..9ab85887ada32628ae6e7841a940c677fb6f0d84 100644 --- a/modules/viewer-modules-ds/viewer-modules-ds-core/src/main/java/xyz/thoughtset/viewer/modules/ds/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 @@ -38,8 +38,8 @@ public class ExecutorManager { private final ConnectFactory connectFactory; private final CacheExecutorHelper cacheExecutorHelper; - public Object execute(String bodyId, Map tmpParam){ - QueryBody queryBody = queryBodyService.getById(bodyId); + public Object execute(String queryId, Map tmpParam){ + QueryBody queryBody = queryBodyService.getById(queryId); Map queryMap = queryBody.getParams() .stream() @@ -65,9 +65,10 @@ public class ExecutorManager { }catch (ExecException e){ throw e; }catch (Exception e){ + e.printStackTrace(); ExecException exc = ExcInfo.buildAndThrowExc(e,paramsMap); ExcInfo excInfo = exc.getExcInfo(); - excInfo.setFunId(bodyId); + excInfo.setFunId(queryId); throw exc; } diff --git a/modules/viewer-modules-ds/viewer-modules-ds-core/src/main/java/xyz/thoughtset/viewer/modules/ds/core/service/DsConfigServiceImpl.java b/modules/viewer-modules-ds/viewer-modules-ds-core/src/main/java/xyz/thoughtset/viewer/modules/ds/core/service/DsConfigServiceImpl.java index b4df07e0ad9ffa3e4aa0cdeebb37465060fa1f13..7651486dfd8a0e04f3355387c3695de88bc5766f 100644 --- a/modules/viewer-modules-ds/viewer-modules-ds-core/src/main/java/xyz/thoughtset/viewer/modules/ds/core/service/DsConfigServiceImpl.java +++ b/modules/viewer-modules-ds/viewer-modules-ds-core/src/main/java/xyz/thoughtset/viewer/modules/ds/core/service/DsConfigServiceImpl.java @@ -17,8 +17,6 @@ import java.util.concurrent.ConcurrentHashMap; @Service @Transactional public class DsConfigServiceImpl extends BaseServiceImpl implements DsConfigService { - private ConcurrentHashMap DS_CACHE = new ConcurrentHashMap<>(); - @Autowired private ConnectFactory connectFactory; diff --git a/modules/viewer-modules-excel/pom.xml b/modules/viewer-modules-export/pom.xml similarity index 94% rename from modules/viewer-modules-excel/pom.xml rename to modules/viewer-modules-export/pom.xml index 03a404cac4e3f1249384868c6d8013e0f95a74a3..966ac8d80b130335ecc9bf33c9c7cba4d33015d4 100644 --- a/modules/viewer-modules-excel/pom.xml +++ b/modules/viewer-modules-export/pom.xml @@ -9,7 +9,7 @@ ${revision} - viewer-modules-excel + viewer-modules-export 17 diff --git a/modules/viewer-modules-excel/src/main/java/xyz/thoughtset/viewer/modules/excel/ModuleExcelAutoConfiguration.java b/modules/viewer-modules-export/src/main/java/xyz/thoughtset/viewer/modules/excel/ModuleExcelAutoConfiguration.java similarity index 100% rename from modules/viewer-modules-excel/src/main/java/xyz/thoughtset/viewer/modules/excel/ModuleExcelAutoConfiguration.java rename to modules/viewer-modules-export/src/main/java/xyz/thoughtset/viewer/modules/excel/ModuleExcelAutoConfiguration.java diff --git a/modules/viewer-modules-excel/src/main/java/xyz/thoughtset/viewer/modules/excel/dao/ExportDataInfoDao.java b/modules/viewer-modules-export/src/main/java/xyz/thoughtset/viewer/modules/excel/dao/ExportDataInfoDao.java similarity index 100% rename from modules/viewer-modules-excel/src/main/java/xyz/thoughtset/viewer/modules/excel/dao/ExportDataInfoDao.java rename to modules/viewer-modules-export/src/main/java/xyz/thoughtset/viewer/modules/excel/dao/ExportDataInfoDao.java diff --git a/modules/viewer-modules-excel/src/main/java/xyz/thoughtset/viewer/modules/excel/entity/ExportDataInfo.java b/modules/viewer-modules-export/src/main/java/xyz/thoughtset/viewer/modules/excel/entity/ExportDataInfo.java similarity index 100% rename from modules/viewer-modules-excel/src/main/java/xyz/thoughtset/viewer/modules/excel/entity/ExportDataInfo.java rename to modules/viewer-modules-export/src/main/java/xyz/thoughtset/viewer/modules/excel/entity/ExportDataInfo.java diff --git a/modules/viewer-modules-excel/src/main/java/xyz/thoughtset/viewer/modules/excel/service/ExportDataInfoService.java b/modules/viewer-modules-export/src/main/java/xyz/thoughtset/viewer/modules/excel/service/ExportDataInfoService.java similarity index 100% rename from modules/viewer-modules-excel/src/main/java/xyz/thoughtset/viewer/modules/excel/service/ExportDataInfoService.java rename to modules/viewer-modules-export/src/main/java/xyz/thoughtset/viewer/modules/excel/service/ExportDataInfoService.java diff --git a/modules/viewer-modules-excel/src/main/java/xyz/thoughtset/viewer/modules/excel/service/ExportDataInfoServiceImpl.java b/modules/viewer-modules-export/src/main/java/xyz/thoughtset/viewer/modules/excel/service/ExportDataInfoServiceImpl.java similarity index 100% rename from modules/viewer-modules-excel/src/main/java/xyz/thoughtset/viewer/modules/excel/service/ExportDataInfoServiceImpl.java rename to modules/viewer-modules-export/src/main/java/xyz/thoughtset/viewer/modules/excel/service/ExportDataInfoServiceImpl.java diff --git a/modules/viewer-modules-excel/src/main/resources/META-INF/spring.factories b/modules/viewer-modules-export/src/main/resources/META-INF/spring.factories similarity index 100% rename from modules/viewer-modules-excel/src/main/resources/META-INF/spring.factories rename to modules/viewer-modules-export/src/main/resources/META-INF/spring.factories diff --git a/modules/viewer-modules-excel/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/modules/viewer-modules-export/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports similarity index 100% rename from modules/viewer-modules-excel/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports rename to modules/viewer-modules-export/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports diff --git a/modules/viewer-modules-fun/pom.xml b/modules/viewer-modules-fun/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..96db436614645872e341692e603f4116800296df --- /dev/null +++ b/modules/viewer-modules-fun/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + + xyz.thoughtset.viewer + modules + ${revision} + + + viewer-modules-fun + + + 17 + 17 + UTF-8 + + + + + xyz.thoughtset.viewer + viewer-modules-step + + + + \ No newline at end of file diff --git a/modules/viewer-modules-fun/src/main/java/xyz/thoughtset/viewer/modules/fun/ModuleFunAutoConfiguration.java b/modules/viewer-modules-fun/src/main/java/xyz/thoughtset/viewer/modules/fun/ModuleFunAutoConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..cc76ae2941afeace9fef35ad59801340077c6dde --- /dev/null +++ b/modules/viewer-modules-fun/src/main/java/xyz/thoughtset/viewer/modules/fun/ModuleFunAutoConfiguration.java @@ -0,0 +1,13 @@ +package xyz.thoughtset.viewer.modules.fun; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan +@EnableConfigurationProperties +@MapperScan(basePackages = "xyz.thoughtset.viewer.modules.fun.dao") +public class ModuleFunAutoConfiguration { +} diff --git a/modules/viewer-modules-fun/src/main/java/xyz/thoughtset/viewer/modules/fun/constants/FunParamTypeConstant.java b/modules/viewer-modules-fun/src/main/java/xyz/thoughtset/viewer/modules/fun/constants/FunParamTypeConstant.java new file mode 100644 index 0000000000000000000000000000000000000000..5020924f9fd38946c6a7e5f64c51ff5fad977406 --- /dev/null +++ b/modules/viewer-modules-fun/src/main/java/xyz/thoughtset/viewer/modules/fun/constants/FunParamTypeConstant.java @@ -0,0 +1,8 @@ +package xyz.thoughtset.viewer.modules.fun.constants; + +public class FunParamTypeConstant { + public static final Integer INPUT = 0; + public static final Integer OUTPUT = 1; + public static final Integer INNER = 2; + +} diff --git a/modules/viewer-modules-fun/src/main/java/xyz/thoughtset/viewer/modules/fun/dao/FunInfoDao.java b/modules/viewer-modules-fun/src/main/java/xyz/thoughtset/viewer/modules/fun/dao/FunInfoDao.java new file mode 100644 index 0000000000000000000000000000000000000000..9d299e9a730e49807f9b24f310660cfca12580ab --- /dev/null +++ b/modules/viewer-modules-fun/src/main/java/xyz/thoughtset/viewer/modules/fun/dao/FunInfoDao.java @@ -0,0 +1,10 @@ +package xyz.thoughtset.viewer.modules.fun.dao; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import xyz.thoughtset.viewer.modules.fun.entity.FunInfo; + +@Mapper +public interface FunInfoDao extends BaseMapper { +} diff --git a/modules/viewer-modules-fun/src/main/java/xyz/thoughtset/viewer/modules/fun/dao/FunParamDao.java b/modules/viewer-modules-fun/src/main/java/xyz/thoughtset/viewer/modules/fun/dao/FunParamDao.java new file mode 100644 index 0000000000000000000000000000000000000000..bae38b30ee4d117a314e0f059ff10b6fa048854d --- /dev/null +++ b/modules/viewer-modules-fun/src/main/java/xyz/thoughtset/viewer/modules/fun/dao/FunParamDao.java @@ -0,0 +1,10 @@ +package xyz.thoughtset.viewer.modules.fun.dao; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import xyz.thoughtset.viewer.modules.fun.entity.FunParam; + +@Mapper +public interface FunParamDao extends BaseMapper { +} diff --git a/modules/viewer-modules-fun/src/main/java/xyz/thoughtset/viewer/modules/fun/entity/FunInfo.java b/modules/viewer-modules-fun/src/main/java/xyz/thoughtset/viewer/modules/fun/entity/FunInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..46cc03233bb9c08bbbe2d15b06646b2f2f73800a --- /dev/null +++ b/modules/viewer-modules-fun/src/main/java/xyz/thoughtset/viewer/modules/fun/entity/FunInfo.java @@ -0,0 +1,40 @@ +package xyz.thoughtset.viewer.modules.fun.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.util.ObjectUtils; +import xyz.thoughtset.viewer.common.core.entity.BaseMeta; +import xyz.thoughtset.viewer.common.crud.core.annotation.ApiCRUDPower; + +import java.util.List; +import java.util.Map; + +@TableName +@Data +@AllArgsConstructor +@NoArgsConstructor +@ApiCRUDPower(insert = false, update = false,list = true) +public class FunInfo extends BaseMeta { + + private Integer cacheTime; + + @TableField(exist = false) + private List params; + @TableField(exist = false) + private Map> groupParams; + + public Map> getGroupParams() { + if (ObjectUtils.isEmpty(params)) { + return Map.of(); + } + if (ObjectUtils.isEmpty(groupParams)) { + this.groupParams = params.parallelStream() + .collect(java.util.stream.Collectors.groupingBy(FunParam::getParamType)); + } + return groupParams; + } + +} diff --git a/modules/viewer-modules-fun/src/main/java/xyz/thoughtset/viewer/modules/fun/entity/FunParam.java b/modules/viewer-modules-fun/src/main/java/xyz/thoughtset/viewer/modules/fun/entity/FunParam.java new file mode 100644 index 0000000000000000000000000000000000000000..566a4edd90e288d1093f1c34e428a505c034e7c1 --- /dev/null +++ b/modules/viewer-modules-fun/src/main/java/xyz/thoughtset/viewer/modules/fun/entity/FunParam.java @@ -0,0 +1,20 @@ +package xyz.thoughtset.viewer.modules.fun.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import xyz.thoughtset.viewer.common.core.entity.BaseMeta; +import xyz.thoughtset.viewer.modules.fun.constants.FunParamTypeConstant; + +@TableName +@Data +@AllArgsConstructor +@NoArgsConstructor +public class FunParam extends BaseMeta { + private String dataType; + private String defaultVal; +// private String dataExp; + private Integer paramType = FunParamTypeConstant.INNER; + +} diff --git a/modules/viewer-modules-fun/src/main/java/xyz/thoughtset/viewer/modules/fun/service/FunInfoService.java b/modules/viewer-modules-fun/src/main/java/xyz/thoughtset/viewer/modules/fun/service/FunInfoService.java new file mode 100644 index 0000000000000000000000000000000000000000..de7c6e930e94f181b85cb1f422349644d690498a --- /dev/null +++ b/modules/viewer-modules-fun/src/main/java/xyz/thoughtset/viewer/modules/fun/service/FunInfoService.java @@ -0,0 +1,8 @@ +package xyz.thoughtset.viewer.modules.fun.service; + + +import xyz.thoughtset.viewer.common.crud.core.service.BaseService; +import xyz.thoughtset.viewer.modules.fun.entity.FunInfo; + +public interface FunInfoService extends BaseService { +} diff --git a/modules/viewer-modules-fun/src/main/java/xyz/thoughtset/viewer/modules/fun/service/FunInfoServiceImpl.java b/modules/viewer-modules-fun/src/main/java/xyz/thoughtset/viewer/modules/fun/service/FunInfoServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..20ec8c7d22dfff9b1d67cffdf5ac2466fb4052fe --- /dev/null +++ b/modules/viewer-modules-fun/src/main/java/xyz/thoughtset/viewer/modules/fun/service/FunInfoServiceImpl.java @@ -0,0 +1,82 @@ +package xyz.thoughtset.viewer.modules.fun.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.ObjectUtils; +//import xyz.thoughtset.viewer.common.crud.core.service.BaseServiceImpl; +import xyz.thoughtset.viewer.common.crud.core.service.BaseServiceImpl; +import xyz.thoughtset.viewer.modules.fun.dao.FunInfoDao; +import xyz.thoughtset.viewer.modules.fun.dao.FunParamDao; +import xyz.thoughtset.viewer.modules.fun.entity.FunInfo; +import xyz.thoughtset.viewer.modules.fun.entity.FunParam; +import xyz.thoughtset.viewer.modules.step.entity.QueryBlock; +import xyz.thoughtset.viewer.modules.step.service.QueryBlockService; +//import xyz.thoughtset.viewer.modules.step.entity.QueryBlock; +//import xyz.thoughtset.viewer.modules.step.service.QueryBlockService; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.stream.Collectors; + +@Service +@Transactional +public class FunInfoServiceImpl extends BaseServiceImpl implements FunInfoService { + @Autowired + private FunParamDao apiParamDao; + @Autowired + private QueryBlockService queryBlockService; + + @Override + public Object saveData(LinkedHashMap baseMap) { + FunInfo entity = (FunInfo) super.saveData(baseMap); + List apiParams = entity.getParams(); + if (!ObjectUtils.isEmpty(apiParams)){ + for (FunParam param : apiParams){ + param.setPid(entity.getId()); + apiParamDao.insertOrUpdate(param); + } + QueryWrapper paramQuery = new QueryWrapper(); + paramQuery.lambda().eq(FunParam::getPid,entity.getId()).select(FunParam::getId); + List oldParams = apiParamDao.selectList(paramQuery); + HashSet params = new HashSet<>(); + for (FunParam param : apiParams){ + param.setPid(entity.getId()); + apiParamDao.insertOrUpdate(param); + params.add(param.getId()); + } + if (!ObjectUtils.isEmpty(oldParams)){ + List delIds = oldParams.stream() + .filter(e->!params.contains(e.getId())) + .map(FunParam::getId) // 提取name属性 + .collect(Collectors.toList()); + apiParamDao.deleteByIds(delIds); + } + } + + return entity; + } + + @Override + public FunInfo getById(Serializable id) { + FunInfo result = super.getById(id); + QueryWrapper query = new QueryWrapper(); + query.lambda().eq(FunParam::getPid,id).orderByAsc(FunParam::getOrderNum).orderByDesc(FunParam::getUpdatedAt); + result.setParams(apiParamDao.selectList(query)); + return result; + } + + @Override + public boolean deleteById(String pkey) { + List blocks = queryBlockService.listByPId(pkey); + for (QueryBlock block : blocks){ + queryBlockService.deleteById(block.getId()); + } + QueryWrapper query = this.pidQueryWrapper(pkey); + apiParamDao.delete(query); + return super.deleteById(pkey); + } +} diff --git a/modules/viewer-modules-fun/src/main/resources/META-INF/spring.factories b/modules/viewer-modules-fun/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000000000000000000000000000000000000..8c293fb9bf917d6233783597ce39b5fac01b1dd3 --- /dev/null +++ b/modules/viewer-modules-fun/src/main/resources/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=xyz.thoughtset.viewer.modules.fun \ No newline at end of file diff --git a/modules/viewer-modules-fun/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/modules/viewer-modules-fun/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000000000000000000000000000000000000..68b78aa8ee39fd79c9d469182a27ab25fe901104 --- /dev/null +++ b/modules/viewer-modules-fun/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +xyz.thoughtset.viewer.modules.fun.ModuleFunAutoConfiguration \ No newline at end of file diff --git a/modules/viewer-modules-step/pom.xml b/modules/viewer-modules-step/pom.xml index c4872b0aa32c5f1598234d5e9e60f78b416b4735..359bcf433037431762f0bf8a753d5241d8a36cc4 100644 --- a/modules/viewer-modules-step/pom.xml +++ b/modules/viewer-modules-step/pom.xml @@ -24,6 +24,10 @@ + + + + diff --git a/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/dao/BlockBodyEleDao.java b/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/dao/BlockBodyEleDao.java new file mode 100644 index 0000000000000000000000000000000000000000..9149598a6a441f8f19f1cc45b291f752dd482cb3 --- /dev/null +++ b/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/dao/BlockBodyEleDao.java @@ -0,0 +1,9 @@ +package xyz.thoughtset.viewer.modules.step.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import xyz.thoughtset.viewer.modules.step.entity.block.BlockBodyEle; + +@Mapper +public interface BlockBodyEleDao extends BaseMapper { +} diff --git a/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/dao/BlockInfoDao.java b/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/dao/BlockInfoDao.java new file mode 100644 index 0000000000000000000000000000000000000000..3dbf0e451e5b5de9182d4884042e2d0c345c603a --- /dev/null +++ b/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/dao/BlockInfoDao.java @@ -0,0 +1,9 @@ +package xyz.thoughtset.viewer.modules.step.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import xyz.thoughtset.viewer.modules.step.entity.block.BlockInfo; + +@Mapper +public interface BlockInfoDao extends BaseMapper { +} diff --git a/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/entity/QueryBlock.java b/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/entity/QueryBlock.java index e0318238237c568ebe58d27df5473a16614a061e..39387082db3cfd61615d7613104ffa185ec19b39 100644 --- a/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/entity/QueryBlock.java +++ b/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/entity/QueryBlock.java @@ -20,7 +20,7 @@ import java.util.Objects; public class QueryBlock extends BaseMeta { protected String bodyId; protected String cacheId; -// private String resultMap; +// private String blockType; // private Boolean loop; protected Boolean single; diff --git a/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/entity/block/BlockBodyEle.java b/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/entity/block/BlockBodyEle.java new file mode 100644 index 0000000000000000000000000000000000000000..a4241ad48f9aa5ccc88ac6e66a68d287e02ea303 --- /dev/null +++ b/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/entity/block/BlockBodyEle.java @@ -0,0 +1,43 @@ +package xyz.thoughtset.viewer.modules.step.entity.block; + +import cn.zhxu.bs.bean.DbIgnore; +import com.baomidou.mybatisplus.annotation.OrderBy; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import xyz.thoughtset.viewer.common.core.entity.BaseMeta; +import xyz.thoughtset.viewer.common.core.entity.IdMeta; +import xyz.thoughtset.viewer.common.crud.core.annotation.ApiCRUDPower; + +import java.util.Date; +import java.util.List; +import java.util.Objects; + +@TableName +@Data +@AllArgsConstructor +@NoArgsConstructor +//@ApiCRUDPower(insert = false,save = true,update = false,list = true) +public class BlockBodyEle extends BaseMeta { + protected String paramsPayload; + protected String eleId; + private String type; +// protected Date version; +// private Boolean loop; + protected String valNum; + + @TableField(exist = false) + @DbIgnore + private transient List params; + +// public boolean resultWasSingle() { +// return Objects.nonNull(single) && single.booleanValue(); +// } + + public boolean eleWasFun() { + return "funInfo".equalsIgnoreCase(type); + } + +} diff --git a/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/entity/block/BlockInfo.java b/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/entity/block/BlockInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..d53def4d135faa80b5a3c218516080621f3f76fe --- /dev/null +++ b/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/entity/block/BlockInfo.java @@ -0,0 +1,42 @@ +package xyz.thoughtset.viewer.modules.step.entity.block; + +import cn.zhxu.bs.bean.DbIgnore; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import xyz.thoughtset.viewer.common.core.entity.BaseMeta; +import xyz.thoughtset.viewer.common.crud.core.annotation.ApiCRUDPower; + +import java.util.List; +import java.util.Objects; + +@TableName +@Data +@AllArgsConstructor +@NoArgsConstructor +@ApiCRUDPower(insert = false,save = true,update = false,list = true) +public class BlockInfo extends BaseMeta { + protected String cacheId; + protected String bodyType; + protected Boolean single; + protected String dataStr; +// protected String valStr;//赋值操作 + + @TableField(exist = false) + @DbIgnore + protected List bodys; + + public boolean resultWasSingle() { + return Objects.nonNull(single) && single.booleanValue(); + } + + public BlockBodyEle firstBody() { + if (bodys == null || bodys.isEmpty()) { + return null; + } + return bodys.get(0); + } + +} diff --git a/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/entity/block/EleParam.java b/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/entity/block/EleParam.java new file mode 100644 index 0000000000000000000000000000000000000000..712962860d22de354b101261f5106d51cca4c772 --- /dev/null +++ b/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/entity/block/EleParam.java @@ -0,0 +1,11 @@ +package xyz.thoughtset.viewer.modules.step.entity.block; + +import lombok.Data; + +@Data +public class EleParam { + + private String title; + private String paramId; + private String dataExp; +} diff --git a/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/entity/vo/BodyEleView.java b/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/entity/vo/BodyEleView.java new file mode 100644 index 0000000000000000000000000000000000000000..a3128cfaabf984db07f809717e1401762cff9cd2 --- /dev/null +++ b/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/entity/vo/BodyEleView.java @@ -0,0 +1,33 @@ +package xyz.thoughtset.viewer.modules.step.entity.vo; + +import cn.zhxu.bs.bean.DbIgnore; +import cn.zhxu.bs.bean.InheritType; +import cn.zhxu.bs.bean.SearchBean; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import xyz.thoughtset.viewer.common.core.entity.BaseMeta; +import xyz.thoughtset.viewer.common.crud.core.annotation.ApiCRUDPower; +import xyz.thoughtset.viewer.modules.step.entity.block.BlockBodyEle; +import xyz.thoughtset.viewer.modules.step.entity.block.BlockInfo; + +import java.util.List; +import java.util.Objects; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@SearchBean( + tables = """ + BlockBodyEle ele left join QueryBody body on block.bodyId = body.id + + """, + autoMapTo = "block", + inheritType = InheritType.FIELD +) +public class BodyEleView extends BlockBodyEle{ + private String title; + +} 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 6152161caaaed80f17675e5d0c313e0c51e998e2..31f752b4b57854a1ad04e3f74044da92500f9e2c 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 @@ -26,6 +26,8 @@ public class SimpleBlockExecutor { private ExecutorManager executorManager; + + public Map executeQuery(String apiId,Map params){ Map contentMap = new HashMap(params); List blocks = queryBlockService.listByPId(apiId); @@ -103,6 +105,7 @@ public class SimpleBlockExecutor { } } //todo: cache执行 + //划分if loop mcp fun return executorManager.execute(block.getBodyId(),tmpParamsMap); } diff --git a/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/service/BlockInfoService.java b/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/service/BlockInfoService.java new file mode 100644 index 0000000000000000000000000000000000000000..689385935f530bad34d24e0a7cd06d80ea9ddafb --- /dev/null +++ b/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/service/BlockInfoService.java @@ -0,0 +1,14 @@ +package xyz.thoughtset.viewer.modules.step.service; + + +import xyz.thoughtset.viewer.common.crud.core.service.BaseService; +import xyz.thoughtset.viewer.modules.step.entity.block.BlockInfo; + +import java.util.List; + +public interface BlockInfoService extends BaseService { + Object saveBlockOrder(List items); + List blockEles(String blockId); + BlockInfo loadBlockEles(BlockInfo blockInfo); + +} diff --git a/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/service/BlockInfoServiceImpl.java b/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/service/BlockInfoServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..0b6b3fd4c128782ac23bcb4dcfc034cc3a810fdc --- /dev/null +++ b/modules/viewer-modules-step/src/main/java/xyz/thoughtset/viewer/modules/step/service/BlockInfoServiceImpl.java @@ -0,0 +1,148 @@ +package xyz.thoughtset.viewer.modules.step.service; + +import cn.zhxu.bs.BeanSearcher; +import cn.zhxu.bs.MapSearcher; +import cn.zhxu.bs.util.MapUtils; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.fasterxml.jackson.databind.JavaType; +import jakarta.annotation.PostConstruct; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.ObjectUtils; +import org.springframework.util.StringUtils; +import xyz.thoughtset.viewer.common.crud.core.service.BaseServiceImpl; +import xyz.thoughtset.viewer.modules.step.dao.BlockBodyEleDao; +import xyz.thoughtset.viewer.modules.step.dao.BlockInfoDao; +import xyz.thoughtset.viewer.modules.step.entity.block.BlockBodyEle; +import xyz.thoughtset.viewer.modules.step.entity.block.BlockInfo; +import xyz.thoughtset.viewer.modules.step.entity.block.EleParam; +import xyz.thoughtset.viewer.modules.step.entity.vo.BodyEleView; + +import java.io.Serializable; +import java.util.*; +import java.util.stream.Collectors; + +@Service +@Transactional +public class BlockInfoServiceImpl extends BaseServiceImpl implements BlockInfoService { + + @Autowired + private BlockBodyEleDao blockBodyEleDao; + @Autowired + private BeanSearcher beanSearcher; + private JavaType eleParamType; + + @PostConstruct + public void init() { + eleParamType = mapper.getTypeFactory().constructParametricType(List.class, EleParam.class); + } + + @Override + public BlockInfo saveData(BlockInfo entity) { + if (!StringUtils.hasLength(entity.getDataStr())){ + entity.setDataStr("{}"); + } + saveOrUpdate(entity); + if(ObjectUtils.isEmpty(entity.getBodys())){ + if (entity.getBodyType().equals("transpose")){ + saveOrUpdate(entity); + return entity; + }else { + throw new IllegalArgumentException("Block body elements cannot be empty for block type: " + entity.getBodyType()); + } + } +// BlockInfo entity = (BlockInfo) super.saveData(baseMap); + List oldEles = blockEles(entity.getId()); + HashSet oldEleIds = new HashSet<>(); + int i = 0; + for (BlockBodyEle ele : entity.getBodys()) { + ele.setPid(entity.getId()); + ele.setOrderNum(++i); + blockBodyEleDao.insertOrUpdate(ele); + oldEleIds.add(ele.getId()); + } + if (!ObjectUtils.isEmpty(oldEles)){ + List delIds = oldEles.stream() + .filter(e->!oldEleIds.contains(e.getId())) + .map(BlockBodyEle::getId) + .collect(Collectors.toList()); + blockBodyEleDao.deleteByIds(delIds); + } + return entity; + } + + @Override + public boolean deleteById(String pkey) { + blockBodyEleDao.delete(this.pidQueryWrapper(pkey)); + return super.deleteById(pkey); + } + + @Override + public BlockInfo getById(Serializable id) { + BlockInfo result = super.getById(id); + Map params = MapUtils.builder() + .field(BlockBodyEle::getPid, id) + .orderBy(BlockBodyEle::getOrderNum).asc() + .build(); +// List bodyEles = beanSearcher.searchList(BodyEleView.class,params); + + QueryWrapper query = new QueryWrapper(); + query.lambda().eq(BlockBodyEle::getPid,id) + .orderByAsc(BlockBodyEle::getOrderNum); + List bodyEles = blockBodyEleDao.selectList(query); + result.setBodys(bodyEles); + return result; + } + + @Override + public Object saveBlockOrder(List items) { + Integer sortNum = 0; + List blocks = new ArrayList<>(items.size()); + for (String item : items){ + blocks.add(BlockInfo.buildByOrder(item,++sortNum,BlockInfo.class)); + } + return this.updateBatchById(blocks,5); + } + + @Override + public List blockEles(String blockId) { + QueryWrapper query = new QueryWrapper(); + query.lambda().eq(BlockBodyEle::getPid,blockId) + .orderByAsc(BlockBodyEle::getOrderNum) + .orderByDesc(BlockBodyEle::getUpdatedAt); + return blockBodyEleDao.selectList(query); + } + + @Override + public BlockInfo loadBlockEles(BlockInfo blockInfo) { + blockInfo.setBodys(blockEles(blockInfo.getId())); + for (BlockBodyEle ele : blockInfo.getBodys()){ + try { + ele.setParams(mapper.readValue(ele.getParamsPayload(), eleParamType)); + } + catch (Exception e) { + e.printStackTrace(); +// ele.setParams(List.of(ele.getParamsPayload())); + } + } + return blockInfo; + } +// +// @Override +// public List selectList(LinkedHashMap baseMap) { +// Map paramMap = cn.zhxu.bs.util.MapUtils.builder(baseMap) +// .orderBy(BlockInfoVo::getOrderNum).asc() +// .orderBy(BlockInfoVo::getUpdatedAt).desc().build(); +// return mapSearcher.searchList(BlockInfoVo.class,paramMap); +// } +// + @Override + public List listByPId(String pid) { + QueryWrapper query = new QueryWrapper(); + query.lambda().eq(BlockInfo::getPid,pid) + .orderByAsc(BlockInfo::getOrderNum) + .orderByDesc(BlockInfo::getUpdatedAt); + return list(query); + } +} diff --git a/pom.xml b/pom.xml index 79986e288666b64eb77f2fc1a2d88eff4eac190c..d259e969a7c2f82bd4598aecd5e209b0444583a3 100644 --- a/pom.xml +++ b/pom.xml @@ -189,6 +189,11 @@ viewer-executor-core ${revision} + + xyz.thoughtset.viewer + viewer-executor-blocks + ${revision} + xyz.thoughtset.viewer viewer-modules-ds-core @@ -199,6 +204,11 @@ viewer-modules-step ${revision} + + xyz.thoughtset.viewer + viewer-modules-fun + ${revision} + xyz.thoughtset.viewer viewer-modules-api @@ -206,7 +216,12 @@ xyz.thoughtset.viewer - viewer-modules-excel + viewer-modules-export + ${revision} + + + xyz.thoughtset.viewer + viewer-modules-datarel ${revision} diff --git a/sql/mysql/dv.sql b/sql/mysql/dv.sql new file mode 100644 index 0000000000000000000000000000000000000000..b937a49e705c2beaff62e16705ad951beb2acf98 --- /dev/null +++ b/sql/mysql/dv.sql @@ -0,0 +1,320 @@ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for apiinfo +-- ---------------------------- +DROP TABLE IF EXISTS `apiinfo`; +CREATE TABLE `apiinfo` ( + `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `title` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `pid` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `groupId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + `orderNum` int(11) NULL DEFAULT NULL, + `createdAt` datetime(0) NOT NULL, + `updatedAt` datetime(0) NOT NULL, + `statesCode` int(11) NULL DEFAULT 200, + `queryType` int(11) NULL DEFAULT NULL, + `url` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `cacheTime` int(11) UNSIGNED ZEROFILL NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for apiparam +-- ---------------------------- +DROP TABLE IF EXISTS `apiparam`; +CREATE TABLE `apiparam` ( + `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `title` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `pid` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `groupId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + `orderNum` int(11) NULL DEFAULT 0, + `createdAt` datetime(0) NOT NULL, + `updatedAt` datetime(0) NOT NULL, + `statesCode` int(11) NULL DEFAULT 200, + `dataType` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `defaultVal` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `dataExp` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + `paramType` int(11) NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for blockbodyele +-- ---------------------------- +DROP TABLE IF EXISTS `blockbodyele`; +CREATE TABLE `blockbodyele` ( + `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `title` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `pid` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `groupId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + `orderNum` int(11) NULL DEFAULT 0, + `createdAt` datetime(0) NOT NULL, + `updatedAt` datetime(0) NOT NULL, + `statesCode` int(11) NULL DEFAULT 200, + `paramsPayload` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + `type` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `eleId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `valnum` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for blockinfo +-- ---------------------------- +DROP TABLE IF EXISTS `blockinfo`; +CREATE TABLE `blockinfo` ( + `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `title` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `pid` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `groupId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + `orderNum` int(11) NULL DEFAULT 0, + `createdAt` datetime(0) NOT NULL, + `updatedAt` datetime(0) NOT NULL, + `statesCode` int(11) NULL DEFAULT 200, + `dataStr` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + `single` bit(1) NULL DEFAULT NULL, + `cacheId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `bodyType` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for blockparam +-- ---------------------------- +DROP TABLE IF EXISTS `blockparam`; +CREATE TABLE `blockparam` ( + `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `pid` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `groupId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `createdAt` datetime(0) NOT NULL, + `updatedAt` datetime(0) NOT NULL, + `qpId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `dataExp` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for dsconfig +-- ---------------------------- +DROP TABLE IF EXISTS `dsconfig`; +CREATE TABLE `dsconfig` ( + `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `title` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `pid` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `groupId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + `orderNum` int(11) NULL DEFAULT 0, + `createdAt` datetime(0) NOT NULL, + `updatedAt` datetime(0) NOT NULL, + `statesCode` int(11) NULL DEFAULT 200, + `linkerType` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `url` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `ak` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `sk` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `otherSettings` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + `testQuery` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for envvars +-- ---------------------------- +DROP TABLE IF EXISTS `envvars`; +CREATE TABLE `envvars` ( + `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `title` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `pid` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `groupId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + `orderNum` int(11) NULL DEFAULT 0, + `createdAt` datetime(0) NOT NULL, + `updatedAt` datetime(0) NOT NULL, + `statesCode` int(11) NULL DEFAULT 200, + `type` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `topic` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + `payload` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for excinfo +-- ---------------------------- +DROP TABLE IF EXISTS `excinfo`; +CREATE TABLE `excinfo` ( + `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `pid` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `groupId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `createdAt` datetime(0) NOT NULL, + `updatedAt` datetime(0) NOT NULL, + `statesCode` int(11) NULL DEFAULT 200, + `apiId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `blockId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `funId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `errMsg` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + `paramStr` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + `errType` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for exportdatainfo +-- ---------------------------- +DROP TABLE IF EXISTS `exportdatainfo`; +CREATE TABLE `exportdatainfo` ( + `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `title` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `pid` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `groupId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + `orderNum` int(11) NULL DEFAULT NULL, + `createdAt` datetime(0) NOT NULL, + `updatedAt` datetime(0) NOT NULL, + `statesCode` int(11) NULL DEFAULT 200, + `bodyId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `templateId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `fileName` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for funinfo +-- ---------------------------- +DROP TABLE IF EXISTS `funinfo`; +CREATE TABLE `funinfo` ( + `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `title` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `pid` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `groupId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + `orderNum` int(11) NULL DEFAULT NULL, + `createdAt` datetime(0) NOT NULL, + `updatedAt` datetime(0) NOT NULL, + `statesCode` int(11) NULL DEFAULT 200, + `cacheTime` int(11) UNSIGNED ZEROFILL NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for funparam +-- ---------------------------- +DROP TABLE IF EXISTS `funparam`; +CREATE TABLE `funparam` ( + `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `title` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `pid` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `groupId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + `orderNum` int(11) NULL DEFAULT 0, + `createdAt` datetime(0) NOT NULL, + `updatedAt` datetime(0) NOT NULL, + `statesCode` int(11) NULL DEFAULT 200, + `dataType` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `defaultVal` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `paramType` int(11) NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for linkerconfig +-- ---------------------------- +DROP TABLE IF EXISTS `linkerconfig`; +CREATE TABLE `linkerconfig` ( + `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `title` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `pid` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `groupId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + `orderNum` int(11) NULL DEFAULT 0, + `createdAt` datetime(0) NOT NULL, + `updatedAt` datetime(0) NOT NULL, + `statesCode` int(11) NULL DEFAULT 200, + `driverClassName` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `jarFilePath` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `linkerType` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `otherSettings` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + `reactive` bit(1) NULL DEFAULT b'0', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for loginfo +-- ---------------------------- +DROP TABLE IF EXISTS `loginfo`; +CREATE TABLE `loginfo` ( + `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `pid` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `groupId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `createdAt` datetime(0) NOT NULL, + `updatedAt` datetime(0) NOT NULL, + `type` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `active` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `data` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for queryblock +-- ---------------------------- +DROP TABLE IF EXISTS `queryblock`; +CREATE TABLE `queryblock` ( + `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `title` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `pid` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `groupId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + `orderNum` int(11) NULL DEFAULT 0, + `createdAt` datetime(0) NOT NULL, + `updatedAt` datetime(0) NOT NULL, + `statesCode` int(11) NULL DEFAULT 200, + `bodyId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `single` bit(1) NULL DEFAULT NULL, + `cacheId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for querybody +-- ---------------------------- +DROP TABLE IF EXISTS `querybody`; +CREATE TABLE `querybody` ( + `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `title` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `pid` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `groupId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + `orderNum` int(11) NULL DEFAULT NULL, + `createdAt` datetime(0) NOT NULL, + `updatedAt` datetime(0) NOT NULL, + `statesCode` int(11) NULL DEFAULT 200, + `dsId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `query` text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for queryparam +-- ---------------------------- +DROP TABLE IF EXISTS `queryparam`; +CREATE TABLE `queryparam` ( + `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `title` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `pid` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `groupId` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, + `orderNum` int(11) NULL DEFAULT 0, + `createdAt` datetime(0) NOT NULL, + `updatedAt` datetime(0) NOT NULL, + `statesCode` int(11) NULL DEFAULT 200, + `dataType` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `defaultVal` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +SET FOREIGN_KEY_CHECKS = 1;