Initial commit
This commit is contained in:
7
backend/app/models/__init__.py
Normal file
7
backend/app/models/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
||||
"""
|
||||
Models package initialization
|
||||
"""
|
||||
|
||||
from app.models.intent import Intent, AICheckRecord
|
||||
|
||||
__all__ = ["Intent", "AICheckRecord"]
|
||||
38
backend/app/models/intent.py
Normal file
38
backend/app/models/intent.py
Normal file
@@ -0,0 +1,38 @@
|
||||
"""
|
||||
意图编制数据模型
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey, JSON
|
||||
from sqlalchemy.orm import relationship
|
||||
from app.database import Base
|
||||
|
||||
|
||||
class Intent(Base):
|
||||
"""意图编制表"""
|
||||
__tablename__ = "intents"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
title = Column(String(255), nullable=False, comment="意图标题")
|
||||
content = Column(Text, nullable=True, comment="意图内容")
|
||||
status = Column(String(50), default="draft", comment="状态: draft, submitted, approved")
|
||||
created_at = Column(DateTime, default=datetime.utcnow, comment="创建时间")
|
||||
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, comment="更新时间")
|
||||
|
||||
# 关联 AI 检查记录
|
||||
check_records = relationship("AICheckRecord", back_populates="intent", cascade="all, delete-orphan")
|
||||
|
||||
|
||||
class AICheckRecord(Base):
|
||||
"""AI 检查记录表"""
|
||||
__tablename__ = "ai_check_records"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
intent_id = Column(Integer, ForeignKey("intents.id"), nullable=False)
|
||||
check_result = Column(JSON, nullable=True, comment="检查结果JSON")
|
||||
suggestions = Column(Text, nullable=True, comment="AI建议")
|
||||
checked_at = Column(DateTime, default=datetime.utcnow, comment="检查时间")
|
||||
|
||||
# 关联意图
|
||||
intent = relationship("Intent", back_populates="check_records")
|
||||
Reference in New Issue
Block a user