-- 通知管理菜单和权限SQL

-- 菜单 SQL
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
('通知管理', 1, 9, 'notify', NULL, 1, 0, 'M', '0', '0', '', 'message', 'admin', SYSDATE(), '', NULL, '通知管理目录');

-- 获取刚插入的父菜单ID（需要手动执行下面的SQL，替换@parentId）
SET @parentId = (SELECT menu_id FROM sys_menu WHERE menu_name = '通知管理' AND menu_type = 'M');

-- 通知任务管理菜单
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
('通知任务', @parentId, 1, 'task', 'system/notify/task/index', 1, 0, 'C', '0', '0', 'system:notify:task:list', 'task', 'admin', SYSDATE(), '', NULL, '通知任务菜单');

-- 获取刚插入的通知任务菜单ID
SET @taskParentId = (SELECT menu_id FROM sys_menu WHERE menu_name = '通知任务' AND menu_type = 'C');

-- 通知任务按钮 SQL
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
('通知任务查询', @taskParentId, 1,  '#', '', 1, 0, 'F', '0', '0', 'system:notify:task:query',        '#', 'admin', SYSDATE(), '', NULL, ''),
('通知任务导出', @taskParentId, 2,  '#', '', 1, 0, 'F', '0', '0', 'system:notify:task:export',       '#', 'admin', SYSDATE(), '', 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
('发送日志', @parentId, 2, 'log', 'system/notify/log/index', 1, 0, 'C', '0', '0', 'system:notify:log:list', 'log', 'admin', SYSDATE(), '', NULL, '通知发送日志菜单');

-- 获取刚插入的发送日志菜单ID
SET @logParentId = (SELECT menu_id FROM sys_menu WHERE menu_name = '发送日志' AND menu_type = 'C');

-- 通知发送日志按钮 SQL
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
('发送日志查询', @logParentId, 1,  '#', '', 1, 0, 'F', '0', '0', 'system:notify:log:query',        '#', 'admin', SYSDATE(), '', NULL, ''),
('发送日志导出', @logParentId, 2,  '#', '', 1, 0, 'F', '0', '0', 'system:notify:log:export',       '#', 'admin', SYSDATE(), '', 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
('渠道配置', @parentId, 3, 'channelConfig', 'system/notify/channelConfig', 1, 0, 'C', '0', '0', 'system:notify:channel:config:list', 'config', 'admin', SYSDATE(), '', NULL, '通知渠道配置菜单');

-- 获取刚插入的渠道配置菜单ID
SET @channelConfigParentId = (SELECT menu_id FROM sys_menu WHERE menu_name = '渠道配置' AND menu_type = 'C');

-- 通知渠道配置按钮 SQL
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
('渠道配置查询', @channelConfigParentId, 1,  '#', '', 1, 0, 'F', '0', '0', 'system:notify:channel:config:query',        '#', 'admin', SYSDATE(), '', NULL, ''),
('渠道配置新增', @channelConfigParentId, 2,  '#', '', 1, 0, 'F', '0', '0', 'system:notify:channel:config:add',       '#', 'admin', SYSDATE(), '', NULL, ''),
('渠道配置修改', @channelConfigParentId, 3,  '#', '', 1, 0, 'F', '0', '0', 'system:notify:channel:config:edit',       '#', 'admin', SYSDATE(), '', NULL, ''),
('渠道配置删除', @channelConfigParentId, 4,  '#', '', 1, 0, 'F', '0', '0', 'system:notify:channel:config:remove',       '#', 'admin', SYSDATE(), '', 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
('企业微信测试', @parentId, 4, 'qywechat/test', 'system/qywechat/test', 1, 0, 'C', '0', '0', 'system:qywechat:test:list', 'wechat', 'admin', SYSDATE(), '', NULL, '企业微信测试菜单');

-- 获取刚插入的企业微信测试菜单ID
SET @qywechatTestParentId = (SELECT menu_id FROM sys_menu WHERE menu_name = '企业微信测试' AND menu_type = 'C');

-- 企业微信测试按钮 SQL
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
('企业微信测试查询', @qywechatTestParentId, 1,  '#', '', 1, 0, 'F', '0', '0', 'system:qywechat:test:query',        '#', 'admin', SYSDATE(), '', NULL, ''),
('企业微信测试新增', @qywechatTestParentId, 2,  '#', '', 1, 0, 'F', '0', '0', 'system:qywechat:test:add',       '#', 'admin', SYSDATE(), '', NULL, ''),
('企业微信测试修改', @qywechatTestParentId, 3,  '#', '', 1, 0, 'F', '0', '0', 'system:qywechat:test:edit',       '#', 'admin', SYSDATE(), '', NULL, ''),
('企业微信测试删除', @qywechatTestParentId, 4,  '#', '', 1, 0, 'F', '0', '0', 'system:qywechat:test:remove',       '#', 'admin', SYSDATE(), '', NULL, '');