magic-boot/data/magic-api/api/系统管理/菜单管理/当前用户菜单.ms

613 lines
28 KiB
Plaintext
Raw Normal View History

2021-10-24 20:09:53 +08:00
{
"properties" : { },
"id" : "f608811b430f4a3cb82feed4067cde71",
"script" : null,
"groupId" : "67b2ce258e24491194b74992958c74aa",
"name" : "当前用户菜单",
2022-03-23 20:57:43 +08:00
"createTime" : null,
"updateTime" : 1656340766427,
2021-10-24 20:09:53 +08:00
"lock" : "0",
"createBy" : null,
"updateBy" : null,
2021-10-24 20:09:53 +08:00
"path" : "/current/menus",
"method" : "POST",
2021-10-24 20:09:53 +08:00
"parameters" : [ ],
"options" : [ ],
2022-01-04 14:56:52 +08:00
"requestBody" : "{\n\n}",
2021-10-24 20:09:53 +08:00
"headers" : [ ],
"paths" : [ ],
2022-03-05 10:31:35 +08:00
"responseBody" : "{\n \"code\": 200,\n \"message\": \"success\",\n \"data\": [{\n \"id\": \"b1851d1b13594e71840103c11a37a669\",\n \"name\": \"系统设置\",\n \"pid\": \"0\",\n \"isShow\": 1,\n \"url\": \"/system\",\n \"sort\": 10,\n \"icon\": \"settings\",\n \"keepAlive\": 0,\n \"code\": null,\n \"componentname\": null,\n \"component\": \"Layout\",\n \"path\": \"/system\",\n \"meta\": {\n \"title\": \"系统设置\",\n \"icon\": \"settings\",\n \"keepAlive\": false\n },\n \"redirect\": \"noRedirect\",\n \"alwaysShow\": true,\n \"children\": [{\n \"id\": \"39be13ef6f0745568c80bf35202ddb2b\",\n \"name\": \"菜单管理\",\n \"pid\": \"b1851d1b13594e71840103c11a37a669\",\n \"isShow\": 1,\n \"url\": \"/system/menu/menu-list\",\n \"sort\": 10,\n \"icon\": \"menu\",\n \"keepAlive\": 1,\n \"code\": null,\n \"componentname\": null,\n \"component\": \"/system/menu/menu-list\",\n \"path\": \"/system/menu/menu-list\",\n \"meta\": {\n \"title\": \"菜单管理\",\n \"icon\": \"menu\",\n \"keepAlive\": true\n }\n }, {\n \"id\": \"6f3594d0-5445-41e1-a13c-890a57485036\",\n \"name\": \"组织机构\",\n \"pid\": \"b1851d1b13594e71840103c11a37a669\",\n \"isShow\": 1,\n \"url\": \"/system/office/office-list\",\n \"sort\": 20,\n \"icon\": \"office\",\n \"keepAlive\": 0,\n \"code\": null,\n \"componentname\": null,\n \"component\": \"/system/office/office-list\",\n \"path\": \"/system/office/office-list\",\n \"meta\": {\n \"title\": \"组织机构\",\n \"icon\": \"office\",\n \"keepAlive\": false\n }\n }, {\n \"id\": \"8e9455740091486c914495cfb0c7faa5\",\n \"name\": \"角色管理\",\n \"pid\": \"b1851d1b13594e71840103c11a37a669\",\n \"isShow\": 1,\n \"url\": \"/system/role/role-list\",\n \"sort\": 40,\n \"icon\": \"role\",\n \"keepAlive\": 0,\n \"code\": null,\n \"componentname\": null,\n \"component\": \"/system/role/role-list\",\n \"path\": \"/system/role/role-list\",\n \"meta\": {\n \"title\": \"角色管理\",\n \"icon\": \"role\",\n \"keepAlive\": false\n }\n }, {\n \"id\": \"06b8a427e4cd4c1ba11752070f565f20\",\n \"name\": \"用户管理\",\n \"pid\": \"b1851d1b13594e71840103c11a37a669\",\n \"isShow\": 1,\n \"url\": \"/system/user/user-list\",\n \"sort\": 50,\n \"icon\": \"user\",\n \"keepAlive\": 0,\n \"code\": null,\n \"componentname\": null,\n \"component\": \"/system/user/user-list\",\n \"path\": \"/system/user/user-list\",\n \"meta\": {\n \"title\": \"用户管理\",\n \"icon\": \"user\",\n \"keepAlive\": false\n }\n }, {\n \"id\": \"c5f407478c4e4c9cbcdbee6389d2c909\",\n \"name\": \"数据字典\",\n \"pid\": \"b1851d1b13594e71840103c11a37a669\",\n \"isShow\": 1,\n \"url\": \"/system/dict/dict-list\",\n \"sort\": 60,\n \"icon\": \"dict\",\n \"keepAlive\": 0,\n \"code\": null,\n \"componentname\": null,\n \"component\": \"/system/dict/dict-list\",\n \"path\": \"/system/dict/dict-list\",\n \"meta\": {\n \"title\": \"数据字典\",\n \"icon\": \"dict\",\n \"keepAlive\": false\
2021-10-24 20:09:53 +08:00
"description" : null,
2022-03-23 20:57:43 +08:00
"requestBodyDefinition" : {
"name" : "",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
},
2021-10-24 20:09:53 +08:00
"responseBodyDefinition" : {
"name" : "",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "code",
2022-01-04 14:56:52 +08:00
"value" : "200",
2021-10-24 20:09:53 +08:00
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "message",
2022-01-04 14:56:52 +08:00
"value" : "success",
2021-10-24 20:09:53 +08:00
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "data",
2022-01-04 14:56:52 +08:00
"value" : "",
2021-10-24 20:09:53 +08:00
"description" : "",
"required" : false,
2022-01-04 14:56:52 +08:00
"dataType" : "Array",
2021-10-24 20:09:53 +08:00
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
2022-01-04 14:56:52 +08:00
"children" : [ {
"name" : "",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "id",
"value" : "b1851d1b13594e71840103c11a37a669",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "name",
"value" : "系统设置",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "pid",
"value" : "0",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "isShow",
"value" : "1",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "url",
"value" : "/system",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "sort",
"value" : "10",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "icon",
"value" : "settings",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
2022-03-05 10:31:35 +08:00
}, {
"name" : "keepAlive",
"value" : "0",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "code",
"value" : "null",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "componentname",
"value" : "null",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
2022-01-04 14:56:52 +08:00
}, {
"name" : "component",
"value" : "Layout",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "path",
"value" : "/system",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "meta",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "title",
"value" : "系统设置",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "icon",
"value" : "settings",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
2022-03-05 10:31:35 +08:00
}, {
"name" : "keepAlive",
"value" : "false",
"description" : "",
"required" : false,
"dataType" : "Boolean",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
2022-01-04 14:56:52 +08:00
} ]
}, {
"name" : "redirect",
"value" : "noRedirect",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "alwaysShow",
"value" : "true",
"description" : "",
"required" : false,
"dataType" : "Boolean",
"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" : "39be13ef6f0745568c80bf35202ddb2b",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "name",
"value" : "菜单管理",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "pid",
"value" : "b1851d1b13594e71840103c11a37a669",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "isShow",
"value" : "1",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "url",
"value" : "/system/menu/menu-list",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "sort",
"value" : "10",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "icon",
"value" : "menu",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
2022-03-05 10:31:35 +08:00
}, {
"name" : "keepAlive",
"value" : "1",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "code",
"value" : "null",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "componentname",
"value" : "null",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
2022-01-04 14:56:52 +08:00
}, {
"name" : "component",
"value" : "/system/menu/menu-list",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "path",
"value" : "/system/menu/menu-list",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "meta",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "title",
"value" : "菜单管理",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "icon",
"value" : "menu",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
2022-03-05 10:31:35 +08:00
}, {
"name" : "keepAlive",
"value" : "true",
"description" : "",
"required" : false,
"dataType" : "Boolean",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
2022-01-04 14:56:52 +08:00
} ]
} ]
} ]
} ]
} ]
2021-10-24 20:09:53 +08:00
}, {
"name" : "timestamp",
2022-03-05 10:31:35 +08:00
"value" : "1646400974566",
2021-10-24 20:09:53 +08:00
"description" : "",
"required" : false,
"dataType" : "Long",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "executeTime",
2022-03-05 10:31:35 +08:00
"value" : "41",
2021-10-24 20:09:53 +08:00
"description" : "",
"required" : false,
2022-01-01 14:28:03 +08:00
"dataType" : "Object",
2021-10-24 20:09:53 +08:00
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
} ]
}
2021-10-24 20:09:53 +08:00
}
================================
import 'cn.dev33.satoken.stp.StpUtil';
var userId = StpUtil.getLoginId()
2022-01-04 14:56:52 +08:00
2021-10-24 20:09:53 +08:00
var menus = db.select("""
2022-01-04 14:56:52 +08:00
select
2021-10-24 20:09:53 +08:00
sm.id,
sm.name title,
2021-10-24 20:09:53 +08:00
sm.pid,
sm.is_show,
sm.url,
2022-01-01 14:28:03 +08:00
sm.sort,
2022-01-07 01:08:42 +08:00
sm.icon,
2022-03-05 10:31:35 +08:00
sm.keep_alive,
2022-03-23 20:57:43 +08:00
sm.component_name
from sys_menu sm where 1=1
2022-01-04 14:56:52 +08:00
?{userId != '1',
and sm.id in (
select menu_id from sys_role_menu where role_id in (
select role_id from sys_user_role where user_id = #{userId}
)
)
} and sm.is_del = '0' and sm.is_show = 1 order by sm.sort
2021-10-24 20:09:53 +08:00
""")
for(menu in menus){
menu.component = (menu.url || "Layout");
menu.path = (menu.component == 'Layout' ? "/" : menu.component);
menu.meta = {}
menu.meta.title = menu.title
2022-01-01 14:28:03 +08:00
menu.meta.icon = menu.icon
2022-01-07 01:08:42 +08:00
menu.meta.keepAlive = (menu.keepAlive == '1' ? true : false)
2021-10-24 20:09:53 +08:00
}
var nodes = menus.toMap(it => it.id)
nodes.each((key, node) => {
if (nodes.containsKey(node.pid)) {
nodes[node.pid].redirect = "noRedirect";
nodes[node.pid].component = "Layout";
nodes[node.pid].alwaysShow = true;
if(!nodes[node.pid].children){
nodes[node.pid].children = []
}
nodes[node.pid].children.push(node)
}
})
var treeNodes = []
nodes.each((key, node) => {
if(node.pid == '0'){
if(node.component != 'Layout'){
node = {
isShow: 1,
component: 'Layout',
redirect: node.path,
children: [node]
}
}
2021-10-24 20:09:53 +08:00
treeNodes.push(node)
}
})
return treeNodes