xinli/Archive/添加知识库菜单-简化版.sql
2026-01-30 16:23:31 +08:00

40 lines
1.9 KiB
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- =============================================
-- 知识库管理菜单 - 简化版(一键执行)
-- =============================================
-- 说明:此脚本假设"心理测评管理"的menu_id为2000
-- 如果不是请先查询SELECT menu_id FROM sys_menu WHERE menu_name LIKE '%心理%';
-- =============================================
-- 添加知识库管理主菜单
INSERT INTO sys_menu (
menu_name, parent_id, order_num, path, component,
is_frame, is_cache, menu_type, visible, status,
perms, icon, create_by, create_time, remark
) VALUES (
'知识库管理', 2000, 8, 'knowledge', 'psychology/knowledge/index',
1, 0, 'C', '0', '0',
'psychology:knowledge:list', 'documentation', 'admin', NOW(), 'AI知识库文档管理'
);
-- 获取刚插入的菜单ID
SET @menu_id = LAST_INSERT_ID();
-- 添加按钮权限
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
VALUES
('知识库查询', @menu_id, 1, '#', '', 1, 0, 'F', '0', '0', 'psychology:knowledge:query', '#', 'admin', NOW()),
('知识库上传', @menu_id, 2, '#', '', 1, 0, 'F', '0', '0', 'psychology:knowledge:upload', '#', 'admin', NOW()),
('知识库删除', @menu_id, 3, '#', '', 1, 0, 'F', '0', '0', 'psychology:knowledge:remove', '#', 'admin', NOW()),
('知识库重建', @menu_id, 4, '#', '', 1, 0, 'F', '0', '0', 'psychology:knowledge:rebuild', '#', 'admin', NOW());
-- 为管理员角色分配权限角色ID=1
INSERT INTO sys_role_menu (role_id, menu_id)
SELECT 1, menu_id FROM sys_menu
WHERE menu_name IN ('知识库管理', '知识库查询', '知识库上传', '知识库删除', '知识库重建')
AND NOT EXISTS (
SELECT 1 FROM sys_role_menu WHERE role_id = 1 AND sys_role_menu.menu_id = sys_menu.menu_id
);
-- 完成!刷新页面查看
SELECT '菜单添加完成!请刷新浏览器页面' AS message;