xinli/sql/给老师角色添加档案导入导出权限.sql
2025-12-02 15:12:55 +08:00

39 lines
2.2 KiB
SQL
Raw 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.

-- 给老师角色添加用户档案的导入和导出权限
-- ============================================
-- 步骤1: 先查询用户档案菜单的ID作为父菜单
SELECT menu_id, menu_name, perms FROM sys_menu WHERE menu_name = '用户档案' OR perms LIKE 'psychology:profile%';
-- 步骤2: 查询老师角色的ID
SELECT role_id, role_name, role_key FROM sys_role;
-- ============================================
-- 步骤3: 添加导入和导出按钮权限需要先执行步骤1获取parent_id
-- 假设用户档案菜单的 menu_id 是 XXX请替换下面的 XXX
-- ============================================
-- 添加导入按钮权限
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, update_by, update_time, remark)
VALUES ('用户档案导入', XXX, 5, '', '', 1, 0, 'F', '0', '0', 'psychology:profile:import', '#', 'admin', NOW(), '', NULL, '');
-- 添加导出按钮权限
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, update_by, update_time, remark)
VALUES ('用户档案导出', XXX, 6, '', '', 1, 0, 'F', '0', '0', 'psychology:profile:export', '#', 'admin', NOW(), '', NULL, '');
-- ============================================
-- 步骤4: 查询新添加的菜单ID
-- ============================================
SELECT menu_id, menu_name, perms FROM sys_menu WHERE perms IN ('psychology:profile:import', 'psychology:profile:export');
-- ============================================
-- 步骤5: 给老师角色添加这两个权限(需要替换 ROLE_ID 和 MENU_ID
-- ============================================
-- INSERT INTO sys_role_menu (role_id, menu_id) VALUES (老师角色ID, 导入菜单ID);
-- INSERT INTO sys_role_menu (role_id, menu_id) VALUES (老师角色ID, 导出菜单ID);
-- ============================================
-- 或者:给老师角色添加用户档案的所有现有权限
-- 先查询用户档案相关的所有菜单
-- ============================================
SELECT menu_id, menu_name, perms FROM sys_menu WHERE perms LIKE 'psychology:profile%';