""" 会话模型 """ from datetime import datetime from app.utils.timezone import beijing_now_naive from sqlalchemy import Column, Integer, String, DateTime, Boolean from app.database import Base class Session(Base): """会话表""" __tablename__ = "sessions" id = Column(Integer, primary_key=True, autoincrement=True, comment="主键ID") session_id = Column(String(64), unique=True, nullable=False, comment="会话ID(UUID)") user_id = Column(Integer, nullable=False, comment="用户ID") machine_code = Column(String(255), nullable=False, comment="机器码") is_active = Column(Boolean, default=True, comment="是否激活") expires_at = Column(DateTime, nullable=False, comment="过期时间") created_at = Column(DateTime, default=beijing_now_naive, comment="创建时间") updated_at = Column(DateTime, default=beijing_now_naive, onupdate=beijing_now_naive, comment="更新时间") def __repr__(self): return f""