Files
student-management-system/model/cls_mgmt_model.py
T

30 lines
1.1 KiB
Python
Raw Normal View History

2026-09-18 16:53:21 +08:00
# model/cls_mgmt_model.py
# 班级管理表模型
from sqlalchemy import Column, Integer, String, Date, ForeignKey
from sqlalchemy.orm import relationship
from database import Base
class ClsMgmt(Base):
"""
班级管理表模型
对应 MySQL 中的 cls_mgmt 表
"""
__tablename__ = "cls_mgmt" # 表名
# 字段定义
id = Column(String(15), primary_key=True, nullable=False) # 班级编号,主键,非空
cls_start_date = Column(Date, nullable=False) # 开课时间
head_tea_id = Column(String(15), ForeignKey("tea_info.id"), nullable=False) # 班主任id
lecturer_id = Column(String(15), ForeignKey("tea_info.id"), nullable=False) # 主讲老师id
is_deleted = Column(Integer, nullable=False, default=0)
stu = relationship("StuInfo", back_populates="cls")
head_teacher = relationship("Teacher",
foreign_keys=[head_tea_id],
back_populates="head_classes")
lecturer = relationship("Teacher",
foreign_keys=[lecturer_id],
back_populates="lecturer_classes")