-- ========================================
-- 量表权限管理菜单配置
-- ========================================
USE ry_news;
SET NAMES utf8mb4;

-- ========================================
-- 量表权限管理
-- ========================================
INSERT IGNORE 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`)
SELECT '量表权限管理', menu_id, 11, 'permission', 'psychology/permission/index', 1, 0, 'C', '0', '0', 'psychology:permission:list', 'lock', 'admin', NOW(), '量表权限管理菜单'
FROM sys_menu WHERE menu_name = '心理测评管理' AND parent_id = 0 LIMIT 1;

-- 量表权限管理按钮权限
INSERT IGNORE 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`)
SELECT '权限查询', menu_id, 1, '', '', 1, 0, 'F', '0', '0', 'psychology:permission:query', '#', 'admin', NOW(), ''
FROM sys_menu WHERE menu_name = '量表权限管理' LIMIT 1;

INSERT IGNORE 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`)
SELECT '权限新增', menu_id, 2, '', '', 1, 0, 'F', '0', '0', 'psychology:permission:add', '#', 'admin', NOW(), ''
FROM sys_menu WHERE menu_name = '量表权限管理' LIMIT 1;

INSERT IGNORE 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`)
SELECT '权限修改', menu_id, 3, '', '', 1, 0, 'F', '0', '0', 'psychology:permission:edit', '#', 'admin', NOW(), ''
FROM sys_menu WHERE menu_name = '量表权限管理' LIMIT 1;

INSERT IGNORE 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`)
SELECT '权限删除', menu_id, 4, '', '', 1, 0, 'F', '0', '0', 'psychology:permission:remove', '#', 'admin', NOW(), ''
FROM sys_menu WHERE menu_name = '量表权限管理' LIMIT 1;

-- ========================================
-- 为管理员角色分配权限
-- ========================================
INSERT IGNORE INTO `sys_role_menu` (`role_id`, `menu_id`)
SELECT 1, menu_id FROM sys_menu WHERE menu_name = '量表权限管理' OR menu_name LIKE '%权限查询%' OR menu_name LIKE '%权限新增%' OR menu_name LIKE '%权限修改%' OR menu_name LIKE '%权限删除%';

SELECT '量表权限管理菜单配置完成！' AS result;

