feat: 完善AI改写草稿箱功能 - 修复重头游玩、评分、数据刷新等问题

This commit is contained in:
wangwuww111
2026-03-09 14:15:00 +08:00
parent bbdccfa843
commit 18db6a8cc6
17 changed files with 1385 additions and 99 deletions

View File

@@ -564,3 +564,39 @@ CREATE TABLE sensitive_words (
UNIQUE KEY uk_word (word),
INDEX idx_category (category)
) ENGINE=InnoDB COMMENT='敏感词表';
-- ============================================
-- 九、AI改写草稿箱
-- ============================================
-- AI改写草稿表
CREATE TABLE story_drafts (
id BIGINT PRIMARY KEY AUTO_INCREMENT,
user_id BIGINT NOT NULL COMMENT '用户ID',
story_id BIGINT NOT NULL COMMENT '原故事ID',
title VARCHAR(100) DEFAULT '' COMMENT '草稿标题',
-- 用户输入
path_history JSON COMMENT '用户之前的选择路径',
current_node_key VARCHAR(50) DEFAULT '' COMMENT '改写起始节点',
current_content TEXT COMMENT '当前节点内容',
user_prompt VARCHAR(500) NOT NULL COMMENT '用户改写指令',
-- AI生成结果
ai_nodes JSON COMMENT 'AI生成的新节点',
entry_node_key VARCHAR(50) DEFAULT '' COMMENT '入口节点',
tokens_used INT DEFAULT 0 COMMENT '消耗token数',
-- 状态
status ENUM('pending', 'processing', 'completed', 'failed') DEFAULT 'pending' COMMENT '状态',
error_message VARCHAR(500) DEFAULT '' COMMENT '失败原因',
is_read BOOLEAN DEFAULT FALSE COMMENT '用户是否已查看',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
completed_at TIMESTAMP NULL COMMENT '完成时间',
INDEX idx_user (user_id),
INDEX idx_story (story_id),
INDEX idx_status (status),
INDEX idx_user_unread (user_id, is_read)
) ENGINE=InnoDB COMMENT='AI改写草稿表';