34 lines
1.5 KiB
Python
34 lines
1.5 KiB
Python
from datetime import datetime
|
|
|
|
from sqlalchemy import DateTime, Integer, JSON, Numeric, String
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.db.base import Base
|
|
from app.models.mixins import TimestampMixin
|
|
|
|
|
|
class User(TimestampMixin, Base):
|
|
"""宿主用户引用:保存外部 user_id,不承担登录注册职责。"""
|
|
|
|
__tablename__ = "users"
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
external_user_id: Mapped[str] = mapped_column(String(128), nullable=False, unique=True, index=True)
|
|
display_name: Mapped[str | None] = mapped_column(String(100), nullable=True)
|
|
|
|
|
|
class UserLearningProfile(TimestampMixin, Base):
|
|
"""学习档案模型:聚合完整评价记录形成用户能力画像。"""
|
|
|
|
__tablename__ = "user_learning_profiles"
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
user_id: Mapped[str] = mapped_column(String(128), nullable=False, index=True)
|
|
tenant_id: Mapped[str | None] = mapped_column(String(128), nullable=True, index=True)
|
|
total_evaluations: Mapped[int] = mapped_column(Integer, default=0)
|
|
avg_score_percentage: Mapped[float | None] = mapped_column(Numeric(6, 2))
|
|
avg_score_five_point: Mapped[float | None] = mapped_column(Numeric(4, 2))
|
|
weak_dimensions: Mapped[list | None] = mapped_column(JSON)
|
|
last_evaluation_id: Mapped[int | None] = mapped_column(Integer)
|
|
last_trained_at: Mapped[datetime | None] = mapped_column(DateTime, index=True)
|