From 70be66fd6678f0431e5c4e5ceeb0a756868df4e2 Mon Sep 17 00:00:00 2001 From: zegezy <1098696801@qq.com> Date: Sun, 3 Mar 2024 20:47:53 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=84=E4=BB=B6tree?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/magic-api/api/系统管理/组件/保存tree.ms | 28 +++++++++++++++++ data/magic-api/api/系统管理/组件/获取源码.ms | 27 ++++++++++++++++ .../api/系统管理/组件/获取组件tree.ms | 31 +++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 data/magic-api/api/系统管理/组件/保存tree.ms create mode 100644 data/magic-api/api/系统管理/组件/获取源码.ms create mode 100644 data/magic-api/api/系统管理/组件/获取组件tree.ms diff --git a/data/magic-api/api/系统管理/组件/保存tree.ms b/data/magic-api/api/系统管理/组件/保存tree.ms new file mode 100644 index 0000000..75079e3 --- /dev/null +++ b/data/magic-api/api/系统管理/组件/保存tree.ms @@ -0,0 +1,28 @@ +{ + "properties" : { }, + "id" : "c01db2a3b18246c89ef1a6ad6b39342c", + "script" : null, + "groupId" : "6f106ebdee21489db34b956f7770ff03", + "name" : "保存tree", + "createTime" : null, + "updateTime" : 1709468623502, + "lock" : null, + "createBy" : null, + "updateBy" : null, + "path" : "/save/tree", + "method" : "POST", + "parameters" : [ ], + "options" : [ ], + "requestBody" : "", + "headers" : [ ], + "paths" : [ ], + "responseBody" : null, + "description" : null, + "requestBodyDefinition" : null, + "responseBodyDefinition" : null +} +================================ +return db.table("sys_dynamic_component").primary("id").saveOrUpdate({ + pid, + name +}) \ No newline at end of file diff --git a/data/magic-api/api/系统管理/组件/获取源码.ms b/data/magic-api/api/系统管理/组件/获取源码.ms new file mode 100644 index 0000000..17ca856 --- /dev/null +++ b/data/magic-api/api/系统管理/组件/获取源码.ms @@ -0,0 +1,27 @@ +{ + "properties" : { }, + "id" : "2e3a230acf004dcdb679ff3a46a8a20a", + "script" : null, + "groupId" : "6f106ebdee21489db34b956f7770ff03", + "name" : "获取源码", + "createTime" : 1709459380012, + "updateTime" : null, + "lock" : null, + "createBy" : null, + "updateBy" : null, + "path" : "/getSourceCode", + "method" : "GET", + "parameters" : [ ], + "options" : [ ], + "requestBody" : "", + "headers" : [ ], + "paths" : [ ], + "responseBody" : null, + "description" : null, + "requestBodyDefinition" : null, + "responseBodyDefinition" : null +} +================================ +return db.selectValue(""" + select source_code from sys_dynamic_component where is_del=0 and name = #{name} +""") \ No newline at end of file diff --git a/data/magic-api/api/系统管理/组件/获取组件tree.ms b/data/magic-api/api/系统管理/组件/获取组件tree.ms new file mode 100644 index 0000000..8792014 --- /dev/null +++ b/data/magic-api/api/系统管理/组件/获取组件tree.ms @@ -0,0 +1,31 @@ +{ + "properties" : { }, + "id" : "8ba14d61082e4ba69324fdc9de080f38", + "script" : null, + "groupId" : "6f106ebdee21489db34b956f7770ff03", + "name" : "获取组件tree", + "createTime" : null, + "updateTime" : 1709459290517, + "lock" : null, + "createBy" : null, + "updateBy" : null, + "path" : "/tree", + "method" : "GET", + "parameters" : [ ], + "options" : [ ], + "requestBody" : "", + "headers" : [ ], + "paths" : [ ], + "responseBody" : null, + "description" : null, + "requestBodyDefinition" : null, + "responseBodyDefinition" : null +} +================================ +var toTree = (list,pid) => select t.*,toTree(list,t.id) children from list t where t.pid = pid +var list = toTree(db.select('select id,name,pid from sys_dynamic_component where is_del = 0 order by name'),'0') + +return { + list: list, + total: list.getLength() +} \ No newline at end of file