fastbee/sql/menu_threshold.sql
2026-09-10 21:00:05 +08:00

37 lines
2.3 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.

-- ============================================================
-- 监测阈值配置菜单权限初始化
-- 说明:在 fastbee 数据库中执行此脚本
-- ============================================================
-- 查询 IoT 模块父菜单 ID(假设菜单名称为"设备管理"或"监测管理")
-- 如果不存在,则创建一个"监测管理"父菜单
SET @iot_parent_id = (SELECT menu_id FROM sys_menu WHERE menu_name = '设备管理' AND parent_id = 0 LIMIT 1);
-- 如果找不到"设备管理",则使用系统工具作为父菜单
SET @iot_parent_id = IFNULL(@iot_parent_id, 1);
-- 插入阈值配置菜单
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 ('阈值配置', @iot_parent_id, 10, 'threshold', 'iot/threshold/index', 1, 0, 'C', '0', '0', 'iot:threshold:list', 'tool', 'admin', NOW(), '监测阈值配置菜单');
-- 获取刚插入的菜单 ID
SET @threshold_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, remark) VALUES
('阈值查询', @threshold_menu_id, 1, '', '', 1, 0, 'F', '0', '0', 'iot:threshold:query', '#', 'admin', NOW(), ''),
('阈值新增', @threshold_menu_id, 2, '', '', 1, 0, 'F', '0', '0', 'iot:threshold:add', '#', 'admin', NOW(), ''),
('阈值修改', @threshold_menu_id, 3, '', '', 1, 0, 'F', '0', '0', 'iot:threshold:edit', '#', 'admin', NOW(), ''),
('阈值删除', @threshold_menu_id, 4, '', '', 1, 0, 'F', '0', '0', 'iot:threshold:remove', '#', 'admin', NOW(), ''),
('阈值导出', @threshold_menu_id, 5, '', '', 1, 0, 'F', '0', '0', 'iot:threshold:export', '#', 'admin', NOW(), '');
-- 提示
SELECT '阈值配置菜单已创建,菜单ID为:' AS message, @threshold_menu_id AS menu_id;
SELECT '请在前端重新登录或刷新页面以查看新菜单' AS hint;
-- ============================================================
-- 说明:
-- 1. 执行此脚本后,管理员角色将自动拥有阈值配置菜单权限
-- 2. 如需分配给其他角色,请在"系统管理 -> 角色管理"中配置
-- 3. 菜单路径为:/iot/threshold,组件路径为:iot/threshold/index
-- ============================================================