21 lines
835 B
Python
21 lines
835 B
Python
# model/scores.py
|
|
# 成绩表:复合主键 (stu_id, exam_id),补充 is_deleted 以统一逻辑删除风格
|
|
from sqlalchemy import Column, Integer, Float, ForeignKey
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from database import Base
|
|
|
|
|
|
class Score(Base):
|
|
__tablename__ = "score"
|
|
|
|
stu_id = Column(Integer, ForeignKey("student.stu_id"), primary_key=True, comment="学生编号")
|
|
exam_id = Column(Integer, primary_key=True, comment="考核序次:一个学生有多次考核")
|
|
score = Column(Float, default=None, comment="考核成绩")
|
|
is_deleted = Column(Integer, default=0, nullable=False, comment="逻辑删除: 0正常 1删除")
|
|
|
|
student = relationship("Student", back_populates="scores")
|
|
|
|
def __repr__(self):
|
|
return f"<Score(stu_id={self.stu_id}, exam_id={self.exam_id}, score={self.score})>"
|