学生管理系统代码提交
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
# model/classes.py
|
||||
# 班级表:对应建表语句中的 c_lass(补充 class_name 字段,便于展示与统计)
|
||||
from sqlalchemy import Column, Integer, String, Date
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from database import Base
|
||||
|
||||
|
||||
class Classinfo(Base):
|
||||
__tablename__ = "c_lass"
|
||||
|
||||
class_id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
class_name = Column(String(50), nullable=False, comment="班级名称,如 Java2301")
|
||||
start_time = Column(Date, nullable=False, comment="开课时间")
|
||||
is_deleted = Column(Integer, default=0, nullable=False, comment="逻辑删除: 0正常 1删除")
|
||||
|
||||
# 反向关联
|
||||
teachers = relationship("Teacher", back_populates="classes")
|
||||
students = relationship("Student", back_populates="classes")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Classinfo(class_id={self.class_id}, class_name='{self.class_name}')>"
|
||||
Reference in New Issue
Block a user