{
  "properties" : { },
  "id" : "eb2b08bc7fe74036867e8dc5f2c0e8f8",
  "script" : null,
  "groupId" : "6f106ebdee21489db34b956f7770ff03",
  "name" : "选择组件",
  "createTime" : null,
  "updateTime" : 1648647253717,
  "lock" : "0",
  "createBy" : null,
  "updateBy" : null,
  "path" : "/select",
  "method" : "GET",
  "parameters" : [ ],
  "options" : [ ],
  "requestBody" : "",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"code\": 200,\n    \"message\": \"success\",\n    \"data\": [{\n        \"id\": \"9bf92d503f4242d39a0f271c577aa3ac\",\n        \"label\": \"系统管理\",\n        \"children\": [{\n            \"id\": \"6bee7576eea04963a573b21bb657784d\",\n            \"label\": \"字典管理\",\n            \"children\": [{\n                \"id\": \"sys-dict-list\",\n                \"label\": \"列表(sys-dict-list)\"\n            }]\n        }]\n    }],\n    \"timestamp\": 1648025200208,\n    \"executeTime\": 14\n}",
  "description" : null,
  "requestBodyDefinition" : null,
  "responseBodyDefinition" : {
    "name" : "",
    "value" : "",
    "description" : "",
    "required" : false,
    "dataType" : "Object",
    "type" : null,
    "defaultValue" : null,
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ {
      "name" : "code",
      "value" : "200",
      "description" : "",
      "required" : false,
      "dataType" : "Integer",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "message",
      "value" : "success",
      "description" : "",
      "required" : false,
      "dataType" : "String",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "data",
      "value" : "",
      "description" : "",
      "required" : false,
      "dataType" : "Object",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ {
        "name" : "",
        "value" : "",
        "description" : "",
        "required" : false,
        "dataType" : "Object",
        "type" : null,
        "defaultValue" : null,
        "validateType" : "",
        "error" : "",
        "expression" : "",
        "children" : [ {
          "name" : "id",
          "value" : "9bf92d503f4242d39a0f271c577aa3ac",
          "description" : "",
          "required" : false,
          "dataType" : "String",
          "type" : null,
          "defaultValue" : null,
          "validateType" : "",
          "error" : "",
          "expression" : "",
          "children" : [ ]
        }, {
          "name" : "label",
          "value" : "系统管理",
          "description" : "",
          "required" : false,
          "dataType" : "String",
          "type" : null,
          "defaultValue" : null,
          "validateType" : "",
          "error" : "",
          "expression" : "",
          "children" : [ ]
        }, {
          "name" : "children",
          "value" : "",
          "description" : "",
          "required" : false,
          "dataType" : "Array",
          "type" : null,
          "defaultValue" : null,
          "validateType" : "",
          "error" : "",
          "expression" : "",
          "children" : [ {
            "name" : "",
            "value" : "",
            "description" : "",
            "required" : false,
            "dataType" : "Object",
            "type" : null,
            "defaultValue" : null,
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ {
              "name" : "id",
              "value" : "6bee7576eea04963a573b21bb657784d",
              "description" : "",
              "required" : false,
              "dataType" : "String",
              "type" : null,
              "defaultValue" : null,
              "validateType" : "",
              "error" : "",
              "expression" : "",
              "children" : [ ]
            }, {
              "name" : "label",
              "value" : "字典管理",
              "description" : "",
              "required" : false,
              "dataType" : "String",
              "type" : null,
              "defaultValue" : null,
              "validateType" : "",
              "error" : "",
              "expression" : "",
              "children" : [ ]
            }, {
              "name" : "children",
              "value" : "",
              "description" : "",
              "required" : false,
              "dataType" : "Array",
              "type" : null,
              "defaultValue" : null,
              "validateType" : "",
              "error" : "",
              "expression" : "",
              "children" : [ {
                "name" : "",
                "value" : "",
                "description" : "",
                "required" : false,
                "dataType" : "Object",
                "type" : null,
                "defaultValue" : null,
                "validateType" : "",
                "error" : "",
                "expression" : "",
                "children" : [ {
                  "name" : "id",
                  "value" : "sys-dict-list",
                  "description" : "",
                  "required" : false,
                  "dataType" : "String",
                  "type" : null,
                  "defaultValue" : null,
                  "validateType" : "",
                  "error" : "",
                  "expression" : "",
                  "children" : [ ]
                }, {
                  "name" : "label",
                  "value" : "列表(sys-dict-list)",
                  "description" : "",
                  "required" : false,
                  "dataType" : "String",
                  "type" : null,
                  "defaultValue" : null,
                  "validateType" : "",
                  "error" : "",
                  "expression" : "",
                  "children" : [ ]
                } ]
              } ]
            } ]
          } ]
        } ]
      } ]
    }, {
      "name" : "timestamp",
      "value" : "1648025200208",
      "description" : "",
      "required" : false,
      "dataType" : "Long",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "executeTime",
      "value" : "14",
      "description" : "",
      "required" : false,
      "dataType" : "Integer",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    } ]
  }
}
================================
import org.ssssssss.magicapi.utils.PathUtils
import org.ssssssss.magicapi.core.service.MagicResourceService
var getFiles = (groupId) => {
    return MagicResourceService.listFiles(groupId).map(file => { 
        id: PathUtils.replaceSlash(String.format("%s/%s", MagicResourceService.getGroupPath(file.groupId), file.path)).replace(/^\//,'').replace(/\/\//, '/').replace('/', '-'),
        label: `${file.name}(${file.path})`
    })
}
var toTree = (children) => {
    var treeData = []
    children.forEach(it => {
        var chi = {}
        chi.id = it.node.id
        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.push(...files)
            }
        }else{
            var files = getFiles(it.node.id)
            if(files.length > 0){
                chi.children = files
            }
        }
        treeData.push(chi)
    }) 
    return treeData
}
return toTree(MagicResourceService.tree('component').children)