magic-boot/data/magic-api/api/系统管理/组件/选择组件.ms

131 lines
3.5 KiB
Plaintext
Raw Normal View History

2022-03-05 10:28:20 +08:00
{
"properties" : { },
"id" : "eb2b08bc7fe74036867e8dc5f2c0e8f8",
"script" : null,
"groupId" : "6f106ebdee21489db34b956f7770ff03",
"name" : "选择组件",
2022-03-23 20:57:43 +08:00
"createTime" : null,
"updateTime" : 1655521303906,
2022-03-05 10:28:20 +08:00
"lock" : "0",
"createBy" : null,
"updateBy" : null,
2022-03-05 10:28:20 +08:00
"path" : "/select",
"method" : "GET",
2022-03-05 10:28:20 +08:00
"parameters" : [ ],
"options" : [ ],
2022-03-05 10:28:20 +08:00
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : "{\n \"code\": 500,\n \"message\": \"系统内部出现错误\",\n \"data\": null,\n \"timestamp\": 1655521300755,\n \"executeTime\": 17\n}",
2022-03-05 10:28:20 +08:00
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : {
"name" : "",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "code",
"value" : "500",
2022-03-05 10:28:20 +08:00
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "message",
"value" : "系统内部出现错误",
2022-03-05 10:28:20 +08:00
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "data",
"value" : "null",
2022-03-05 10:28:20 +08:00
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
2022-03-05 10:28:20 +08:00
}, {
"name" : "timestamp",
"value" : "1655521300755",
2022-03-05 10:28:20 +08:00
"description" : "",
"required" : false,
"dataType" : "Long",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "executeTime",
"value" : "17",
2022-03-05 10:28:20 +08:00
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
} ]
}
2022-03-05 10:28:20 +08:00
}
================================
2022-03-23 20:57:43 +08:00
import org.ssssssss.magicapi.utils.PathUtils
import org.ssssssss.magicapi.core.service.MagicResourceService
var getFiles = (groupId) => {
return MagicResourceService.listFiles(groupId).map(file => {
2022-05-07 13:51:54 +08:00
value: PathUtils.replaceSlash(String.format("%s/%s", MagicResourceService.getGroupPath(file.groupId), file.path)).replace(/^\//,'').replace(/\/\//, '/').replace('/', '-'),
2022-03-23 20:57:43 +08:00
label: `${file.name}(${file.path})`
})
}
var toTree = (children) => {
var treeData = []
children.forEach(it => {
var chi = {}
2022-05-07 13:51:54 +08:00
chi.value = it.node.id
2022-03-23 20:57:43 +08:00
chi.label = `${it.node.name}(${it.node.path})`
if(it.children.length > 0){
chi.children = toTree(it.children)
var files = getFiles(it.node.id)
if(files.length > 0){
chi.children.addAll(files)
2022-03-23 20:57:43 +08:00
}
}else{
var files = getFiles(it.node.id)
if(files.length > 0){
chi.children = files
}
}
if(chi instanceof List){
treeData.addAll(chi)
}else{
treeData.add(chi)
}
2022-03-23 20:57:43 +08:00
})
return treeData
}
return toTree(MagicResourceService.tree('component').children)