model.py 933 B

123456789101112131415161718192021222324252627282930
  1. # -*- coding: utf-8 -*-
  2. from typing import TYPE_CHECKING
  3. from sqlalchemy import String, Integer
  4. from sqlalchemy.orm import relationship, Mapped, mapped_column
  5. from app.core.base_model import ModelMixin, UserMixin
  6. if TYPE_CHECKING:
  7. from app.api.v1.module_system.user.model import UserModel
  8. class PositionModel(ModelMixin, UserMixin):
  9. """
  10. 岗位模型
  11. """
  12. __tablename__: str = "sys_position"
  13. __table_args__: dict[str, str] = ({'comment': '岗位表'})
  14. __loader_options__: list[str] = ["users", "created_by", "updated_by"]
  15. name: Mapped[str] = mapped_column(String(40), nullable=False, comment="岗位名称")
  16. order: Mapped[int] = mapped_column(Integer, nullable=False, default=1, comment="显示排序")
  17. # 关联关系
  18. users: Mapped[list["UserModel"]] = relationship(
  19. secondary="sys_user_positions",
  20. back_populates="positions",
  21. lazy="selectin"
  22. )