Files
Zhang Jing Xuan 0841b1a103 智教助手平台:完整初始化
- 前端:Vue3 + TS + Element Plus,24 个页面路由(课件/组题/教案/动画/思维导图/作文批改/命题/课堂/资源/社区等)
- 后端:FastAPI + SQLAlchemy + SQLite,17 个路由模块,AI 服务层含降级模板
- AI:glm-5.x 推理模型已禁用思维链,确保输出真实内容
- 修复:ai_service 两处请求体注入 enable_thinking/thinking disabled
- 测试账号:13900999999 / test1234
2026-07-29 16:29:10 +08:00

37 lines
2.3 KiB
Python

from sqlalchemy import Column, Integer, String, DateTime, Enum as SAEnum, Boolean
from sqlalchemy.orm import relationship
from sqlalchemy.sql import func
from database import Base
class User(Base):
__tablename__ = "users"
id = Column(Integer, primary_key=True, index=True)
phone = Column(String(20), unique=True, index=True, nullable=False)
password_hash = Column(String(255), nullable=False)
name = Column(String(50), nullable=False)
avatar = Column(String(500), default="")
subject = Column(String(50), default="")
school = Column(String(100), default="")
grade = Column(String(50), default="")
role = Column(SAEnum("teacher", "admin", name="user_role"), default="teacher")
is_active = Column(Boolean, default=True)
created_at = Column(DateTime, server_default=func.now())
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())
coursewares = relationship("Courseware", back_populates="author", lazy="selectin")
animations = relationship("Animation", back_populates="author", lazy="selectin")
exercises = relationship("Exercise", back_populates="author", lazy="selectin")
lesson_plans = relationship("LessonPlan", back_populates="author", lazy="selectin")
essay_grades = relationship("EssayGrade", back_populates="author", lazy="selectin", cascade="all, delete-orphan")
resources = relationship("Resource", back_populates="author", lazy="selectin")
materials = relationship("Material", back_populates="author", lazy="selectin", cascade="all, delete-orphan")
resource_favorites = relationship("ResourceFavorite", back_populates="user", lazy="selectin", cascade="all, delete-orphan")
posts = relationship("Post", back_populates="author", lazy="selectin")
credit_account = relationship("CreditAccount", back_populates="user", uselist=False, lazy="selectin", cascade="all, delete-orphan")
credit_transactions = relationship("CreditTransaction", back_populates="user", lazy="selectin", cascade="all, delete-orphan")
mind_maps = relationship("MindMap", back_populates="author", lazy="selectin", cascade="all, delete-orphan")
notifications = relationship("Notification", back_populates="user", lazy="selectin", cascade="all, delete-orphan")
chat_conversations = relationship("ChatConversation", back_populates="author", lazy="selectin", cascade="all, delete-orphan")