claude_sms_test
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
# model/stu_score_model.py
|
||||
# 学生成绩表模型
|
||||
from sqlalchemy import Column, Integer, String, Boolean, ForeignKey
|
||||
from sqlalchemy.dialects.mysql import DECIMAL
|
||||
from sqlalchemy.orm import relationship
|
||||
from database import Base
|
||||
|
||||
|
||||
class StuScore(Base):
|
||||
"""
|
||||
学生成绩表模型
|
||||
对应 MySQL 中的 stu_score 表
|
||||
"""
|
||||
__tablename__ = "stu_score" # 表名
|
||||
|
||||
# 字段定义
|
||||
id = Column(Integer, primary_key=True, nullable=False, autoincrement=True) # 自增主键
|
||||
stu_id = Column(String(15), ForeignKey("stu_info.id"), nullable=False) # 学生id,非空
|
||||
exam_attempt = Column(Integer, nullable=False, default=1) # 考试轮次,非空
|
||||
exam_score = Column(DECIMAL(5, 2), nullable=False) # 成绩,非空
|
||||
score_level = Column(String(10), nullable=False, default="普通") # 成绩评级
|
||||
is_deleted = Column(Boolean, default=False, nullable=False) # 软删除: False-正常 True-已删除
|
||||
|
||||
student = relationship("StuInfo", back_populates="score")
|
||||
|
||||
def __repr__(self):
|
||||
return (f"<StuScore(stu_id={self.stu_id}, exam_attempt='{self.exam_attempt}'"
|
||||
f"exam_score={self.exam_score}, score_level='{self.score_level}'"
|
||||
f"is_deleted={self.is_deleted})>")
|
||||
Reference in New Issue
Block a user