-- =============================================
-- 租户管理菜单权限SQL
-- =============================================

-- ----------------------------
-- 1. 插入租户管理菜单
-- ----------------------------
-- 菜单 SQL
INSERT INTO sys_menu (menu_id, 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 (2000, '租户管理', 0, 6, 'tenant', 'system/tenant/index', 1, 0, 'C', '0', '0', 'system:tenant:list', 'peoples', 'admin', sysdate(), '', '', '租户管理菜单');

-- 按钮 SQL
INSERT INTO sys_menu (menu_name, parent_id, order_num, perms, menu_type, visible, status, create_by, create_time)
VALUES ('租户查询', 2000, 1, 'system:tenant:query', 'F', '0', '0', 'admin', sysdate());

INSERT INTO sys_menu (menu_name, parent_id, order_num, perms, menu_type, visible, status, create_by, create_time)
VALUES ('租户新增', 2000, 2, 'system:tenant:add', 'F', '0', '0', 'admin', sysdate());

INSERT INTO sys_menu (menu_name, parent_id, order_num, perms, menu_type, visible, status, create_by, create_time)
VALUES ('租户修改', 2000, 3, 'system:tenant:edit', 'F', '0', '0', 'admin', sysdate());

INSERT INTO sys_menu (menu_name, parent_id, order_num, perms, menu_type, visible, status, create_by, create_time)
VALUES ('租户删除', 2000, 4, 'system:tenant:remove', 'F', '0', '0', 'admin', sysdate());

-- ----------------------------
-- 2. 为超级管理员角色分配租户管理权限
-- ----------------------------
INSERT INTO sys_role_menu (role_id, menu_id)
SELECT 1, menu_id FROM sys_menu WHERE perms IN ('system:tenant:list', 'system:tenant:query', 'system:tenant:add', 'system:tenant:edit', 'system:tenant:remove');

-- ----------------------------
-- 3. 查看菜单是否插入成功
-- ----------------------------
-- SELECT * FROM sys_menu WHERE menu_id = 2000 OR parent_id = 2000;
