-- ============================================ -- 热点雷达系统 (Hotspot Radar) — 6 tables -- ============================================ -- ./hotspot_source (来源配置: API / Browser / Crawler) drop table if exists hotspot_source; CREATE TABLE hotspot_source ( `id` VARCHAR(32) comment 'id', `name` VARCHAR(200) comment '来源名称', `type` VARCHAR(20) comment '类型: rss/api/browser/crawler', `url` VARCHAR(2000) comment '目标URL', -- API 类型专用 `api_key` VARCHAR(500) comment 'API Key', `api_secret` VARCHAR(500) comment 'API Secret(加密)', `headers` TEXT comment '自定义请求头 JSON', `fetch_method` VARCHAR(10) DEFAULT 'GET' comment 'HTTP方法', `request_body` TEXT comment 'POST请求体', -- Browser 类型专用 `browser_headless` VARCHAR(1) DEFAULT '1' comment '无头模式', `browser_wait_selector` VARCHAR(500) comment '等待元素选择器', `browser_scroll` VARCHAR(1) DEFAULT '0' comment '是否自动滚动', -- Crawler 类型专用 `crawler_depth` INT DEFAULT 1 comment '爬取深度', `crawler_rules` TEXT comment '爬取规则 JSON', `crawler_start_urls` TEXT comment '起始URL列表 JSON', -- 通用 `proxy_enabled` VARCHAR(1) DEFAULT '0' comment '启用代理', `proxy_url` VARCHAR(500) comment '代理地址', `parser_config` TEXT comment '提取规则 JSON: parser/item_path/field_map/builtin_name', `enabled` VARCHAR(1) DEFAULT '1' comment '是否启用', `priority` INT DEFAULT 0 comment '优先级(越大越高)', `last_fetch` VARCHAR(50) comment '上次抓取时间', `created_at` VARCHAR(50) comment '创建时间' ,primary key(id) ) engine=innodb default charset=utf8 comment '热点来源配置' ; -- ./hotspot_schedule (调度配置) drop table if exists hotspot_schedule; CREATE TABLE hotspot_schedule ( `id` VARCHAR(32) comment 'id', `source_id` VARCHAR(32) comment '关联来源ID', `cron_expr` VARCHAR(100) comment 'cron表达式', `interval_min` INT DEFAULT 60 comment '间隔(分钟)', `enabled` VARCHAR(1) DEFAULT '1' comment '是否启用', `last_run` VARCHAR(50) comment '上次运行', `next_run` VARCHAR(50) comment '下次运行', `retry_max` INT DEFAULT 3 comment '最大重试', `retry_count` INT DEFAULT 0 comment '已重试次数' ,primary key(id) ) engine=innodb default charset=utf8 comment '调度配置' ; CREATE INDEX hotspot_schedule_source_idx ON hotspot_schedule(source_id); -- ./hotspot_fetch_log (抓取日志) drop table if exists hotspot_fetch_log; CREATE TABLE hotspot_fetch_log ( `id` VARCHAR(32) comment 'id', `source_id` VARCHAR(32) comment '关联来源ID', `start_time` VARCHAR(50) comment '开始时间', `end_time` VARCHAR(50) comment '结束时间', `duration_ms` INT DEFAULT 0 comment '耗时(毫秒)', `status` VARCHAR(20) comment '状态: success/failed/partial', `items_total` INT DEFAULT 0 comment '抓取总数', `items_new` INT DEFAULT 0 comment '新增数量', `items_duplicate` INT DEFAULT 0 comment '重复数量', `error_msg` TEXT comment '错误信息', `response_code` INT comment 'HTTP状态码', `response_size_bytes` INT DEFAULT 0 comment '响应大小' ,primary key(id) ) engine=innodb default charset=utf8 comment '抓取日志' ; CREATE INDEX hotspot_fetch_log_source_idx ON hotspot_fetch_log(source_id); CREATE INDEX hotspot_fetch_log_status_idx ON hotspot_fetch_log(status); -- ./hotspot_item (热点条目) drop table if exists hotspot_item; CREATE TABLE hotspot_item ( `id` VARCHAR(32) comment 'id', `source_id` VARCHAR(32) comment '来源ID', `title` VARCHAR(500) comment '标题', `url` VARCHAR(2000) comment '原文链接', `summary` TEXT comment '摘要', `content` TEXT comment '正文', `heat_score` DOUBLE(10,2) DEFAULT 0 comment '热度分数', `heat_velocity` DOUBLE(10,2) DEFAULT 0 comment '热度加速度', `publish_time` VARCHAR(50) comment '发布时间', `first_seen` VARCHAR(50) comment '首次发现', `last_updated` VARCHAR(50) comment '最后更新', `status` VARCHAR(20) DEFAULT 'emerging' comment '状态: emerging/rising/hot/cooling/expired', `category` VARCHAR(100) comment '分类', `tags` VARCHAR(500) comment '标签', `engagement_count` INT DEFAULT 0 comment '互动数', `comment_count` INT DEFAULT 0 comment '评论数', `share_count` INT DEFAULT 0 comment '转发数', `sentiment` VARCHAR(20) DEFAULT 'neutral' comment '情感: positive/negative/neutral', `is_verified` VARCHAR(1) DEFAULT '0' comment '是否已验证', `duplicate_of` VARCHAR(32) comment '重复于(另一热点ID)' ,primary key(id) ) engine=innodb default charset=utf8 comment '热点条目' ; CREATE INDEX hotspot_item_source_idx ON hotspot_item(source_id); CREATE INDEX hotspot_item_status_idx ON hotspot_item(status); CREATE INDEX hotspot_item_score_idx ON hotspot_item(heat_score); -- ./hotspot_analysis (五维分析) drop table if exists hotspot_analysis; CREATE TABLE hotspot_analysis ( `id` VARCHAR(32) comment 'id', `item_id` VARCHAR(32) comment '关联热点ID', `dimension` VARCHAR(50) comment '维度: time/heat/content/propagation/audience', `score` DOUBLE(10,2) DEFAULT 0 comment '维度得分(0-100)', `analysis_data` TEXT comment '分析数据JSON', `analyzed_at` VARCHAR(50) comment '分析时间' ,primary key(id) ) engine=innodb default charset=utf8 comment '五维分析' ; CREATE INDEX hotspot_analysis_item_idx ON hotspot_analysis(item_id); -- ./hotspot_alert (预警规则) drop table if exists hotspot_alert; CREATE TABLE hotspot_alert ( `id` VARCHAR(32) comment 'id', `name` VARCHAR(200) comment '规则名称', `source_id` VARCHAR(32) comment '来源ID(空=全局)', `condition_type` VARCHAR(50) comment '条件: heat_threshold/velocity/sentiment/status_change', `condition_value` VARCHAR(500) comment '条件值 JSON', `enabled` VARCHAR(1) DEFAULT '1' comment '是否启用', `notify_method` VARCHAR(50) comment '通知方式: email/webhook/sms', `notify_target` VARCHAR(500) comment '通知目标', `last_triggered` VARCHAR(50) comment '上次触发时间' ,primary key(id) ) engine=innodb default charset=utf8 comment '预警规则' ;