DROP TABLE IF EXISTS `pre_config`;
create table `pre_config` (
  `k` varchar(32) NOT NULL,
  `v` text NULL,
  PRIMARY KEY  (`k`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

INSERT INTO `pre_config` VALUES ('version', '2021');
INSERT INTO `pre_config` VALUES ('admin_user', 'admin');
INSERT INTO `pre_config` VALUES ('admin_pwd', '123456');
INSERT INTO `pre_config` VALUES ('blackip', '');
INSERT INTO `pre_config` VALUES ('title', '彩虹外链网盘');
INSERT INTO `pre_config` VALUES ('keywords', '外链网盘,免费外链,免费图床,图片外链');
INSERT INTO `pre_config` VALUES ('description', '彩虹外链网盘提供大容量云存储服务');
INSERT INTO `pre_config` VALUES ('iptype', '0');
INSERT INTO `pre_config` VALUES ('filesearch', '1');
INSERT INTO `pre_config` VALUES ('storage', 'local');
INSERT INTO `pre_config` VALUES ('filepath', '');
INSERT INTO `pre_config` VALUES ('aliyun_ak', '');
INSERT INTO `pre_config` VALUES ('aliyun_sk', '');
INSERT INTO `pre_config` VALUES ('name_block', '');
INSERT INTO `pre_config` VALUES ('type_block', '');
INSERT INTO `pre_config` VALUES ('type_image', 'png|jpg|jpeg|gif|bmp|webp|ico|svg|svgz|tif|tiff|heic|exif');
INSERT INTO `pre_config` VALUES ('type_audio', 'mp3|wav|ogg|m4a|flac|aac');
INSERT INTO `pre_config` VALUES ('type_video', 'mp4|webm|flv|f4v|mov|3gp|3gpp|avi|mpg|mpeg|wmv|mkv|ts|dat|asf|mts|m2ts|m3u8|m4v');
INSERT INTO `pre_config` VALUES ('green_check', '0');
INSERT INTO `pre_config` VALUES ('green_check_region', 'cn-beijing');
INSERT INTO `pre_config` VALUES ('green_check_porn', '0');
INSERT INTO `pre_config` VALUES ('green_check_terrorism', '0');
INSERT INTO `pre_config` VALUES ('green_label_porn', 'sexy,porn');
INSERT INTO `pre_config` VALUES ('green_label_terrorism', 'bloody,explosion,outfit,logo,weapon,politics');
INSERT INTO `pre_config` VALUES ('gg_file', '网站所有文件内容均由用户自行上传分享本站严格遵守国家相关法律法规，尊重著作权、版权等第三方权利，如果当前文件侵犯了您的相关权利，请邮件反馈至@qq.com，我们将及时处理。');
INSERT INTO `pre_config` VALUES ('user_storage_quota', '1024');
INSERT INTO `pre_config` VALUES ('user_traffic_quota', '1024');
INSERT INTO `pre_config` VALUES ('traffic_log_enabled', '1');
INSERT INTO `pre_config` VALUES ('traffic_log_retention_days', '90');
INSERT INTO `pre_config` VALUES ('traffic_alert_threshold', '80');
INSERT INTO `pre_config` VALUES ('traffic_alert_enabled', '1');
INSERT INTO `pre_config` VALUES ('traffic_anomaly_detection', '1');
INSERT INTO `pre_config` VALUES ('traffic_anomaly_threshold', '5');
INSERT INTO `pre_config` VALUES ('traffic_anomaly_window', '60');
INSERT INTO `pre_config` VALUES ('traffic_anomaly_count', '50');
INSERT INTO `pre_config` VALUES ('traffic_anomaly_avg_size', '100');
INSERT INTO `pre_config` VALUES ('guest_auto_ban_enabled', '0');
INSERT INTO `pre_config` VALUES ('guest_ban_duration', '86400');
INSERT INTO `pre_config` VALUES ('guest_storage_quota', '0');
INSERT INTO `pre_config` VALUES ('guest_traffic_quota', '0');
INSERT INTO `pre_config` VALUES ('user_anomaly_ban_enabled', '0');
INSERT INTO `pre_config` VALUES ('user_anomaly_ban_duration', '86400');
INSERT INTO `pre_config` VALUES ('login_apiurl', '');
INSERT INTO `pre_config` VALUES ('login_appid', '');
INSERT INTO `pre_config` VALUES ('login_appkey', '');
INSERT INTO `pre_config` VALUES ('login_qq', '0');
INSERT INTO `pre_config` VALUES ('login_wx', '0');
INSERT INTO `pre_config` VALUES ('uploadfile_type', '0');
INSERT INTO `pre_config` VALUES ('downfile_type', '0');
INSERT INTO `pre_config` VALUES ('downfile_protocol', '0');
INSERT INTO `pre_config` VALUES ('downfile_domain', '');
INSERT INTO `pre_config` VALUES ('storagename', '');
INSERT INTO `pre_config` VALUES ('oss_ak', '');
INSERT INTO `pre_config` VALUES ('oss_sk', '');
INSERT INTO `pre_config` VALUES ('oss_endpoint', '');
INSERT INTO `pre_config` VALUES ('oss_bucket', '');
INSERT INTO `pre_config` VALUES ('qcloud_id', '');
INSERT INTO `pre_config` VALUES ('qcloud_key', '');
INSERT INTO `pre_config` VALUES ('qcloud_region', '');
INSERT INTO `pre_config` VALUES ('qcloud_bucket', '');
INSERT INTO `pre_config` VALUES ('obs_ak', '');
INSERT INTO `pre_config` VALUES ('obs_sk', '');
INSERT INTO `pre_config` VALUES ('obs_endpoint', '');
INSERT INTO `pre_config` VALUES ('obs_bucket', '');
INSERT INTO `pre_config` VALUES ('upyun_name', '');
INSERT INTO `pre_config` VALUES ('upyun_user', '');
INSERT INTO `pre_config` VALUES ('upyun_pwd', '');
INSERT INTO `pre_config` VALUES ('qiniu_ak', '');
INSERT INTO `pre_config` VALUES ('qiniu_sk', '');
INSERT INTO `pre_config` VALUES ('qiniu_bucket', '');
INSERT INTO `pre_config` VALUES ('qiniu_domain', '');
INSERT INTO `pre_config` VALUES ('rainyun_ak', '');
INSERT INTO `pre_config` VALUES ('rainyun_sk', '');
INSERT INTO `pre_config` VALUES ('rainyun_bucket', '');
INSERT INTO `pre_config` VALUES ('rainyun_endpoint', 's3.rainyun.com');

DROP TABLE IF EXISTS `pre_file`;
CREATE TABLE `pre_file` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `type` varchar(50) DEFAULT NULL,
  `size` int(11) unsigned NOT NULL,
  `hash` varchar(32) NOT NULL,
  `addtime` datetime NOT NULL,
  `lasttime` datetime DEFAULT NULL,
  `ip` varchar(15) NOT NULL,
  `hide` int(1) NOT NULL DEFAULT '0',
  `pwd` varchar(255) DEFAULT NULL,
  `block` int(1) NOT NULL DEFAULT '0',
  `count` int(11) unsigned NOT NULL DEFAULT '0',
  `uid` int(11) unsigned NOT NULL DEFAULT '0',
  `folder_id` int(11) unsigned NOT NULL DEFAULT '0',
  `guest_token` varchar(32) DEFAULT NULL,
  `share_key` varchar(64) DEFAULT NULL COMMENT '分享链接密钥',
  `share_type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '分享类型:0=直链,1=普通链接',
  `share_notice` text COMMENT '分享页面公告(支持HTML)',
  `share_count` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '分享页面访问次数',
   PRIMARY KEY (`id`),
   KEY `hash` (`hash`),
   KEY `uid` (`uid`),
   KEY `folder_id` (`folder_id`),
   KEY `idx_guest_token` (`guest_token`),
   KEY `idx_share_key` (`share_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

DROP TABLE IF EXISTS `pre_folder`;
CREATE TABLE `pre_folder` (
  `folder_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `uid` int(11) unsigned NOT NULL,
  `parent_id` int(11) unsigned NOT NULL DEFAULT '0',
  `name` varchar(255) NOT NULL,
  `sort` int(11) NOT NULL DEFAULT '0',
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `perm_read` tinyint(1) NOT NULL DEFAULT '1',
  `perm_write` tinyint(1) NOT NULL DEFAULT '1',
  `perm_exec` tinyint(1) NOT NULL DEFAULT '1',
  PRIMARY KEY (`folder_id`),
  KEY `uid` (`uid`),
  KEY `parent_id` (`parent_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

DROP TABLE IF EXISTS `pre_log`;
CREATE TABLE `pre_log` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `uid` int(11) unsigned NOT NULL,
  `action` varchar(50) NOT NULL,
  `details` text,
  `ip` varchar(50) NOT NULL,
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

DROP TABLE IF EXISTS `pre_user`;
CREATE TABLE `pre_user` (
  `uid` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(50) NOT NULL,
  `password` varchar(255) NOT NULL,
  `email` varchar(100) DEFAULT NULL,
  `nickname` varchar(255) NOT NULL,
  `faceimg` varchar(255) DEFAULT NULL,
  `qq_openid` varchar(150) DEFAULT NULL,
  `wx_openid` varchar(150) DEFAULT NULL,
  `enable` tinyint(1) NOT NULL DEFAULT '1',
  `level` tinyint(4) NOT NULL DEFAULT '0',
  `regip` varchar(20) DEFAULT NULL,
  `loginip` varchar(20) DEFAULT NULL,
  `login_count` int(11) NOT NULL DEFAULT '0',
  `addtime` datetime NOT NULL,
  `lasttime` datetime NOT NULL,
  `storage_used` bigint(20) unsigned NOT NULL DEFAULT '0',
  `traffic_used` bigint(20) unsigned NOT NULL DEFAULT '0',
  `u_storage_quota` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '用户额外存储配额（字节）',
  `u_traffic_quota` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '用户额外流量配额（字节）',
  `u_storage_expire` datetime DEFAULT NULL COMMENT '额外存储配额过期时间',
  `u_traffic_expire` datetime DEFAULT NULL COMMENT '额外流量配额过期时间',
  PRIMARY KEY (`uid`),
  UNIQUE KEY `username` (`username`),
  KEY `qq_openid` (`qq_openid`),
  KEY `wx_openid` (`wx_openid`),
  KEY `enable` (`enable`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1000;

DROP TABLE IF EXISTS `pre_updates`;
CREATE TABLE `pre_updates` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `version_code` int(11) unsigned NOT NULL,
  `version_name` varchar(50) NOT NULL,
  `changelog` text,
  `file_path` varchar(255) DEFAULT NULL,
  `sql_path` varchar(255) DEFAULT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `version_code` (`version_code`),
  KEY `status` (`status`),
  KEY `created_at` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

DROP TABLE IF EXISTS `pre_traffic_log`;
CREATE TABLE `pre_traffic_log` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `file_id` int(11) unsigned NOT NULL COMMENT '文件ID',
  `file_hash` varchar(32) NOT NULL COMMENT '文件hash',
  `file_name` varchar(255) NOT NULL COMMENT '文件名',
  `file_size` bigint(20) unsigned NOT NULL COMMENT '文件大小（字节）',
  `file_type` varchar(50) DEFAULT NULL COMMENT '文件类型',
  `owner_uid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '文件所有者UID（0=游客上传）',
  `visitor_uid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '访问者UID（0=游客）',
  `visitor_ip` varchar(50) NOT NULL COMMENT '访问者IP',
  `access_type` varchar(20) NOT NULL COMMENT '访问类型：download/preview',
  `traffic_size` bigint(20) unsigned NOT NULL COMMENT '实际流量大小（字节）',
  `range_start` bigint(20) unsigned DEFAULT NULL COMMENT '范围请求起始位置',
  `range_end` bigint(20) unsigned DEFAULT NULL COMMENT '范围请求结束位置',
  `created_at` datetime NOT NULL COMMENT '访问时间',
  PRIMARY KEY (`id`),
  KEY `file_id` (`file_id`),
  KEY `file_hash` (`file_hash`),
  KEY `owner_uid` (`owner_uid`),
  KEY `visitor_uid` (`visitor_uid`),
  KEY `visitor_ip` (`visitor_ip`),
  KEY `access_type` (`access_type`),
  KEY `created_at` (`created_at`),
  KEY `owner_date` (`owner_uid`, `created_at`),
  KEY `visitor_date` (`visitor_uid`, `created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='流量使用日志表';

DROP TABLE IF EXISTS `pre_traffic_quota`;
CREATE TABLE `pre_traffic_quota` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `uid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户UID（0=游客）',
  `ip` varchar(50) DEFAULT NULL COMMENT 'IP地址（游客专用）',
  `quota_type` varchar(20) NOT NULL COMMENT '配额类型：daily/monthly/yearly',
  `quota_limit` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '配额限制（字节）',
  `quota_used` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '已使用流量（字节）',
  `period_start` datetime NOT NULL COMMENT '统计周期开始时间',
  `period_end` datetime NOT NULL COMMENT '统计周期结束时间',
  `last_reset` datetime DEFAULT NULL COMMENT '上次重置时间',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态：1=正常, 0=已超限',
  `created_at` datetime NOT NULL COMMENT '创建时间',
  `updated_at` datetime NOT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_quota` (`uid`, `ip`, `quota_type`, `period_start`),
  KEY `uid` (`uid`),
  KEY `ip` (`ip`),
  KEY `quota_type` (`quota_type`),
  KEY `period_start` (`period_start`),
  KEY `status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='流量配额表';

DROP TABLE IF EXISTS `pre_card`;
CREATE TABLE `pre_card` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `card_code` varchar(32) NOT NULL COMMENT '卡密代码',
  `card_type` varchar(20) NOT NULL COMMENT '卡密类型：storage/traffic/both',
  `storage_quota` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '存储空间配额（字节）',
  `traffic_quota` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '流量配额（字节）',
  `status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '状态：0=未使用, 1=已使用, 2=已禁用',
  `used_uid` int(11) unsigned DEFAULT NULL COMMENT '使用用户UID',
  `used_time` datetime DEFAULT NULL COMMENT '使用时间',
  `created_by` int(11) unsigned NOT NULL COMMENT '创建者UID（管理员）',
  `created_at` datetime NOT NULL COMMENT '创建时间',
  `expire_time` datetime DEFAULT NULL COMMENT '过期时间',
  `expire_days` int(11) unsigned DEFAULT '0' COMMENT '过期天数（0表示不过期，从使用时间开始计算）',
  `remark` varchar(255) DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`id`),
  UNIQUE KEY `card_code` (`card_code`),
  KEY `card_type` (`card_type`),
  KEY `status` (`status`),
  KEY `used_uid` (`used_uid`),
  KEY `created_at` (`created_at`),
  KEY `expire_time` (`expire_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='卡密表';

DROP TABLE IF EXISTS `pre_ip_ban`;
CREATE TABLE `pre_ip_ban` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `ip` varchar(50) NOT NULL COMMENT '被封禁的IP地址',
  `ip_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'IP类型：0=IPv4, 1=IPv6',
  `ban_type` varchar(20) NOT NULL DEFAULT 'auto' COMMENT '封禁类型：auto=自动封禁, manual=手动封禁',
  `ban_reason` varchar(255) DEFAULT NULL COMMENT '封禁原因',
  `ban_start` datetime NOT NULL COMMENT '封禁开始时间',
  `ban_end` datetime DEFAULT NULL COMMENT '封禁结束时间（NULL表示永久封禁）',
  `trigger_count` int(11) unsigned NOT NULL DEFAULT '1' COMMENT '触发封禁的异常次数',
  `traffic_limit` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '触发封禁时的流量限制（字节）',
  `traffic_used` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '触发封禁时的已用流量（字节）',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态：1=封禁中, 0=已解封',
  `created_by` int(11) unsigned DEFAULT '0' COMMENT '操作者UID（0=系统自动）',
  `created_at` datetime NOT NULL COMMENT '创建时间',
  `updated_at` datetime NOT NULL COMMENT '更新时间',
  `unbanned_at` datetime DEFAULT NULL COMMENT '解封时间',
  `unban_reason` varchar(255) DEFAULT NULL COMMENT '解封原因',
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_ip` (`ip`),
  KEY `ip` (`ip`),
  KEY `ban_type` (`ban_type`),
  KEY `ban_end` (`ban_end`),
  KEY `status` (`status`),
  KEY `created_at` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='IP封禁表';

DROP TABLE IF EXISTS `pre_ip_ban_log`;
CREATE TABLE `pre_ip_ban_log` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `ip` varchar(50) NOT NULL COMMENT 'IP地址',
  `action` varchar(20) NOT NULL COMMENT '操作：ban=封禁, unban=解封',
  `ban_type` varchar(20) DEFAULT NULL COMMENT '封禁类型',
  `ban_reason` varchar(255) DEFAULT NULL COMMENT '封禁原因',
  `ban_end` datetime DEFAULT NULL COMMENT '封禁结束时间',
  `operator_uid` int(11) unsigned DEFAULT '0' COMMENT '操作者UID',
  `operator_name` varchar(50) DEFAULT NULL COMMENT '操作者名称',
  `created_at` datetime NOT NULL COMMENT '操作时间',
  PRIMARY KEY (`id`),
  KEY `ip` (`ip`),
  KEY `action` (`action`),
  KEY `created_at` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='IP封禁日志表';

-- 邮箱配置表
DROP TABLE IF EXISTS `pre_email_config`;
CREATE TABLE `pre_email_config` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `smtp_server` varchar(255) NOT NULL DEFAULT 'smtp.qq.com' COMMENT 'SMTP服务器地址',
  `smtp_port` int(11) unsigned NOT NULL DEFAULT 587 COMMENT 'SMTP端口',
  `smtp_user` varchar(255) NOT NULL DEFAULT '' COMMENT 'SMTP用户名（邮箱地址）',
  `smtp_pass` varchar(255) NOT NULL DEFAULT '' COMMENT 'SMTP密码或授权码',
  `smtp_secure` varchar(10) NOT NULL DEFAULT 'tls' COMMENT '加密方式：tls/ssl/none',
  `from_email` varchar(255) NOT NULL DEFAULT '' COMMENT '发件人邮箱',
  `from_name` varchar(255) NOT NULL DEFAULT '' COMMENT '发件人名称',
  `is_enabled` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否启用：0=禁用，1=启用',
  `updated_at` datetime NOT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='邮箱配置表';

-- 插入默认配置
INSERT INTO `pre_email_config` (`smtp_server`, `smtp_port`, `smtp_user`, `smtp_pass`, `smtp_secure`, `from_email`, `from_name`, `is_enabled`, `updated_at`) 
VALUES ('smtp.qq.com', 587, '', '', 'tls', '', '彩虹外链网盘', 0, NOW());

-- 邮箱验证码记录表
DROP TABLE IF EXISTS `pre_email_verify`;
CREATE TABLE `pre_email_verify` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `email` varchar(255) NOT NULL COMMENT '邮箱地址',
  `code` varchar(10) NOT NULL COMMENT '验证码',
  `type` varchar(20) NOT NULL COMMENT '验证码类型：register=注册，resetpwd=找回密码，bind=绑定邮箱，unbind=解绑邮箱',
  `ip` varchar(50) NOT NULL COMMENT '请求IP',
  `uid` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '用户ID（0表示未登录用户）',
  `is_used` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否已使用：0=未使用，1=已使用',
  `used_at` datetime DEFAULT NULL COMMENT '使用时间',
  `expire_at` datetime NOT NULL COMMENT '过期时间',
  `created_at` datetime NOT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`),
  KEY `email` (`email`),
  KEY `code` (`code`),
  KEY `type` (`type`),
  KEY `ip` (`ip`),
  KEY `uid` (`uid`),
  KEY `expire_at` (`expire_at`),
  KEY `created_at` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='邮箱验证码记录表';

-- 用户中心公告栏表
DROP TABLE IF EXISTS `pre_user_announcement`;
CREATE TABLE `pre_user_announcement` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(255) NOT NULL DEFAULT '' COMMENT '公告标题',
  `content` text NOT NULL COMMENT '公告内容（支持HTML）',
  `type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '公告类型：1=普通公告，2=重要公告，3=紧急公告',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态：0=禁用，1=启用',
  `sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序权重，数值越大越靠前',
  `start_time` datetime DEFAULT NULL COMMENT '开始显示时间（NULL表示立即显示）',
  `end_time` datetime DEFAULT NULL COMMENT '结束显示时间（NULL表示永不过期）',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `update_time` datetime NOT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`),
  KEY `status` (`status`),
  KEY `sort` (`sort`),
  KEY `start_time` (`start_time`),
  KEY `end_time` (`end_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户中心公告栏表';

-- 插入默认公告示例
INSERT INTO `pre_user_announcement` (`title`, `content`, `type`, `status`, `sort`, `start_time`, `end_time`, `create_time`, `update_time`) VALUES
('欢迎使用用户中心', '<p>欢迎使用用户中心！您可以在这里管理个人资料、查看资源配额、兑换卡密等。</p>', 1, 1, 10, NULL, NULL, NOW(), NOW()),
('系统公告功能已上线', '<p>用户中心现在支持公告栏功能啦！管理员可以在后台发布重要通知。</p>', 2, 1, 5, NULL, NULL, NOW(), NOW());
