from __future__ import annotations from sqlalchemy import BigInteger, Integer, String from sqlalchemy.orm import Mapped, mapped_column from app.db.base import Base from app.models.mixins import TimestampMixin BIGINT_PK = BigInteger().with_variant(Integer, "sqlite") class Department(TimestampMixin, Base): """科室模型:使用用户端确定的 department 表字段。""" __tablename__ = "department" id: Mapped[int] = mapped_column(BIGINT_PK, primary_key=True, autoincrement=True, comment="科室ID") name: Mapped[str] = mapped_column(String(100), nullable=False, comment="科室名称") category: Mapped[str] = mapped_column(String(50), nullable=False, comment="科室分类") institution_id: Mapped[int] = mapped_column(BigInteger, nullable=False, index=True, comment="所属机构ID") __table_args__ = {"comment": "科室表"}