-- =============================================
-- ODF v1.0.2 菜单权限初始化脚本
-- 新增 4 个一级菜单及按钮权限
-- =============================================

-- 1. 光缆管理（一级菜单）
INSERT INTO sys_menu (MenuId, MenuName, ParentId, OrderNum, Path, Component, IsCache, IsFrame, MenuType, Visible, Status, Perms, Icon, Create_by, Create_time)
VALUES (11190, N'光缆管理', 0, 5, 'OdfCables', 'business/OdfCables', 0, 0, 'C', '0', '0', 'odfcables:list', 'icon1', 'admin', GETDATE());

-- 光缆管理 - 按钮权限
INSERT INTO sys_menu (MenuId, MenuName, ParentId, OrderNum, Path, Component, MenuType, Perms, Create_by, Create_time)
VALUES (11191, N'查询', 11190, 1, '#', NULL, 'F', 'odfcables:query', 'admin', GETDATE());
INSERT INTO sys_menu (MenuId, MenuName, ParentId, OrderNum, Path, Component, MenuType, Perms, Create_by, Create_time)
VALUES (11192, N'新增', 11190, 2, '#', NULL, 'F', 'odfcables:add', 'admin', GETDATE());
INSERT INTO sys_menu (MenuId, MenuName, ParentId, OrderNum, Path, Component, MenuType, Perms, Create_by, Create_time)
VALUES (11193, N'删除', 11190, 3, '#', NULL, 'F', 'odfcables:delete', 'admin', GETDATE());
INSERT INTO sys_menu (MenuId, MenuName, ParentId, OrderNum, Path, Component, MenuType, Perms, Create_by, Create_time)
VALUES (11194, N'修改', 11190, 4, '#', NULL, 'F', 'odfcables:edit', 'admin', GETDATE());
INSERT INTO sys_menu (MenuId, MenuName, ParentId, OrderNum, Path, Component, MenuType, Perms, Create_by, Create_time)
VALUES (11195, N'导出', 11190, 5, '#', NULL, 'F', 'odfcables:export', 'admin', GETDATE());

-- 2. 干线故障管理（一级菜单）
INSERT INTO sys_menu (MenuId, MenuName, ParentId, OrderNum, Path, Component, IsCache, IsFrame, MenuType, Visible, Status, Perms, Icon, Create_by, Create_time)
VALUES (11200, N'干线故障管理', 0, 6, 'OdfCableFaults', 'business/OdfCableFaults', 0, 0, 'C', '0', '0', 'odfcablefaults:list', 'icon1', 'admin', GETDATE());

-- 干线故障管理 - 按钮权限
INSERT INTO sys_menu (MenuId, MenuName, ParentId, OrderNum, Path, Component, MenuType, Perms, Create_by, Create_time)
VALUES (11201, N'查询', 11200, 1, '#', NULL, 'F', 'odfcablefaults:query', 'admin', GETDATE());
INSERT INTO sys_menu (MenuId, MenuName, ParentId, OrderNum, Path, Component, MenuType, Perms, Create_by, Create_time)
VALUES (11202, N'删除', 11200, 2, '#', NULL, 'F', 'odfcablefaults:delete', 'admin', GETDATE());
INSERT INTO sys_menu (MenuId, MenuName, ParentId, OrderNum, Path, Component, MenuType, Perms, Create_by, Create_time)
VALUES (11203, N'导出', 11200, 3, '#', NULL, 'F', 'odfcablefaults:export', 'admin', GETDATE());

-- 3. 签到记录管理（一级菜单）
INSERT INTO sys_menu (MenuId, MenuName, ParentId, OrderNum, Path, Component, IsCache, IsFrame, MenuType, Visible, Status, Perms, Icon, Create_by, Create_time)
VALUES (11210, N'签到记录管理', 0, 7, 'OdfCheckin', 'business/OdfCheckin', 0, 0, 'C', '0', '0', 'odfcheckin:list', 'icon1', 'admin', GETDATE());

-- 签到记录管理 - 按钮权限
INSERT INTO sys_menu (MenuId, MenuName, ParentId, OrderNum, Path, Component, MenuType, Perms, Create_by, Create_time)
VALUES (11211, N'查询', 11210, 1, '#', NULL, 'F', 'odfcheckin:query', 'admin', GETDATE());
INSERT INTO sys_menu (MenuId, MenuName, ParentId, OrderNum, Path, Component, MenuType, Perms, Create_by, Create_time)
VALUES (11212, N'导出', 11210, 2, '#', NULL, 'F', 'odfcheckin:export', 'admin', GETDATE());

