update:1.更新根据分析建议重新生成章节内容
This commit is contained in:
@@ -12,6 +12,8 @@ from app.models.memory import StoryMemory, PlotAnalysis
|
||||
from app.models.writing_style import WritingStyle
|
||||
from app.models.project_default_style import ProjectDefaultStyle
|
||||
from app.models.mcp_plugin import MCPPlugin
|
||||
from app.models.user import User, UserPassword
|
||||
from app.models.regeneration_task import RegenerationTask
|
||||
|
||||
__all__ = [
|
||||
"Project",
|
||||
@@ -30,5 +32,8 @@ __all__ = [
|
||||
"PlotAnalysis",
|
||||
"WritingStyle",
|
||||
"ProjectDefaultStyle",
|
||||
"MCPPlugin"
|
||||
"MCPPlugin",
|
||||
"User",
|
||||
"UserPassword",
|
||||
"RegenerationTask"
|
||||
]
|
||||
@@ -0,0 +1,51 @@
|
||||
"""章节重新生成任务模型"""
|
||||
from sqlalchemy import Column, String, Text, Integer, DateTime, ForeignKey, JSON, Boolean
|
||||
from sqlalchemy.sql import func
|
||||
from app.database import Base
|
||||
import uuid
|
||||
|
||||
|
||||
class RegenerationTask(Base):
|
||||
"""章节重新生成任务表"""
|
||||
__tablename__ = "regeneration_tasks"
|
||||
|
||||
# 基本信息
|
||||
id = Column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
|
||||
chapter_id = Column(String(36), ForeignKey('chapters.id', ondelete='CASCADE'), nullable=False, index=True)
|
||||
analysis_id = Column(String(36), nullable=True, comment="关联的分析结果ID")
|
||||
user_id = Column(String(50), nullable=False, index=True)
|
||||
project_id = Column(String(36), nullable=False, index=True)
|
||||
|
||||
# 修改指令
|
||||
modification_instructions = Column(Text, nullable=False, comment="综合修改指令")
|
||||
original_suggestions = Column(JSON, comment="来自分析的原始建议列表")
|
||||
selected_suggestion_indices = Column(JSON, comment="用户选择的建议索引")
|
||||
custom_instructions = Column(Text, comment="用户自定义修改意见")
|
||||
|
||||
# 生成参数
|
||||
style_id = Column(Integer, nullable=True, comment="写作风格ID")
|
||||
target_word_count = Column(Integer, default=3000, comment="目标字数")
|
||||
focus_areas = Column(JSON, comment="重点优化方向")
|
||||
preserve_elements = Column(JSON, comment="需要保留的元素配置")
|
||||
|
||||
# 状态跟踪
|
||||
status = Column(String(20), default='pending', comment="pending/running/completed/failed")
|
||||
progress = Column(Integer, default=0, comment="进度 0-100")
|
||||
error_message = Column(Text, nullable=True)
|
||||
|
||||
# 内容版本
|
||||
original_content = Column(Text, comment="原始章节内容快照")
|
||||
original_word_count = Column(Integer, comment="原始字数")
|
||||
regenerated_content = Column(Text, comment="重新生成的内容")
|
||||
regenerated_word_count = Column(Integer, comment="新内容字数")
|
||||
version_number = Column(Integer, default=1, comment="版本号")
|
||||
version_note = Column(String(500), comment="版本说明")
|
||||
|
||||
# 时间戳
|
||||
created_at = Column(DateTime, server_default=func.now())
|
||||
started_at = Column(DateTime, nullable=True)
|
||||
completed_at = Column(DateTime, nullable=True)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<RegenerationTask(id={self.id[:8]}..., chapter_id={self.chapter_id[:8]}..., status={self.status})>"
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
"""
|
||||
用户数据模型 - 存储用户基本信息
|
||||
"""
|
||||
from sqlalchemy import Column, String, Integer, Boolean, DateTime
|
||||
from sqlalchemy.sql import func
|
||||
from app.database import Base
|
||||
|
||||
|
||||
class User(Base):
|
||||
"""用户模型 - 存储OAuth和本地用户信息"""
|
||||
__tablename__ = "users"
|
||||
|
||||
user_id = Column(String(100), primary_key=True, index=True, comment="用户ID,格式:linuxdo_{id} 或 local_{id}")
|
||||
username = Column(String(100), nullable=False, index=True, comment="用户名")
|
||||
display_name = Column(String(200), nullable=False, comment="显示名称")
|
||||
avatar_url = Column(String(500), nullable=True, comment="头像URL")
|
||||
trust_level = Column(Integer, default=0, comment="信任等级(仅用于显示)")
|
||||
is_admin = Column(Boolean, default=False, comment="是否为管理员")
|
||||
linuxdo_id = Column(String(100), nullable=False, unique=True, index=True, comment="LinuxDO用户ID或本地用户ID")
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now(), comment="创建时间")
|
||||
last_login = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now(), comment="最后登录时间")
|
||||
|
||||
def to_dict(self):
|
||||
"""转换为字典"""
|
||||
return {
|
||||
"user_id": self.user_id,
|
||||
"username": self.username,
|
||||
"display_name": self.display_name,
|
||||
"avatar_url": self.avatar_url,
|
||||
"trust_level": self.trust_level,
|
||||
"is_admin": self.is_admin,
|
||||
"linuxdo_id": self.linuxdo_id,
|
||||
"created_at": self.created_at.isoformat() if self.created_at else None,
|
||||
"last_login": self.last_login.isoformat() if self.last_login else None,
|
||||
}
|
||||
|
||||
|
||||
class UserPassword(Base):
|
||||
"""用户密码模型 - 存储用户密码信息"""
|
||||
__tablename__ = "user_passwords"
|
||||
|
||||
user_id = Column(String(100), primary_key=True, index=True, comment="用户ID")
|
||||
username = Column(String(100), nullable=False, comment="用户名")
|
||||
password_hash = Column(String(64), nullable=False, comment="密码哈希(SHA256)")
|
||||
has_custom_password = Column(Boolean, default=False, comment="是否为自定义密码")
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now(), comment="创建时间")
|
||||
updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now(), comment="更新时间")
|
||||
Reference in New Issue
Block a user