-- 文本文件表
CREATE TABLE IF NOT EXISTS `text_file` (
  `file_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '文件ID',
  `file_name` varchar(255) NOT NULL COMMENT '文件名',
  `original_file_name` varchar(255) NOT NULL COMMENT '原始文件名',
  `file_path` varchar(500) NOT NULL COMMENT '文件路径',
  `file_size` bigint(20) DEFAULT NULL COMMENT '文件大小（字节）',
  `description` varchar(500) DEFAULT NULL COMMENT '文件描述',
  `status` tinyint(1) DEFAULT '0' COMMENT '状态 0=正常 1=禁用',
  `upload_user_id` bigint(20) DEFAULT NULL COMMENT '上传用户ID',
  `upload_user_name` varchar(50) DEFAULT NULL COMMENT '上传用户名',
  `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted` tinyint(1) DEFAULT '0' COMMENT '删除标志 0=未删除 1=已删除',
  PRIMARY KEY (`file_id`),
  KEY `idx_status` (`status`),
  KEY `idx_create_time` (`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文本文件表';

-- 初始化一些示例菜单权限（可选）
-- 注意：这里的parent_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, update_by, update_time, remark) 
VALUES 
('文本阅读器', 0, 5, 'reader', NULL, 1, 0, 'M', '0', '0', NULL, 'documentation', 'admin', NOW(), NULL, NULL, '文本阅读器菜单'),
('文件管理', (SELECT menu_id FROM (SELECT menu_id FROM sys_menu WHERE menu_name = '文本阅读器' AND parent_id = 0) AS tmp), 1, 'file', 'reader/file/index', 1, 0, 'C', '0', '0', 'reader:file:list', 'list', 'admin', NOW(), NULL, NULL, '文本文件管理菜单'),
('文件上传', (SELECT menu_id FROM (SELECT menu_id FROM sys_menu WHERE menu_name = '文件管理' AND perms = 'reader:file:list') AS tmp), 1, '', NULL, 1, 0, 'F', '0', '0', 'reader:file:upload', '#', 'admin', NOW(), NULL, NULL, ''),
('文件查询', (SELECT menu_id FROM (SELECT menu_id FROM sys_menu WHERE menu_name = '文件管理' AND perms = 'reader:file:list') AS tmp), 2, '', NULL, 1, 0, 'F', '0', '0', 'reader:file:query', '#', 'admin', NOW(), NULL, NULL, ''),
('文件删除', (SELECT menu_id FROM (SELECT menu_id FROM sys_menu WHERE menu_name = '文件管理' AND perms = 'reader:file:list') AS tmp), 3, '', NULL, 1, 0, 'F', '0', '0', 'reader:file:remove', '#', 'admin', NOW(), NULL, NULL, ''),
('文件编辑', (SELECT menu_id FROM (SELECT menu_id FROM sys_menu WHERE menu_name = '文件管理' AND perms = 'reader:file:list') AS tmp), 4, '', NULL, 1, 0, 'F', '0', '0', 'reader:file:edit', '#', 'admin', NOW(), NULL, NULL, '');