-- 4. 用户模块权限（一级菜单）
INSERT INTO sys_menu (MenuId, MenuName, ParentId, OrderNum, Path, Component, IsCache, IsFrame, MenuType, Visible, Status, Perms, Icon, Create_by, Create_time)
VALUES (11220, N'用户模块权限', 0, 8, 'OdfUserModules', 'business/OdfUserModules', 0, 0, 'C', '0', '0', 'odfusermodules:list', 'icon1', 'admin', GETDATE());

-- 用户模块权限 - 按钮权限
INSERT INTO sys_menu (MenuId, MenuName, ParentId, OrderNum, Path, Component, MenuType, Perms, Create_by, Create_time)
VALUES (11221, N'查询', 11220, 1, '#', NULL, 'F', 'odfusermodules:query', 'admin', GETDATE());
INSERT INTO sys_menu (MenuId, MenuName, ParentId, OrderNum, Path, Component, MenuType, Perms, Create_by, Create_time)
VALUES (11222, N'修改', 11220, 2, '#', NULL, 'F', 'odfusermodules:edit', 'admin', GETDATE());

-- =============================================
-- 角色菜单权限分配
-- Role 2 (common): 所有菜单 + 全部按钮权限
-- Role 3 (editor): 所有菜单 + 仅查询权限
-- Role 4 (lock):   所有菜单 + 仅查询权限
-- Role 1 (admin):  超级管理员自动拥有所有权限，无需插入
-- =============================================

-- Role 2 (common) — 光缆管理：全部权限
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (2, 11190, 'admin', GETDATE());
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (2, 11191, 'admin', GETDATE());
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (2, 11192, 'admin', GETDATE());
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (2, 11193, 'admin', GETDATE());
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (2, 11194, 'admin', GETDATE());
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (2, 11195, 'admin', GETDATE());

-- Role 2 (common) — 干线故障管理：全部权限
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (2, 11200, 'admin', GETDATE());
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (2, 11201, 'admin', GETDATE());
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (2, 11202, 'admin', GETDATE());
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (2, 11203, 'admin', GETDATE());

-- Role 2 (common) — 签到记录管理：全部权限
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (2, 11210, 'admin', GETDATE());
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (2, 11211, 'admin', GETDATE());
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (2, 11212, 'admin', GETDATE());

-- Role 2 (common) — 用户模块权限：全部权限
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (2, 11220, 'admin', GETDATE());
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (2, 11221, 'admin', GETDATE());
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (2, 11222, 'admin', GETDATE());

-- Role 3 (editor) — 光缆管理：菜单 + 查询
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (3, 11190, 'admin', GETDATE());
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (3, 11191, 'admin', GETDATE());

-- Role 3 (editor) — 干线故障管理：菜单 + 查询
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (3, 11200, 'admin', GETDATE());
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (3, 11201, 'admin', GETDATE());

-- Role 3 (editor) — 签到记录管理：菜单 + 查询
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (3, 11210, 'admin', GETDATE());
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (3, 11211, 'admin', GETDATE());

-- Role 3 (editor) — 用户模块权限：菜单 + 查询
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (3, 11220, 'admin', GETDATE());
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (3, 11221, 'admin', GETDATE());

-- Role 4 (lock) — 光缆管理：菜单 + 查询
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (4, 11190, 'admin', GETDATE());
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (4, 11191, 'admin', GETDATE());

-- Role 4 (lock) — 干线故障管理：菜单 + 查询
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (4, 11200, 'admin', GETDATE());
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (4, 11201, 'admin', GETDATE());

-- Role 4 (lock) — 签到记录管理：菜单 + 查询
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (4, 11210, 'admin', GETDATE());
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (4, 11211, 'admin', GETDATE());

-- Role 4 (lock) — 用户模块权限：菜单 + 查询
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (4, 11220, 'admin', GETDATE());
INSERT INTO sys_role_menu (Role_id, Menu_id, Create_by, Create_time) VALUES (4, 11221, 'admin', GETDATE());
